PAMapp/components/Consultant/ConsultantList.vue | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
PAMapp/pages/questionnaire/_agentNo.vue | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
PAMapp/shared/services/auth.service.ts | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
PAMapp/shared/services/login.service.ts | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 |
PAMapp/components/Consultant/ConsultantList.vue
@@ -23,16 +23,20 @@ </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)=> @@ -46,6 +50,12 @@ : 'æ¨ç®åç¡å·²é¸é¡§å'; } ////////////////////////////////////////////////////////////////////// mounted() { this.isUserLogin = authService.isUserLogin(); } } </script> 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) { PAMapp/shared/services/auth.service.ts
¤ñ¹ï·sÀÉ®× @@ -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(); 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 { /** 顧客ç»å ¥-ç¼éOTP **/ sendOtp(loginInfo: LoginRequest):Promise<OtpInfo> { async sendOtp(loginInfo: LoginRequest):Promise<OtpInfo> { return http.post('/otp/sendOtp', loginInfo).then( res => res.data ); } /** 顧客ç»å ¥-é©èOTP **/ 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(