| | |
| | | |
| | | // 快速篩選 |
| | | async fastQuery(data: FastQueryParams): Promise<Consultant[]> { |
| | | return http.post<Consultant[]>('/consultant/fastQuery', data).then(res => res.data); |
| | | try { |
| | | const response = await http.post<Consultant[]>('/consultant/fastQuery', data); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while performing fast query:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 嚴選配對 |
| | | async strictQuery(data:StrictQueryParams): Promise<AgentOfStrictQuery[]>{ |
| | | return http.post('/consultant/strictQuery', data).then((res) => res.data); |
| | | async strictQuery(data: StrictQueryParams): Promise<AgentOfStrictQuery[]> { |
| | | try { |
| | | const response = await http.post('/consultant/strictQuery', data); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while performing strict query:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 加入顧問 |
| | | async addFavoriteConsultant(agentNoList: string[]) { |
| | | return http.post('/consultant/favorite', { agentNoList }); |
| | | async addFavoriteConsultant(addFavoriteConsultantList: AddFavoriteConsultantItem[]) { |
| | | const payload = { |
| | | consultantList: addFavoriteConsultantList |
| | | }; |
| | | return http.post('/consultant/favorite', payload); |
| | | } |
| | | |
| | | // 預約前詢問 |
| | | async appointmentDemand(data: AppointmentParams) { |
| | | return http.post('/appointment/customer/create', data); |
| | | /** |
| | | * 預約需求 |
| | | * @param data 包含預約需求相關資訊的物件 |
| | | * @returns 回傳預約需求結果 |
| | | */ |
| | | async appointmentDemand(data: AppointmentParams) { |
| | | try { |
| | | // 弱掃Test4: 改為 promise.then 寫法 |
| | | return http.post('/appointment/customer/create', data).then((res) => { |
| | | if (res) { |
| | | return res['data']; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | }) |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | console.error('An error occurred while creating appointment demand:', error); |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | export default new QueryConsultantService(); |
| | | |
| | | export interface AddFavoriteConsultantItem { |
| | | agentNo : string; |
| | | createdTime: string; |
| | | } |