保誠-保戶業務員媒合平台
劉鈞霖
2021-12-15 95d0e5524c3ab1e55a9909e2c38e7cc35901220f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { AxiosResponse } from 'axios';
import { http } from "./httpClient";
import { editAppointmentParams } from '../models/editAppointmentParams.model';
import { AppointmentDetail } from '../models/AppointmentDetail';
import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
import { UserSetting } from '../models/account.model';
import { FastQueryParams } from '../models/quickFilter.model';
import { LoginRequest } from "../models/loginRequest.model";
import { OtpInfo } from "../models/otpInfo.model";
import { Consultant } from '../models/consultant.model';
import { RegisterInfo } from '../models/registerInfo';
import { LoginVerify } from '../models/loginVerify.model';
import { StrictQueryParams } from '../models/strictQueryParams';
import { AppointmentParams } from '../models/appointmentParams';
import { UserReviewsConsultantsParams } from '../models/UserReviewsConsultantsParams';
import { LoginSuccessToken } from '../models/loginSuccessToken.model';
import { AgentOfStrictQuery } from '../models/agentOfStrictQuery';
import _ from "lodash";
 
 
 
 
class PamService {
  constructor() {}
 
  /** 顧客登入-發送OTP **/
  sendOtp(loginInfo: LoginRequest):Promise<AxiosResponse<OtpInfo>> {
    return http.post('/otp/sendOtp', loginInfo).then( res => res.data );
  }
 
  /** 顧客登入-驗證OTP **/
  loginVerify(loginVerify: LoginVerify):Promise<AxiosResponse<any>>{
    return http.post('/otp/verify', loginVerify);
  }
 
  /** 顧客註冊 **/
  register(registerInfo: RegisterInfo):Promise<AxiosResponse<any>>{
    return http.post('/otp/register', registerInfo);
  }
 
  /** 推薦保險顧問 **/
  recommend():Promise<AxiosResponse<Consultant[]>>{
    return http.get('/consultant/recommend');
  }
 
  /** 快速篩選 **/
  fastQuery(data: FastQueryParams):Promise<AxiosResponse<Consultant[]>>{
    return http.post('/consultant/fastQuery', data)
  }
 
  /** 嚴選配對 **/
  strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery[]>>{
    return http.post('/consultant/strictQuery', data)
  }
 
  /** 加入顧問 **/
  addFavoriteConsultant(agentNoList: string[]):Promise<AxiosResponse<any>>{
    return http.post('/consultant/favorite', {agentNoList})
  }
 
  /** 預約前詢問 **/
  appointmentDemand(data: AppointmentParams):Promise<AxiosResponse<any>> {
    return http.post('/appointment/customer/create', data)
  }
 
  /** 顧問詳細資訊 **/
  getConsultantDetail(agentNo:string):Promise<AxiosResponse<any>>{
    return http.get('/consultant/detail', {params:{agentNo:agentNo}})
  }
 
  /** 移除顧問 **/
  deleteConsultant(agentId: string):Promise<AxiosResponse<any>>{
    return http.delete('/consultant/favorite/'+agentId);
  }
 
  /** 取得驗證碼圖片 **/
  getImgOfVerification():Promise<string>{
    return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' })
      .then( response => {
        const toBase64 = window.btoa(
                          _.reduce( new Uint8Array(response.data),(data,byte) =>
                            data + String.fromCharCode(byte),'')
                        );
        const imgSrc = `data:image/jpeg;base64,${toBase64}`;
        return imgSrc;
    });
  }
 
  /** 驗證碼-驗證 **/
  getVerificationStatus(imgCode:string):Promise<AxiosResponse<boolean>>{
    return http.get('/login/validate/verify_img_code/'+imgCode);
  }
 
  /** 顧問登入 **/
  logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<AxiosResponse<LoginSuccessToken>>{
    return http.post('/ehttp/authenticate',consultantDto);
  }
 
  /** 取得預約單細節 **/
  getAppointmentDetail(apointmentId: number):Promise<AxiosResponse<AppointmentDetail>> {
    return http.get('/appointment/getDetail/'+apointmentId)
  }
 
  /** 取得使用者帳號資訊 **/
  getUserAccountSetting():Promise<AxiosResponse<UserSetting>>{
    return http.get<UserSetting>('/customer/info');
  }
 
  /** 更新使用者帳號資訊 **/
  updateAccountSetting(params: any):Promise<AxiosResponse<any>> {
    return http.put('/customer/info', params);
  }
 
  //客戶進行滿意度評分
  userReviewsConsultants(data: UserReviewsConsultantsParams):Promise<AxiosResponse<any>> {
    return http.post('/satisfaction/create', data);
  }
 
  // 取消預約
  cancelAppointment(appointment: number):Promise<AxiosResponse<any>>{
    return http.delete('/appointment/'+appointment);
  }
 
  // 編輯預約
  editAppointment(editAppointmentParams:editAppointmentParams):Promise<AxiosResponse<any>>{
    return http.put('/appointment', editAppointmentParams);
  }
}
 
export default new PamService();