保誠-保戶業務員媒合平台
PAMapp/assets/ts/api/consultant.ts
@@ -1,32 +1,45 @@
import { service } from '~/assets/ts/api/share';
import { AxiosResponse } from 'axios';
import { AppointmentDetail } from '../models/AppointmentDetail';
import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
import _ from 'lodash';
import { UserSetting } from '../models/account.model';
import { Consultant } from '~/assets/ts/models/consultant.model';
import { http } from '../services/httpClient';
// 顧客登入(TODO: OTP認證開發前 暫時使用)
export function login(user: any) {
    return service.post('/authenticate', user)
    return http.post('/authenticate', user)
}
// 顧客登入-發送OTP
export function sendOtp(loginInfo: LoginRequest) {
    return http.post<OtpInfo>('/otp/sendOtp', loginInfo).then(res => res.data)
}
// 顧客登入-驗證otp並登入
export function loginVerify(loginVerify: LoginVerify) {
    return http.post('/otp/verify', loginVerify)
}
// 顧客註冊
export function register(registerInfo: RegisterInfo) {
    return http.post('/otp/register', registerInfo)
}
// 推薦保險顧問
export function recommend() {
    return service.get('/consultant/recommend')
}
// 我的顧問清單
export function getFavoriteConsultant() {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.get('/consultant/favorite', {headers});
    return http.get<Consultant[]>('/consultant/recommend')
            .then(res => res.data);
}
// 快速篩選
export function fastQuery(data: FastQueryParams) {
    return service.post('/consultant/fastQuery', data)
    return http.post('/consultant/fastQuery', data)
}
// 嚴選配對
export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery>>{
    return service.post('/consultant/strictQuery', data)
export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery[]>>{
    return http.post('/consultant/strictQuery', data)
}
// 加入顧問
@@ -34,7 +47,7 @@
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.post('/consultant/favorite', {agentNoList}, {headers})
    return http.post('/consultant/favorite', {agentNoList}, {headers})
}
// 預約前詢問
@@ -42,12 +55,12 @@
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.post('/appointment/customer/create', data, {headers})
    return http.post('/appointment/customer/create', data, {headers})
}
//顧問詳細資訊
export function getConsultantDetail(agentNo:string){
    return service.get('/consultant/detail', {params:{agentNo:agentNo}})
    return http.get('/consultant/detail', {params:{agentNo:agentNo}})
}
// 移除顧問
@@ -55,28 +68,179 @@
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return service.delete('/consultant/favorite/'+agentId, {headers})
    return http.delete('/consultant/favorite/'+agentId, {headers})
}
export interface Consultants {
    agentNo: string,
    name: string,
    img: string,
    new: boolean,
    avgScore: number,
    expertise: string[],
    updateTime: Date,
    seniority: string,
    contactStatus?: string;
// 取得驗證碼圖片
export function 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;
  });
}
// 驗證碼 驗證
export function getVerificationStatus(imgCode:string):Promise<AxiosResponse<boolean>>{
  return http.get('/login/validate/verify_img_code/'+imgCode);
}
// 顧問登入
export function logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<AxiosResponse<RequestOfLoginSuccess>>{
    return http.post('/eService/authenticate',consultantDto);
}
// 取得預約單細節
export function getAppointmentDetail(apointmentId: number):Promise<AxiosResponse<AppointmentDetail>> {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.get('/appointment/getDetail/'+apointmentId, {headers})
}
//取得使用者帳號資訊
export function getUserAccountSetting() : Promise<UserSetting> {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.get<UserSetting>('/customer/info', {headers}).then(res => res.data);
}
//更新使用者帳號資訊
export function updateAccountSetting(params: any) : any {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.put('/customer/info', params ,{headers}).then(res => res.data);
}
//客戶進行滿意度評分
export function userReviewsConsultants(data: UserReviewsConsultantsParams) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.post('/satisfaction/create', data ,{headers});
}
// 取消預約
export function cancelAppointment(appointment: number) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.delete('/appointment/'+appointment ,{headers});
}
// 編輯預約
export function editAppointment(editAppointmentParams: editAppointmentParams) {
    const headers = {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
    return http.put('/appointment', editAppointmentParams, {headers});
}
export interface FastQueryParams {
    gender: string,
    gender             : string,
    communicationStyles: string[],
    avgScore: number,
    status: 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
}
export interface UserReviewsConsultantsParams{
    appointmentId:number,
    score:number,
}
export interface editAppointmentParams {
    id: number,
    phone: string,
    email: string,
    contactType: string,
@@ -85,29 +249,5 @@
    job: string,
    requirement: string,
    hopeContactTime: string,
    otherRequirement: string,
    agentNo: string
    otherRequirement: null
}
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;
}