From 68e499e5eed17a2b1d2e47ee1790e16f001552f7 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期三, 22 十二月 2021 16:21:28 +0800 Subject: [PATCH] Merge branch 'master' of https://192.168.0.10:8443/r/pcalife/PAM --- PAMapp/pages/userReviewsRecord/index.vue | 24 ++++++----- PAMapp/pages/questionnaire/_agentNo.vue | 9 ++-- PAMapp/shared/services/auth.service.ts | 16 ++++++++ PAMapp/shared/services/login.service.ts | 17 ++++---- PAMapp/components/Consultant/ConsultantList.vue | 28 +++++++++---- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/PAMapp/components/Consultant/ConsultantList.vue b/PAMapp/components/Consultant/ConsultantList.vue index ce11a46..45e8a0a 100644 --- a/PAMapp/components/Consultant/ConsultantList.vue +++ b/PAMapp/components/Consultant/ConsultantList.vue @@ -23,21 +23,25 @@ </template> <script lang="ts"> -import { Vue, Component, Prop, namespace } from 'nuxt-property-decorator'; -import { Consultant } from '~/shared/models/consultant.model'; +import { Vue, Component, Prop } from 'nuxt-property-decorator'; -const roleStorage = namespace('localStorage'); +import authService from '~/shared/services/auth.service'; +import { Consultant } from '~/shared/models/consultant.model'; @Component export default class ConsultantList extends Vue { - @Prop() agents!: Consultant[]; - @Prop() title! : string; - @roleStorage.Getter isUserLogin!:boolean; + @Prop() + agents!: Consultant[]; + + @Prop() + title! : string; + + isUserLogin = false; get agentList(){ - return this.agents.map((agentDto)=> - ({...agentDto,customerScore:0,}) - ) + return this.agents.map((agentDto)=> + ({...agentDto,customerScore:0,}) + ) } get noDataPlaceholder(): string { @@ -46,6 +50,12 @@ : '����撌脤憿批��'; } + ////////////////////////////////////////////////////////////////////// + + mounted() { + this.isUserLogin = authService.isUserLogin(); + } + } </script> diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue index 83f35e9..69ea619 100644 --- a/PAMapp/pages/questionnaire/_agentNo.vue +++ b/PAMapp/pages/questionnaire/_agentNo.vue @@ -143,8 +143,9 @@ 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 authService from '~/shared/services/auth.service'; +import queryConsultantService from '~/shared/services/query-consultant.service'; import { Consultant } from '~/shared/models/consultant.model'; import { ContactType } from '~/shared/models/enum/ContactType'; import { Gender } from '~/shared/models/enum/Gender'; @@ -280,7 +281,7 @@ beforeRouteEnter(to: any, from: any, next: any) { next(vm => { - const isUserLogin = vm.$store.getters['localStorage/isUserLogin']; + const isUserLogin = authService.isUserLogin(); if (from.name === 'login' && !isUserLogin) { vm.$router.go(-1); return; @@ -293,7 +294,7 @@ } async fetch() { - if (this.isUserLogin) { + if (authService.isUserLogin()) { await this.storeConsultantList(); }; } @@ -451,7 +452,7 @@ : appointmentInfo.appointmentDate; } @Watch('myConsultantList') onMyConsultantListChange() { - if (this.isUserLogin && this.myConsultantList.length > 0) { + if (authService.isUserLogin() && this.myConsultantList.length > 0) { const editAppointment = this.getLatestReserved(this.$route.params.agentNo); if (editAppointment && editAppointment.agentNo) { diff --git a/PAMapp/pages/userReviewsRecord/index.vue b/PAMapp/pages/userReviewsRecord/index.vue index 2f5471e..c6029e8 100644 --- a/PAMapp/pages/userReviewsRecord/index.vue +++ b/PAMapp/pages/userReviewsRecord/index.vue @@ -16,7 +16,7 @@ class="user-reviews-card" v-for="(appointmentLog, index) in myAppointmentReviewLogList" :key="index"> - <div class="user-reviews-card-content" v-if="currentRole === 'user'"> + <div class="user-reviews-card-content" v-if="isUserLogin"> �撠�<span class="mdTxt">{{ ` ${appointmentLog.agentName} ` }}</span>���� <UiReviewScore :score="appointmentLog.score" /> 閰嚗� </div> <div class="user-reviews-card-content" v-else> @@ -41,26 +41,28 @@ </template> <script lang="ts"> -import { Vue, Component, Action, State, namespace } from 'nuxt-property-decorator'; -import { AppointmentLog } from '~/shared/models/appointment.model'; +import { Vue, Component, Action, State } from 'nuxt-property-decorator'; -const roleStorage = namespace('localStorage'); +import authService from '~/shared/services/auth.service'; +import { AppointmentLog } from '~/shared/models/appointment.model'; @Component export default class UserReviewsRecord extends Vue{ - today = new Date(); + @State('myAppointmentReviewLogList') + myAppointmentReviewLogList!: AppointmentLog[]; - @roleStorage.Getter currentRole!:string; - - @State('myAppointmentReviewLogList') myAppointmentReviewLogList!: AppointmentLog[]; - - @Action storeMyAppointmentReviewLog!: any; + @Action + storeMyAppointmentReviewLog!: any; appointmentLogList: AppointmentLog[] = []; + isUserLogin = false; + + ////////////////////////////////////////////////////////////////////// mounted() { - this.storeMyAppointmentReviewLog(); + this.isUserLogin = authService.isUserLogin(); + this.storeMyAppointmentReviewLog(); } } diff --git a/PAMapp/shared/services/auth.service.ts b/PAMapp/shared/services/auth.service.ts new file mode 100644 index 0000000..6c10d47 --- /dev/null +++ b/PAMapp/shared/services/auth.service.ts @@ -0,0 +1,16 @@ +import { Role } from "../models/enum/role"; + +class AuthService { + private idToken = localStorage.getItem('id_token'); + private currentRole = localStorage.getItem('current_role'); + + isAdminLogin(): boolean { + return this.currentRole === Role.ADMIN; + } + + isUserLogin(): boolean { + return this.currentRole === Role.USER; + } +} + +export default new AuthService(); diff --git a/PAMapp/shared/services/login.service.ts b/PAMapp/shared/services/login.service.ts index 9797d52..26bf0f2 100644 --- a/PAMapp/shared/services/login.service.ts +++ b/PAMapp/shared/services/login.service.ts @@ -1,31 +1,32 @@ +import { http } from "./httpClient"; +import { AxiosResponse } from 'axios'; +import _ from "lodash"; + import { ConsultantLoginInfo } from "../models/ConsultantLoginInfo"; import { LoginRequest } from "../models/loginRequest.model"; import { LoginSuccessToken } from "../models/loginSuccessToken.model"; import { LoginVerify } from "../models/loginVerify.model"; import { OtpInfo } from "../models/otpInfo.model"; import { RegisterInfo } from "../models/registerInfo"; -import { http } from "./httpClient"; -import { AxiosResponse } from 'axios'; -import _ from "lodash"; class LoginService { /** 憿批恥��-��TP **/ - sendOtp(loginInfo: LoginRequest):Promise<OtpInfo> { + async sendOtp(loginInfo: LoginRequest):Promise<OtpInfo> { return http.post('/otp/sendOtp', loginInfo).then( res => res.data ); } /** 憿批恥��-撽�TP **/ - loginVerify(loginVerify: LoginVerify):Promise<LoginSuccessToken>{ + async loginVerify(loginVerify: LoginVerify):Promise<LoginSuccessToken>{ return http.post('/otp/verify', loginVerify).then(res => res.data); } /** 憿批恥閮餃�� **/ - register(registerInfo: RegisterInfo):Promise<LoginSuccessToken>{ + async register(registerInfo: RegisterInfo):Promise<LoginSuccessToken>{ return http.post('/otp/register', registerInfo).then(res => res.data); } /** �����Ⅳ���� **/ - getImgOfVerification():Promise<string>{ + async getImgOfVerification():Promise<string>{ return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' }) .then( response => { const toBase64 = window.btoa( @@ -48,4 +49,4 @@ } } -export default new LoginService(); \ No newline at end of file +export default new LoginService(); -- Gitblit v1.8.0