保誠-保戶業務員媒合平台
Benson
2021-12-30 0d13a8e22cfd29bcb4360f2f5d6ed0c2e38e1052
PAMapp/shared/services/my-consultant.service.ts
@@ -1,8 +1,7 @@
import { http } from "./httpClient";
import { AgentInfo } from '~/shared/models/agent-info.model';
import { Consultant } from "../models/consultant.model";
import _ from "lodash";
class MyConsultantService {
  async getFavoriteConsultantList(): Promise<Consultant[]> {
@@ -24,6 +23,31 @@
    return http.get('/consultant/detail', {params:{agentNo:agentNo}}).then((res) => res.data);
  }
  // 移除顧問
  async deleteConsultant(agentId: string) {
    return http.delete(`/consultant/favorite/${agentId}`);
  }
  // 標記為已聯絡
  markAsContact(appointmentId: number): Promise<void> {
    // TODO: 跟後端確認,這裡的 API 不應該傳回 void, 而是應該是更新後的資料 - Ben 2021/11/16
    // return http.post('/appointment/markAsContacted/'+appointmentId, undefined, {headers})
    //         .then(res => res.data)
    return http.post(`/appointment/markAsContacted/${appointmentId}`);
  }
  // 取得顧問頭像
  getConsultantAvatar(agentNo:string):Promise<string>{
    return http.get(`/consultant/avatar/${agentNo}`,{ responseType : 'arraybuffer' })
      .then( response => {
        const toBase64 = window.btoa(
                          _.reduce( new Uint8Array(response.data),(data,byte) =>
                            data + String.fromCharCode(byte),'')
                        );
        const imgSrc = `data:image/png;base64,${toBase64}`;
        return imgSrc;
    });
  }
}
export default new MyConsultantService();