From 6fa4bba623713c396432ba8b863846883d6a1906 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期三, 26 一月 2022 10:52:23 +0800
Subject: [PATCH] Merge branch 'pollex-dev' into sit

---
 PAMapp/pages/consultantLogin/index.vue |   58 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/PAMapp/pages/consultantLogin/index.vue b/PAMapp/pages/consultantLogin/index.vue
index 8b61609..dcebb79 100644
--- a/PAMapp/pages/consultantLogin/index.vue
+++ b/PAMapp/pages/consultantLogin/index.vue
@@ -61,36 +61,54 @@
   import { Role } from '~/shared/models/enum/Role';
   import messageBoxService from '~/shared/services/message-box.service';
   import loginService from '~/shared/services/login.service'
+import { AgentInfo } from '~/shared/models/agent-info.model';
 
+  const loginStore  = namespace('login.store');
   const roleStorage = namespace('localStorage');
+
   @Component({
     layout: 'home'
   })
   export default class ConsultantLogin extends Vue {
-    @roleStorage.Mutation storageIdToken!: (token: string) => void;
-    @roleStorage.Mutation storageRole!: (role: string) => void;
-    @roleStorage.Mutation storageConsultantId!:(id:string) => void;
+    @roleStorage.Mutation
+    storageIdToken!: (token: string) => void;
+
+    @roleStorage.Mutation
+    storageRole!: (role: string) => void;
+
+    @roleStorage.Mutation
+    storageConsultantId!:(id:string) => void;
+
+    @loginStore.Action
+    getLoginConsultantDetail!: (agentNo: string) => Promise<AgentInfo>;
+
+    consultantDto = {
+      password: '',
+      username: '',
+    };
+    imgSrc = '';
     isRememberUserName = false;
     isShowPassword = false;
-    imgSrc = '';
     verificationCode='';
-    consultantDto = {
-      username: '',
-      password: '',
-    }
 
     ////////////////////////////////////////////////////////////////////
+
     mounted() {
       this.getInitUserName();
       this.regenerateImgOfVerification();
     };
 
-    get isAlreadyDone():boolean{
-      return !!(this.verificationCode && this.consultantDto.username && this.consultantDto.password);
+    private getInitUserName(): void {
+      const username = localStorage.getItem('consultantUserName')
+      if (username) {
+        this.consultantDto.username = username;
+        this.isRememberUserName = true;
+      }
     }
 
-
     ////////////////////////////////////////////////////////////////////
+
+
     public regenerateImgOfVerification(): void {
       loginService.getImgOfVerification().then( imgOfBase64 =>
         this.imgSrc = imgOfBase64
@@ -103,23 +121,22 @@
     }
 
     public sendInfo():void{
-      this.isAlreadyDone ? this.verify() : messageBoxService.showErrorMessage('隢Ⅱ隤董����Ⅳ隞亙���Ⅳ��憛怠神摰');
+      this.isAlreadyDone
+        ? this.verify()
+        : messageBoxService.showErrorMessage('隢Ⅱ隤董����Ⅳ隞亙���Ⅳ��憛怠神摰');
+    }
+
+    get isAlreadyDone():boolean{
+      return !!(this.verificationCode && this.consultantDto.username && this.consultantDto.password);
     }
 
 
     ////////////////////////////////////////////////////////////////////
-    private getInitUserName(): void {
-      const username = localStorage.getItem('consultantUserName')
-      if (username) {
-        this.consultantDto.username = username;
-        this.isRememberUserName = true;
-      }
-    }
 
     private verify():void{
       loginService.getVerificationStatus(this.verificationCode).then( verifySuccess => {
         if(verifySuccess.data){
-          this.loginWithConsultant()
+          this.loginWithConsultant();
         }else{
           this.clearValue();
           this.regenerateImgOfVerification();
@@ -130,6 +147,7 @@
 
     private loginWithConsultant(): void {
       loginService.logInToConsultant(this.consultantDto).then(res => {
+        this.getLoginConsultantDetail(this.consultantDto.username);
         this.storageIdToken(res.data.id_token);
         this.storageRole(Role.ADMIN);
         this.storageConsultantId(this.consultantDto.username)

--
Gitblit v1.8.0