From 544f91e63a01f37e7b79db99609eec99b1afafd9 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期一, 13 十二月 2021 11:07:31 +0800
Subject: [PATCH] fixed: 使用 isUserLogin / isAdminLogin 判斷顧問/客戶是否登入

---
 PAMapp/pages/questionnaire/_agentNo.vue |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue
index 402e190..1ed02c8 100644
--- a/PAMapp/pages/questionnaire/_agentNo.vue
+++ b/PAMapp/pages/questionnaire/_agentNo.vue
@@ -1,5 +1,5 @@
 <template>
-  <div class="ques-page--reset" v-if="isLogin">
+  <div class="ques-page--reset" v-if="isUserLogin">
     <div class="ques-header">
         <div class="ques-header__mob-banner"></div>
         <div
@@ -150,7 +150,7 @@
   export default class Questionnaire extends Vue {
     @State('myConsultantList') myConsultantList!: Consultant[];
     @Action storeConsultantList!: () => Promise<number>;
-    @roleStorage.Getter currentRole!:string;
+    @roleStorage.Getter isUserLogin!:boolean;
 
     genderOptions=[
       {
@@ -272,19 +272,20 @@
 
     beforeRouteEnter(to: any, from: any, next: any) {
       next(vm => {
-        if (from.name === 'login' && !vm.isLogin) {
+        const isUserLogin = vm.$store.getters['localStorage/isUserLogin'];
+        if (from.name === 'login' && !isUserLogin) {
           vm.$router.go(-1);
           return;
         }
 
-        if (!vm.isLogin) {
+        if (!isUserLogin) {
           vm.$router.push('/login');
         }
       })
     }
 
     async fetch() {
-      if (this.isLogin) {
+      if (this.isUserLogin) {
         await this.storeConsultantList();
       };
     }
@@ -334,10 +335,6 @@
            return _.includes(this.myRequest.contactType,ContactType.PHONE)
       ? !this.isHopeContactTimeDone()
       : !this.phoneValid;
-    }
-
-    get isLogin() {
-      return this.currentRole === Role.USER;
     }
 
     private isHopeContactTimeDone():boolean{
@@ -450,7 +447,7 @@
     }
 
     @Watch('myConsultantList') onMyConsultantListChange() {
-      if (this.isLogin && this.myConsultantList.length > 0) {
+      if (this.isUserLogin && this.myConsultantList.length > 0) {
           const editAppointment = this.getLatestReserved(this.$route.params.agentNo);
 
           if (editAppointment.agentNo) {

--
Gitblit v1.8.0