update 使用 currentRole 判斷目前是否為顧問/客戶登入狀態
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { namespace, Watch } from 'nuxt-property-decorator'; |
| | | import { namespace } from 'nuxt-property-decorator'; |
| | | import { Vue, Component,} from 'vue-property-decorator'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | import * as _ from 'lodash'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | | @Component |
| | |
| | | } |
| | | |
| | | set label(value) { |
| | | this.questionnaireState = value === 'é²è¡é ç´' ? isLogin() : true; |
| | | this.questionnaireState = value === 'é²è¡é ç´' ? this.currentRole === Role.USER : true; |
| | | } |
| | | } |
| | | </script> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Action } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, Prop, Action, namespace } from 'nuxt-property-decorator'; |
| | | import { getAppointmentDetail, UserReviewsConsultantsParams, userReviewsConsultants, cancelAppointment } from '~/assets/ts/api/consultant'; |
| | | import { Consultant, Appointment } from '~/assets/ts/models/consultant.model'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { isMobileDevice } from '~/assets/ts/device'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | | @Component({ |
| | | filters: { |
| | | formatNumber(index: number) { |
| | |
| | | @Action removeFromMyConsultantList!: (agentNo: string) => Promise<boolean>; |
| | | @Action storeConsultantList!: any; |
| | | @Prop() agentInfo!: Consultant; |
| | | @roleStorage.Getter currentRole!:string; |
| | | |
| | | isVisibleDialog = false; |
| | | reviewsBtn = false; |
| | | status = false; |
| | |
| | | reserveCommunication() { |
| | | const contactStatus = this.agentInfo.contactStatus; |
| | | if (!contactStatus || contactStatus === 'picked') { |
| | | isLogin() |
| | | this.currentRole === Role.USER |
| | | ? this.$router.push(`/questionnaire/${this.agentInfo.agentNo}`) |
| | | : this.$router.push('/login'); |
| | | } else { |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, Prop, namespace } from 'nuxt-property-decorator'; |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | | |
| | | @Component |
| | | export default class ConsultantList extends Vue { |
| | | @Prop() agents!: Consultant[]; |
| | | @roleStorage.Getter currentRole!:string; |
| | | |
| | | get isLogin() { |
| | | return isLogin(); |
| | | return this.currentRole === Role.USER; |
| | | } |
| | | get agentList(){ |
| | | return this.agents.map((agentDto)=> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Prop, Getter } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, Prop } from 'nuxt-property-decorator'; |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | |
| | | |
| | | @Component |
| | | export default class ConsultantPage extends Vue { |
| | | @Prop() consultantList!: Consultant[]; |
| | | @Getter isLogin!: boolean; |
| | | pageList: Consultant[] = []; |
| | | |
| | | changePage(pageList: Consultant[]) { |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, State, Action, Watch } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; |
| | | import { addFavoriteConsultant, appointmentDemand, AppointmentParams, AppointmentRequests ,editAppointment,RegisterInfo } from '~/assets/ts/api/consultant'; |
| | | import { getRequestQuestionFromStorage, getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/assets/ts/storageRequests'; |
| | | import _ from 'lodash'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | import { ContactType } from '~/assets/ts/models/enum/ContactType'; |
| | | import { Gender } from '~/assets/ts/models/enum/Gender'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | | @Component |
| | | export default class Questionnaire extends Vue { |
| | | @State('myConsultantList') myConsultantList!: Consultant[]; |
| | | @Action storeConsultantList!: () => Promise<number>; |
| | | @roleStorage.Getter currentRole!:string; |
| | | |
| | | genderOptions=[ |
| | | { |
| | |
| | | |
| | | beforeRouteEnter(to: any, from: any, next: any) { |
| | | next(vm => { |
| | | if (from.name === 'login' && !isLogin()) { |
| | | if (from.name === 'login' && !vm.isLogin) { |
| | | vm.$router.go(-1); |
| | | return; |
| | | } |
| | | |
| | | if (!isLogin()) { |
| | | if (!vm.isLogin) { |
| | | vm.$router.push('/login'); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | async fetch() { |
| | | if (isLogin()) { |
| | | if (this.isLogin) { |
| | | await this.storeConsultantList(); |
| | | }; |
| | | } |
| | |
| | | } |
| | | |
| | | get isLogin() { |
| | | return isLogin(); |
| | | return this.currentRole === Role.USER; |
| | | } |
| | | |
| | | private isHopeContactTimeDone():boolean{ |
| | |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | import { ClientInfo, getMyAppointmentList, getMyReviewLog, allAppointmentsView } from '~/assets/ts/api/appointment'; |
| | | // import * as consultant from '~/assets/ts/api/consultant'; |
| | | import { ClientInfo, getMyAppointmentList, getMyReviewLog } from '~/assets/ts/api/appointment'; |
| | | import { recommend, AgentOfStrictQuery, getFavoriteConsultant, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/assets/ts/api/consultant'; |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { AppointmentLog } from '~/assets/ts/models/appointment.model'; |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | |
| | | @Action |
| | | async storeConsultantList() { |
| | | const localData = getFavoriteFromStorage(); |
| | | if (!isLogin()) { |
| | | if (this.context.getters['localStorage/currentRole'] !== Role.USER) { |
| | | this.context.commit('updateConsultantList', localData) |
| | | return; |
| | | }; |
| | |
| | | // no agent was removed |
| | | if (left.length === this.myConsultantList.length) return false; |
| | | |
| | | if (!isLogin()) { |
| | | if (this.context.getters['localStorage/currentRole'] !== Role.USER) { |
| | | setFavoriteToStorage(left); |
| | | } else { |
| | | await deleteConsultant(agentNo) |
| | |
| | | if (!found) { |
| | | const newData = [consultantToAdd].concat(this.myConsultantList); |
| | | |
| | | if (isLogin()) { |
| | | if (this.context.getters['localStorage/currentRole'] === Role.USER) { |
| | | await addFavoriteConsultant([consultantToAdd.agentNo]) |
| | | } else { |
| | | setFavoriteToStorage(newData); |