| | |
| | | import axios from 'axios'; |
| | | import { AxiosRequestConfig, AxiosError, AxiosResponse } 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', |
| | |
| | | }) |
| | | |
| | | 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); |
| | | }); |
| | | |
| | |
| | | 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, |
| | |
| | | updateTime: Date, |
| | | seniority: string, |
| | | contactStatus?: string; |
| | | } |
| | | |
| | | export interface FastQueryParams { |
| | | gender: string, |
| | | communicationStyles: string[], |
| | | avgScore: number, |
| | | status: string |
| | | } |