保誠-保戶業務員媒合平台
劉鈞霖
2021-11-30 8925275188dd075d96f5cc24c0a9eefffc88824e
PAMapp/pages/consultantLogin/index.vue
@@ -57,9 +57,10 @@
<script lang="ts">
  import { Vue, Component , namespace } from 'nuxt-property-decorator';
  import { AxiosError } from 'axios';
  import { getImgOfVerification, logInToConsultant, getVerificationStatus } from '~/assets/ts/api/consultant';
  import { Role } from '~/assets/ts/models/enum/Role';
  import { MessageBox } from 'element-ui';
  import ErrorMessageBox from '~/assets/ts/errorService';
  const roleStorage = namespace('localStorage');
  @Component({
@@ -107,12 +108,17 @@
    }
    public sendInfo():void{
      this.isAlreadyDone ? this.verify() : this.showErrorMessageBox('請確認帳號、密碼以及驗證碼是否填寫完畢');
      this.isAlreadyDone ? this.verify() : ErrorMessageBox('請確認帳號、密碼以及驗證碼是否填寫完畢');
    }
    private verify():void{
      getVerificationStatus(this.verificationCode).then( verifySuccess => {
        verifySuccess.data ? this.loginWithConsultant() : this.showErrorMessageBox('驗證碼輸入錯誤');
        if(verifySuccess.data){
          this.loginWithConsultant()
        }else{
          this.clearValue();
          ErrorMessageBox('驗證碼輸入錯誤');
        }
      });
    }
@@ -122,21 +128,21 @@
        this.storageRole(Role.ADMIN);
        this.storeUserName();
        this.$router.push('/myAppointmentList/appointmentList');
      }, (error) => {
          this.clearValue();
      }).catch((error:AxiosError)=>{
        this.checkHttpErrorStatus(error);
      });
    }
    private showErrorMessageBox(errorMsg:string):void{
    private checkHttpErrorStatus(error:any):void{
      this.clearValue();
      MessageBox({
        message: errorMsg,
        showClose:false,
        showConfirmButton:true,
        confirmButtonText:'確認',
        customClass:'pam-message-box',
        closeOnClickModal:false,
      });
      switch (error.response.status) {
        case 401:
          const errorMsg = error.response.data.detail;
          ErrorMessageBox(errorMsg);
          break;
        default:
          ErrorMessageBox();
          break;
      }
    }
    private storeUserName(): void {
@@ -144,6 +150,7 @@
    };
    private clearValue():void{
      if (!this.isRememberUserName) this.consultantDto.username='';
      this.consultantDto.password = '';
      this.verificationCode = '';
    }