| | |
| | | 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({ |
| | | baseURL: 'http://localhost:8080/api', |
| | | headers: { |
| | | Authorization: 'Bearer ' + localStorage.getItem('id_token') |
| | | } |
| | | 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); |
| | | }); |
| | | |
| | |
| | | |
| | | // 我的顧問清單 |
| | | export function getFavoriteConsultant() { |
| | | return service.get('/consultant/favorite'); |
| | | const headers = { |
| | | Authorization: 'Bearer ' + localStorage.getItem('id_token') |
| | | } |
| | | return service.get('/consultant/favorite', {headers}); |
| | | } |
| | | |
| | | // 快速篩選 |
| | |
| | | return service.post('/consultant/fastQuery', data) |
| | | } |
| | | |
| | | // 加入顧問 |
| | | export function addFavoriteConsultant(agentNoList: string[]) { |
| | | return service.post('/consultant/favorite', agentNoList) |
| | | // 嚴選配對 |
| | | export function strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery>>{ |
| | | return service.post('/consultant/strictQuery', data) |
| | | } |
| | | |
| | | // 加入顧問 |
| | | export function addFavoriteConsultant(agentNoList: string[]) { |
| | | const headers = { |
| | | Authorization: 'Bearer ' + localStorage.getItem('id_token') |
| | | } |
| | | return service.post('/consultant/favorite', {agentNoList}, {headers}) |
| | | } |
| | | |
| | | // 預約前詢問 |
| | | export function appointmentDemand(data: AppointmentParams) { |
| | | return service.post('/appointment/customer/create', data) |
| | | } |
| | | |
| | | //顧問詳細資訊 |
| | | export function getConsultantDetail(agentNo:string){ |
| | | return service.get('/consultant/detail', {params:{agentNo:agentNo}}) |
| | | } |
| | | |
| | | // 取得所有預約清單 |
| | | export function getMyAppointmentList():Promise<AxiosResponse<ClientInfo>> { |
| | | const headers = { |
| | | Authorization: 'Bearer ' + localStorage.getItem('id_token') |
| | | } |
| | | return service.get('/consultant/getMyAppointment', {headers}); |
| | | } |
| | | export interface Consultants { |
| | | agentNo: number, |
| | | agentNo: string, |
| | | name: string, |
| | | img: string, |
| | | new: boolean, |
| | |
| | | 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 |
| | | } |
| | | export interface StrictQueryParams{ |
| | | gender: string; |
| | | avgScore: number; |
| | | status: string; //phase 1 disable |
| | | area: string; |
| | | requirements: string[]; |
| | | otherRequirement: string; |
| | | seniority: string; |
| | | popularTags: string[]; |
| | | otherPopularTags: string; |
| | | } |
| | | export interface AgentOfStrictQuery { |
| | | agentNo: string; |
| | | name: string; |
| | | img: string; |
| | | expertise: string[]; |
| | | avgScore: number; |
| | | contactStatus: null; |
| | | updateTime: null; |
| | | seniority: string; |
| | | new: boolean; |
| | | } |
| | | |
| | | export interface ClientInfo { |
| | | id: number, |
| | | phone: string, |
| | | email: string, |
| | | contactType: string, |
| | | gender: string, |
| | | age: string, |
| | | job: string, |
| | | requirement: string, |
| | | communicateStatus: string, |
| | | hopeContactTime: string, |
| | | otherRequirement: string, |
| | | appointmentDate: Date, |
| | | agentNo: string, |
| | | customerId: number, |
| | | name: string |
| | | } |