保誠-保戶業務員媒合平台
wayne
2021-11-29 14bd6ba7ea80a0c47301371404754b6a77849cdc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import { service } from '~/assets/ts/api/share';
import { AxiosResponse } from 'axios';
import { AppointmentDetail } from '../models/AppointmentDetail';
import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
import _ from 'lodash';
 
// 顧客登入(TODO: OTP認證開發前 暫時使用)
export function login(user: any) {
    return service.post('/authenticate', user)
}
 
// 顧客登入-發送OTP
export function sendOtp(loginInfo: LoginRequest) {
    return service.post<OtpInfo>('/otp/sendOtp', loginInfo).then(res => res.data)
}
 
// 顧客登入-驗證otp並登入
export function loginVerify(loginVerify: LoginVerify) {
    return service.post('/otp/verify', loginVerify)
}
 
// 顧客註冊
export function register(registerInfo: RegisterInfo) {
    return service.post('/otp/register', registerInfo)
}
 
// 推薦保險顧問
export function recommend() {
    return service.get<Consultants[]>('/consultant/recommend')
            .then(res => res.data);
}
 
// 我的顧問清單
export function getFavoriteConsultant() {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.get<Consultants[]>('/consultant/favorite', {headers})
            .then(res => res.data);
}
 
// 快速篩選
export function fastQuery(data: FastQueryParams) {
    return service.post('/consultant/fastQuery', data)
}
 
// 嚴選配對
export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery[]>>{
    return service.post('/consultant/strictQuery', data)
}
 
// 加入顧問
export function addFavoriteConsultant(agentNoList: string[]) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.post('/consultant/favorite', {agentNoList}, {headers})
}
 
// 預約前詢問
export function appointmentDemand(data: AppointmentParams) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.post('/appointment/customer/create', data, {headers})
}
 
//顧問詳細資訊
export function getConsultantDetail(agentNo:string){
    return service.get('/consultant/detail', {params:{agentNo:agentNo}})
}
 
// 移除顧問
export function deleteConsultant(agentId: string) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.delete('/consultant/favorite/'+agentId, {headers})
}
 
// 取得驗證碼圖片
export function getImgOfVerification():Promise<string>{
  return service.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;
  });
}
 
// 驗證碼 驗證
export function getVerificationStatus(imgCode:string):Promise<AxiosResponse<boolean>>{
  return service.get('/login/validate/verify_img_code/'+imgCode);
}
 
// 顧問登入
export function logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<AxiosResponse<RequestOfLoginSuccess>>{
    return service.post('/eService/authenticate',consultantDto);
}
 
// 取得預約單細節
export function getAppointmentDetail(apointmentId: number):Promise<AxiosResponse<AppointmentDetail>> {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.get('/appointment/getDetail/'+apointmentId, {headers})
}
export interface Consultants {
    agentNo            : string,
    name               : string,
    img                : string,
    new                : boolean,
    avgScore           : number,
    expertise          : string[],
    updateTime         : Date,
    seniority          : string,
    contactStatus?     : string;
    latestAppointmentId: number;
    role               : string;
    image?             : string;
    expertises?        : string;
}
 
export interface FastQueryParams {
    gender             : string,
    communicationStyles: string[],
    avgScore           : number,
    status             : string
}
 
export interface AppointmentRequests {
    phone          : string,
    email          : string,
    contactType    : string,
    gender         : string,
    age            : string,
    job            : string,
    requirement    : string[],
    hopeContactTime: ContactTime[],
    agentNo        : string,
}
export interface ContactTime {
  selectWeekOptions : string[],
  selectTimesOptions: string[]
}
export interface AppointmentParams {
    phone          : string,
    email          : string,
    contactType    : string,
    gender         : string,
    age            : string,
    job            : string,
    requirement    : string,
    hopeContactTime: string,
    agentNo        : string
}
export interface StrictQueryParams{
    gender:           string;
    avgScore:         number;
    status:           string; //phase 1 disable
    area:             string;
    requirements:     string[];
    otherRequirement: string;
    seniority:        string;
    popularTags:      string[];
    otherPopularTags: string;
}
export interface AgentOfStrictQuery {
    agentNo:       string;
    name:          string;
    img:           string;
    expertise:     string[];
    avgScore:      number;
    contactStatus: null;
    updateTime:    null;
    seniority:     string;
    new:           boolean;
}
export interface RequestOfLoginSuccess{
  id_token: string;
}
 
export interface LoginRequest {
    /** "SMS"=手機,"EMAIL"=email */
    loginType: string,
    /** 若loginType填SMS則該欄帶入手機、EMAIL則帶入郵件信箱 */
    account: string,
}
 
export interface OtpInfo {
    /** 用於帶入otp認證時 */
    indexKey: string,
    /** Otp是否有成功發送 */
    success: boolean,
    failCode: string,
    failReason: string,
}
 
export interface LoginVerify {
    /** 可帶入手機或email */
    account: string,
    /** 由otp的api回的index key */
    indexKey: string,
    /** 由手機或信箱收到的認證碼 */
    otpCode: string
}
 
export interface RegisterInfo {
    phone?: string,
    email?: string,
    indexKey: string,
    otpCode: string,
    name: string,
    /** "SMS":Otp發送手機,"EMAIL":Otp發email */
    contactType: string
}