From 60dc6e178e4ab05ea8f62f7baa1dd72a5c20f93c Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期一, 13 十二月 2021 16:10:13 +0800
Subject: [PATCH] fixed#132096: 查看完聯絡清單(或登出後再登入),顧問清單的黃點並不會消失

---
 PAMapp/assets/ts/api/consultant.ts |  277 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 192 insertions(+), 85 deletions(-)

diff --git a/PAMapp/assets/ts/api/consultant.ts b/PAMapp/assets/ts/api/consultant.ts
index c761f2f..2cf639b 100644
--- a/PAMapp/assets/ts/api/consultant.ts
+++ b/PAMapp/assets/ts/api/consultant.ts
@@ -1,51 +1,45 @@
-import axios from 'axios';
-import { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
-import { MessageBox } from 'element-ui';
-import { functionsIn } from 'lodash';
-import Router from 'vue-router';
-
-export const service = axios.create({
-    baseURL: 'http://localhost:8080/api'
-})
-
-service.interceptors.request.use(function (config: AxiosRequestConfig) {
-    return config;
-}, function (error: AxiosError) {
-    return Promise.reject(error);
-});
-
-service.interceptors.response.use(function (response: AxiosResponse) {
-    return response;
-}, function (error: AxiosError) {
-    return Promise.reject(error);
-});
+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)
+}
+
+// 憿批恥��-��TP
+export function sendOtp(loginInfo: LoginRequest) {
+    return http.post<OtpInfo>('/otp/sendOtp', loginInfo).then(res => res.data)
+}
+
+// 憿批恥��-撽�tp銝衣�
+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)
 }
 
 // ��憿批��
@@ -53,81 +47,199 @@
     const headers = {
         Authorization: 'Bearer ' + localStorage.getItem('id_token')
     }
-    return service.post('/consultant/favorite', {agentNoList}, {headers})
+    return http.post('/consultant/favorite', {agentNoList}, {headers})
 }
 
 // ����岷���
 export function appointmentDemand(data: AppointmentParams) {
-    return service.post('/appointment/customer/create', data)
+    const headers = {
+        Authorization: 'Bearer ' + localStorage.getItem('id_token')
+    }
+    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}})
 }
 
-// ���������
-export function getMyAppointmentList():Promise<AxiosResponse<ClientInfo>> {
+// 蝘駁憿批��
+export function deleteConsultant(agentId: string) {
     const headers = {
         Authorization: 'Bearer ' + localStorage.getItem('id_token')
     }
-    return service.get('/consultant/getMyAppointment', {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);
+}
+
+//摰X�脰�遛��漲閰��
+
+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,
+    phone          : string,
+    email          : string,
+    contactType    : string,
+    gender         : string,
+    age            : string,
+    job            : string,
+    requirement    : string,
     hopeContactTime: string,
-    otherRequirement: string,
-    agentNo: string
+    agentNo        : string
 }
 export interface StrictQueryParams{
-    gender:           string;
-    avgScore:         number;
-    status:           string; //phase 1 disable
-    area:             string;
-    requirements:     string[];
+    gender          : string;
+    avgScore        : number;
+    status          : string;    //phase 1 disable
+    area            : string;
+    requirements    : string[];
     otherRequirement: string;
-    seniority:        string;
-    popularTags:      string[];
+    seniority       : string;
+    popularTags     : string[];
     otherPopularTags: string;
 }
 export interface AgentOfStrictQuery {
-    agentNo:       string;
-    name:          string;
-    img:           string;
-    expertise:     string[];
-    avgScore:      number;
+    agentNo      : string;
+    name         : string;
+    img          : string;
+    expertise    : string[];
+    avgScore     : number;
     contactStatus: null;
-    updateTime:    null;
-    seniority:     string;
-    new:           boolean;
+    updateTime   : null;
+    seniority    : string;
+    new          : boolean;
+}
+export interface RequestOfLoginSuccess{
+  id_token: string;
 }
 
-export interface ClientInfo {
+export interface LoginRequest {
+    /** "SMS"=�����"EMAIL"=email */
+    loginType: string,
+    /** �loginType憛俟MS��府甈葆�����MAIL��葆��隞嗡縑蝞� */
+    account: string,
+}
+
+export interface OtpInfo {
+    /** ��撣嗅otp隤��� */
+    indexKey: string,
+    /** Otp�������� */
+    success: boolean,
+    failCode: string,
+    failReason: string,
+}
+
+export interface LoginVerify {
+    /** �撣嗅����mail */
+    account: string,
+    /** �otp��pi���ndex key */
+    indexKey: string,
+    /** �����縑蝞望�����Ⅳ */
+    otpCode: string
+}
+
+export interface RegisterInfo {
+    phone?: string,
+    email?: string,
+    indexKey: string,
+    otpCode: string,
+    name: string,
+    /** "SMS"嚗tp������"EMAIL":Otp�email */
+    contactType: string
+}
+
+export interface UserReviewsConsultantsParams{
+    appointmentId:number,
+    score:number,
+}
+
+export interface editAppointmentParams {
     id: number,
     phone: string,
     email: string,
@@ -136,11 +248,6 @@
     age: string,
     job: string,
     requirement: string,
-    communicateStatus: string,
     hopeContactTime: string,
-    otherRequirement: string,
-    appointmentDate: Date,
-    agentNo: string,
-    customerId: number,
-    name: string
-}
\ No newline at end of file
+    otherRequirement: null
+}

--
Gitblit v1.8.0