refactor: separate api/consultant.ts into serveral services
刪除6個檔案
修改14個檔案
新增4個檔案
修改1個檔案名稱
| | |
| | | import { Vue, Component, Prop, Action, namespace } from 'nuxt-property-decorator'; |
| | | |
| | | import appointmentService from '~/shared/services/appointment.service'; |
| | | import reviewsService from '~/shared/services/reviews.service'; |
| | | import { isMobileDevice } from '~/shared/device'; |
| | | import { hideReviews } from '~/shared/const/hide-reviews'; |
| | | import { UserReviewsConsultantsParams, userReviewsConsultants } from '~/shared/api/consultant'; |
| | | import { Consultant, ConsultantWithAppointmentId } from '~/shared/models/consultant.model'; |
| | | import { Appointment } from '~/shared/models/appointment.model'; |
| | | import { UserReviewsConsultantsParams } from '~/shared/models/reviews.model'; |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | @Component({ |
| | |
| | | } |
| | | this.appointmentDetail.satisfactionScore = this.inputScore; |
| | | |
| | | userReviewsConsultants(reviewParams).then((res) => { |
| | | reviewsService.userReviewsConsultants(reviewParams).then((res) => { |
| | | this.reviewsBtn = false; |
| | | this.storeConsultantList(); |
| | | }); |
| | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Watch, Emit } from 'nuxt-property-decorator'; |
| | | import { hideReviews } from '~/shared/const/hide-reviews'; |
| | | import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quickFilter.model'; |
| | | import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model'; |
| | | @Component |
| | | export default class QuickFilterDrawer extends Vue { |
| | | pickedItem: FastQueryParams = { |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue,Component } from 'vue-property-decorator' |
| | | import { getUserAccountSetting, updateAccountSetting } from '~/shared/api/consultant'; |
| | | import { UserSetting } from '~/shared/models/account.model'; |
| | | |
| | | import accountSettingService from '~/shared/services/account-setting.service'; |
| | | |
| | | @Component |
| | | export default class AccountSetting extends Vue { |
| | |
| | | phone: this.phoneValue, |
| | | email: this.emailValue |
| | | } |
| | | updateAccountSetting(editSettingInfo).then((res: any) => { |
| | | accountSettingService.updateAccountSetting(editSettingInfo).then((res: any) => { |
| | | console.log('updateRes:', res); |
| | | this.resetSettingForm(); |
| | | }); |
| | |
| | | } |
| | | |
| | | mounted(){ |
| | | getUserAccountSetting().then((userInfo: UserSetting)=>{ |
| | | accountSettingService.getUserAccountSetting().then((userInfo: UserSetting)=>{ |
| | | this._userSetting = { |
| | | name: userInfo.name || '', |
| | | phone: userInfo.phone || '', |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; |
| | | import { addFavoriteConsultant, appointmentDemand, AppointmentParams, AppointmentRequests ,editAppointment } from '~/shared/api/consultant'; |
| | | import { getRequestQuestionFromStorage, getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests'; |
| | | import { getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests'; |
| | | import _ from 'lodash'; |
| | | |
| | | import queryConsultantService from '~/shared/services/query-consultant.service'; |
| | | import appointmentService from '~/shared/services/appointment.service'; |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | import { ContactType } from '~/shared/models/enum/ContactType'; |
| | | import { Gender } from '~/shared/models/enum/Gender'; |
| | | import { RegisterInfo } from '~/shared/models/registerInfo'; |
| | | import { AppointmentParams, AppointmentRequests } from '~/shared/models/appointment.model'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | | @Component |
| | |
| | | if (this.isEditBtn) { |
| | | this.sentEditAppointmentDemand(); |
| | | } else { |
| | | addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand()); |
| | | queryConsultantService.addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand()); |
| | | } |
| | | |
| | | } |
| | |
| | | agentNo: this.$route.params.agentNo |
| | | }; |
| | | |
| | | appointmentDemand(data).then(res => { |
| | | queryConsultantService.appointmentDemand(data).then(res => { |
| | | this.sendReserve = true; |
| | | this.myRequest.hopeContactTime = []; |
| | | setRequestsToStorage(this.myRequest); |
| | |
| | | id: this.appointmentId, |
| | | otherRequirement: null |
| | | } |
| | | editAppointment(info).then(res => { |
| | | appointmentService.editAppointment(info).then(res => { |
| | | this.sendReserve = true; |
| | | this.myRequest.hopeContactTime = []; |
| | | setRequestsToStorage(this.myRequest); |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, namespace } from 'nuxt-property-decorator'; |
| | | |
| | | import queryConsultantService from '~/shared/services/query-consultant.service'; |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | import { fastQuery } from '~/shared/api/consultant'; |
| | | import { questionList } from '~/shared/const/quickFilter-questionList'; |
| | | import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quickFilter.model'; |
| | | import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model'; |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | @Component |
| | |
| | | status: '' |
| | | } |
| | | |
| | | fastQuery(data).then((consultantList) => { |
| | | queryConsultantService.fastQuery(data).then((consultantList) => { |
| | | this.consultantList = consultantList; |
| | | this.storageQuickFilter(JSON.stringify(this.confirmItem)) |
| | | }) |
| | |
| | | </template> |
| | | <script lang="ts"> |
| | | import {Vue,Component, State, namespace, Action} from 'nuxt-property-decorator'; |
| | | import { AgentOfStrictQuery } from '~/shared/api/consultant'; |
| | | import { hideReviews } from '~/shared/const/hide-reviews'; |
| | | import { AgentOfStrictQuery } from '~/shared/models/strict-query.model'; |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | |
| | |
| | | import { QuestionOption } from "../models/quickFilter.model"; |
| | | import { QuestionOption } from "~/shared/models/quick-filter.model"; |
| | | |
| | | export const questionList: QuestionOption[] = [ |
| | | { |
| | |
| | | customerId : number; |
| | | name : string; |
| | | } |
| | | |
| | | export interface AppointmentParams { |
| | | phone : string; |
| | | email : string; |
| | | contactType : string; |
| | | gender : string; |
| | | age : string; |
| | | job : string; |
| | | requirement : string; |
| | | hopeContactTime: string; |
| | | agentNo : string; |
| | | } |
| | | export interface EditAppointmentParams { |
| | | id : number, |
| | | phone : string, |
| | | email : string, |
| | | contactType : string, |
| | | gender : string, |
| | | age : string, |
| | | job : string, |
| | | requirement : string, |
| | | hopeContactTime : string, |
| | | otherRequirement: null |
| | | } |
| | | export interface AppointmentRequests { |
| | | phone : string, |
| | | email : string, |
| | | contactType : string, |
| | | gender : string, |
| | | age : string, |
| | | job : string, |
| | | requirement : string[], |
| | | hopeContactTime: ContactTime[], |
| | | agentNo : string, |
| | | } |
| | | export interface ContactTime { |
| | | selectWeekOptions : string[], |
| | | selectTimesOptions: string[] |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | export interface UserReviewsConsultantsParams{ |
| | | appointmentId: number, |
| | | score : number, |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | |
| | | 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; |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | import { http } from "./httpClient"; |
| | | |
| | | import { UserSetting } from "~/shared/models/account.model"; |
| | | |
| | | class AccountSettingService{ |
| | | |
| | | //åå¾ä½¿ç¨è
帳èè³è¨ |
| | | async getUserAccountSetting() : Promise<UserSetting> { |
| | | return http.get<UserSetting>('/customer/info').then(res => res.data); |
| | | } |
| | | //æ´æ°ä½¿ç¨è
帳èè³è¨ |
| | | async updateAccountSetting(params: any) : Promise<any> { |
| | | return http.put('/customer/info', params ).then(res => res.data); |
| | | } |
| | | |
| | | } |
| | | export default new AccountSettingService(); |
| | |
| | | import { http } from "./httpClient"; |
| | | |
| | | import { ClientInfo } from "../models/client.model"; |
| | | import { AppointmentDetail } from "../models/appointment.model"; |
| | | import { ClientInfo } from "~/shared/models/client.model"; |
| | | import { AppointmentDetail, EditAppointmentParams } from "~/shared/models/appointment.model"; |
| | | |
| | | class AppointmentService { |
| | | |
| | |
| | | return http.delete(`/appointment/${appointmentId}`); |
| | | } |
| | | |
| | | // 編輯é ç´ |
| | | editAppointment(editAppointmentParams: EditAppointmentParams) { |
| | | return http.put('/appointment', editAppointmentParams); |
| | | } |
| | | |
| | | } |
| | | |
| | | export default new AppointmentService(); |
| | |
| | | return http.get('/consultant/detail', {params:{agentNo:agentNo}}).then((res) => res.data); |
| | | } |
| | | |
| | | // ç§»é¤é¡§å |
| | | async deleteConsultant(agentId: string) { |
| | | return http.delete(`/consultant/favorite/${agentId}`); |
| | | } |
| | | |
| | | } |
| | | |
| | | export default new MyConsultantService(); |
| | |
| | | import { http } from "./httpClient"; |
| | | |
| | | import { Consultant } from "../models/consultant.model"; |
| | | import { Consultant } from "~/shared/models/consultant.model"; |
| | | import { FastQueryParams } from "~/shared/models/quick-filter.model"; |
| | | import { AgentOfStrictQuery, StrictQueryParams } from "~/shared/models/strict-query.model"; |
| | | import { AppointmentParams } from "~/shared/models/appointment.model"; |
| | | |
| | | class QueryConsultantService { |
| | | |
| | |
| | | return http.get<Consultant[]>('/consultant/recommend').then((res) => res.data); |
| | | } |
| | | |
| | | // å¿«éç¯©é¸ |
| | | async fastQuery(data: FastQueryParams): Promise<Consultant[]> { |
| | | return http.post<Consultant[]>('/consultant/fastQuery', data).then(res => res.data); |
| | | } |
| | | |
| | | // å´é¸é
å° |
| | | async strictQuery(data:StrictQueryParams): Promise<AgentOfStrictQuery[]>{ |
| | | return http.post('/consultant/strictQuery', data).then((res) => res.data); |
| | | } |
| | | |
| | | // å å
¥é¡§å |
| | | async addFavoriteConsultant(agentNoList: string[]) { |
| | | return http.post('/consultant/favorite', { agentNoList }); |
| | | } |
| | | |
| | | // é ç´åè©¢å |
| | | async appointmentDemand(data: AppointmentParams) { |
| | | return http.post('/appointment/customer/create', data); |
| | | } |
| | | |
| | | } |
| | | |
| | | export default new QueryConsultantService(); |
¤ñ¹ï·sÀÉ®× |
| | |
| | | import { http } from "./httpClient"; |
| | | |
| | | import { UserReviewsConsultantsParams } from "../models/reviews.model"; |
| | | |
| | | class ReviewsService { |
| | | |
| | | //客æ¶é²è¡æ»¿æåº¦è©å |
| | | userReviewsConsultants(data: UserReviewsConsultantsParams) { |
| | | return http.post('/satisfaction/create', data ); |
| | | } |
| | | } |
| | | |
| | | export default new ReviewsService(); |
| | |
| | | import { AppointmentRequests } from "./api/consultant"; |
| | | import { AppointmentRequests } from "./models/appointment.model"; |
| | | |
| | | export function getRequestsFromStorage(): AppointmentRequests { |
| | | const requests = localStorage.getItem('myRequests'); |
| | |
| | | import { StrictQueryParams } from '~/shared/models/strict-query.model'; |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | |
| | | import { getMyReviewLog } from '~/shared/api/appointment'; |
| | | import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/shared/api/consultant'; |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/shared/storageConsultant'; |
| | | |
| | | import myConsultantService from '~/shared/services/my-consultant.service'; |
| | | import queryConsultantService from '~/shared/services/query-consultant.service'; |
| | | import appointmentService from '~/shared/services/appointment.service'; |
| | | |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | import { AppointmentLog } from '~/shared/models/appointment.model'; |
| | | import { ClientInfo } from '~/shared/models/client.model'; |
| | | import { AgentOfStrictQuery } from '~/shared/models/strict-query.model'; |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | | recommendList: Consultant[] = []; |
| | |
| | | |
| | | @Action |
| | | storeRecommendList() { |
| | | recommend().then(data => { |
| | | queryConsultantService.getRecommendConsultantList().then(data => { |
| | | this.context.commit('updateRecommend', data) |
| | | }) |
| | | } |
| | |
| | | |
| | | if (localData?.length) { |
| | | const agentNoList = localData.map(i => i.agentNo) |
| | | await addFavoriteConsultant(agentNoList).then(res => { |
| | | await queryConsultantService.addFavoriteConsultant(agentNoList).then(res => { |
| | | localStorage.removeItem('favoriteConsultant') |
| | | }) |
| | | } |
| | |
| | | if (!this.isUserLogin) { |
| | | setFavoriteToStorage(left); |
| | | } else { |
| | | await deleteConsultant(agentNo) |
| | | await myConsultantService.deleteConsultant(agentNo) |
| | | } |
| | | |
| | | this.context.commit('updateConsultantList', left) |
| | |
| | | if (!found) { |
| | | const newData = [consultantToAdd].concat(this.myConsultantList); |
| | | if (this.isUserLogin) { |
| | | await addFavoriteConsultant([consultantToAdd.agentNo]) |
| | | await queryConsultantService.addFavoriteConsultant([consultantToAdd.agentNo]) |
| | | } else { |
| | | setFavoriteToStorage(newData); |
| | | } |
| | |
| | | } |
| | | |
| | | @Action |
| | | async storeStrictQueryList(strictQueryDto) { |
| | | return await strictQuery(strictQueryDto).then(res=>{ |
| | | async storeStrictQueryList(strictQueryDto: StrictQueryParams) { |
| | | return await queryConsultantService.strictQuery(strictQueryDto).then(res=>{ |
| | | this.context.commit('localStorage/storageRecommendConsultant', JSON.stringify(strictQueryDto)); |
| | | this.context.commit('updateStrictQueryList', res.data) |
| | | return res.data.length; |
| | | this.context.commit('updateStrictQueryList', res) |
| | | return res.length; |
| | | }); |
| | | } |
| | | |
| | |
| | | import { Module, Mutation, VuexModule ,Action } from 'vuex-module-decorators'; |
| | | import { Role } from '~/shared/models/enum/role'; |
| | | import { Selected } from '~/shared/models/quickFilter.model'; |
| | | import { Selected } from '~/shared/models/quick-filter.model'; |
| | | @Module |
| | | export default class LocalStorage extends VuexModule { |
| | | id_token = localStorage.getItem('id_token'); |