From 1b57ac5bea14a750b5ddf961c3a8510da18f3637 Mon Sep 17 00:00:00 2001
From: 劉鈞霖 <benson@gmail.com>
Date: 星期二, 23 十一月 2021 12:07:02 +0800
Subject: [PATCH] [ Update ] 串接顧問登入 完成 50% (驗證碼以及忘記密碼 尚未 ) 、 新增 api 錯誤訊息 。

---
 PAMapp/assets/ts/api/consultant.ts |  109 ++++++++++++++++++++++--------------------------------
 1 files changed, 44 insertions(+), 65 deletions(-)

diff --git a/PAMapp/assets/ts/api/consultant.ts b/PAMapp/assets/ts/api/consultant.ts
index 1deb514..d0299bb 100644
--- a/PAMapp/assets/ts/api/consultant.ts
+++ b/PAMapp/assets/ts/api/consultant.ts
@@ -1,24 +1,7 @@
-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: process.env.BASE_URL
-})
-
-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 { service } from '~/assets/ts/api/share';
+import { AxiosResponse } from 'axios';
+import { AppointmentDetail } from '../models/AppointmentDetail';
+import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
 
 // 憿批恥��(TODO: OTP隤����� ���蝙�)
 export function login(user: any) {
@@ -27,7 +10,8 @@
 
 // ��靽憿批��
 export function recommend() {
-    return service.get('/consultant/recommend')
+    return service.get<Consultants[]>('/consultant/recommend')
+            .then(res => res.data);
 }
 
 // ���“���
@@ -35,7 +19,8 @@
     const headers = {
         Authorization: 'Bearer ' + localStorage.getItem('id_token')
     }
-    return service.get('/consultant/favorite', {headers});
+    return service.get<Consultants[]>('/consultant/favorite', {headers})
+            .then(res => res.data);
 }
 
 // 敹恍�祟�
@@ -44,7 +29,7 @@
 }
 
 // ������
-export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery>>{
+export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery[]>>{
     return service.post('/consultant/strictQuery', data)
 }
 
@@ -61,7 +46,7 @@
     const headers = {
         Authorization: 'Bearer ' + localStorage.getItem('id_token')
     }
-    return service.post('/appointment/customer/create', data ,{headers})
+    return service.post('/appointment/customer/create', data, {headers})
 }
 
 //憿批�底蝝啗���
@@ -69,12 +54,12 @@
     return service.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 service.delete('/consultant/favorite/'+agentId, {headers})
 }
 
 // 敹��Ⅳ蝬脣�
@@ -84,26 +69,24 @@
     })
 }
 
-// �����Ⅳ���� 
+// �����Ⅳ����
 export function getVerificationCodeImg():Promise<string>{
     return new Promise((resolve, reject)=>{
         resolve('');
     })
-} 
+}
 
 // 憿批��
-export function logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<boolean>{
-    console.log('consultantDto',consultantDto);
-    return new Promise((resolve, reject)=>{
-        setTimeout(()=>{
-            resolve(true);
-        },1000)
-    })
+export function logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<AxiosResponse<RequestOfLoginSuccess>>{
+    return service.post('/eService/authenticate',consultantDto);
 }
-export interface ConsultantLoginInfo{
-    account:string,
-    password:string,
-    verificationCode:string,
+
+// �����蝝啁�
+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,
@@ -115,6 +98,10 @@
     updateTime: Date,
     seniority: string,
     contactStatus?: string;
+    latestAppointmentId: number;
+    role: string;
+    image?: string;
+    expertises?: string;
 }
 
 export interface FastQueryParams {
@@ -124,16 +111,25 @@
     status: string
 }
 
+export interface AppointmentRequests {
+  connectDevices: any[],
+  hopeContactTime: any,
+  email?: string,
+  job?: string,
+  otherJob?: string,
+  gender?: string,
+  myQuestion: any[],
+  age?: string,
+}
 export interface AppointmentParams {
-    phone: string,
-    email: string,
+    phone?: string,
+    email?: string,
     contactType: string,
-    gender: string,
-    age: string,
-    job: string,
+    gender?: string,
+    age?: string,
+    job?: string,
     requirement: string,
-    hopeContactTime: string,
-    otherRequirement: string,
+    hopeContactTime?: string,
     agentNo: string
 }
 export interface StrictQueryParams{
@@ -159,20 +155,3 @@
     new:           boolean;
 }
 
-export interface ClientInfo {
-    id: number,
-    phone: string,
-    email: string,
-    contactType: string,
-    gender: string,
-    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

--
Gitblit v1.8.0