| | |
| | | import { http } from "./httpClient"; |
| | | |
| | | import { AgentInfo } from '~/shared/models/agent-info.model'; |
| | | import { Appointment } from "../models/appointment.model"; |
| | | import { Consultant } from "../models/consultant.model"; |
| | | |
| | | import { http } from "./httpClient"; |
| | | class MyConsultantService { |
| | | |
| | | async getFavoriteConsultantList(): Promise<Consultant[]> { |
| | |
| | | }); |
| | | } |
| | | |
| | | async getAllGroupByConsultant(): Promise<Consultant[]> { |
| | | return http.get<Consultant[]>('/appointment/customer/get_all_group_by_consultant').then((res) => res.data); |
| | | } |
| | | |
| | | private viewMyConsultantList(): void { |
| | | http.post('/consultant/favorite/view'); |
| | | } |
| | |
| | | return http.get('/consultant/detail', {params:{agentNo:agentNo}}).then((res) => res.data); |
| | | } |
| | | |
| | | // 移除顧問 |
| | | async deleteConsultant(agentId: string) { |
| | | return http.delete(`/consultant/favorite/${agentId}`); |
| | | } |
| | | |
| | | // 標記為已聯絡 |
| | | async markAsContact(appointmentId: number): Promise<Appointment> { |
| | | try { |
| | | const response = await http.post(`/appointment/markAsContacted/${appointmentId}`); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while marking appointment as contacted:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 取得顧問頭像 |
| | | getConsultantAvatar(agentNo:string):Promise<string>{ |
| | | return http.get(`/consultant/avatar/${agentNo}`,{ responseType : 'arraybuffer' }) |
| | | .then( response => { |
| | | const toBase64 = window.btoa( |
| | | Array.from(new Uint8Array(response.data)).reduce((data, byte) => |
| | | data + String.fromCharCode(byte), '') |
| | | ); |
| | | const imgSrc = `data:image/png;base64,${toBase64}`; |
| | | return imgSrc; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | export default new MyConsultantService(); |