| | |
| | | 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({ |
| | |
| | | }) |
| | | |
| | | 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.post('/consultant/favorite', {agentNoList}) |
| | | } |
| | | |
| | | // 預約前詢問 |
| | | export function appointmentDemand(data: AppointmentParams) { |
| | | return service.post('/appointment/customer/create', data) |
| | | } |
| | | export interface Consultants { |
| | | agentNo: string, |
| | | name: string, |
| | |
| | | communicationStyles: string[], |
| | | avgScore: number, |
| | | status: string |
| | | } |
| | | |
| | | export interface AppointmentParams { |
| | | phone: string, |
| | | email: string, |
| | | contactType: string, |
| | | gender: string, |
| | | age: string, |
| | | job: string, |
| | | requirement: string, |
| | | hopeContactTime: string, |
| | | otherRequirement: string, |
| | | agentNo: string |
| | | } |