保誠-保戶業務員媒合平台
Mila
2021-11-10 7c291a812e980917bc9f64a3f251f2a08ae7f157
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import axios from 'axios';
import { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
import { MessageBox } from 'element-ui';
import Router from 'vue-router';
 
export const service = axios.create({
    baseURL: 'http://localhost:8080/api',
    headers: {
        Authorization: 'Bearer ' + localStorage.getItem('id_token')
    }
})
 
service.interceptors.request.use(function (config: AxiosRequestConfig) {
    window.$nuxt.$loading.start();
    return config;
}, function (error: AxiosError) {
    return Promise.reject(error);
});
 
service.interceptors.response.use(function (response: AxiosResponse) {
    window.$nuxt.$loading.finish();
    return response;
}, function (error: AxiosError) {
    console.log(error.request.status)
    const errorCode = error.request.status;
    if (errorCode === 401) {
        window.$nuxt.$router.push('/login');
    } else {
        // MessageBox.alert(error.request.statusText, errorCode, {
        //     confirmButtonText: '確定' });
    }
 
    window.$nuxt.$loading.finish();
    return Promise.reject(error);
});
 
// 顧客登入(TODO: OTP認證開發前 暫時使用)
export function login(user: any) {
    return service.post('/authenticate', user)
}
 
// 推薦保險顧問
export function recommend() {
    return service.get('/consultant/recommend')
}
 
// 我的顧問清單
export function getFavoriteConsultant() {
    return service.get('/consultant/favorite');
}
 
// 快速篩選
export function fastQuery(data: FastQueryParams) {
    return service.post('/consultant/fastQuery', data)
}
 
// 加入顧問
export function addFavoriteConsultant(agentNoList: string[]) {
    return service.post('/consultant/favorite', agentNoList)
}
 
export interface Consultants {
    agentNo: number,
    name: string,
    img: string,
    new: boolean,
    avgScore: number,
    expertise: string[],
    updateTime: Date,
    seniority: string,
    contactStatus?: string;
}
 
export interface FastQueryParams {
    gender: string,
    communicationStyles: string[],
    avgScore: number,
    status: string
}