From abfd26bb700d93a92da6a04703b0187d4acaaeb5 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期三, 22 十二月 2021 10:13:02 +0800 Subject: [PATCH] refactor: move ts folder to shared folder --- PAMapp/pages/consultantLogin/index.vue | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/PAMapp/pages/consultantLogin/index.vue b/PAMapp/pages/consultantLogin/index.vue index 17d59a5..3a90f3f 100644 --- a/PAMapp/pages/consultantLogin/index.vue +++ b/PAMapp/pages/consultantLogin/index.vue @@ -31,8 +31,8 @@ </div> <div class="pam-paragraph"> <div class="pam-consultant-login__title"> - <div>撽�Ⅳ</div> - <div class="text--dark-blue fs-16 cursor--pointer fix-chrome-click--issue" + <div>撽�Ⅳ <span class="text--dark-blue fs-16">(����之撠神)</span></div> + <div class="text--primary fs-16 cursor--pointer fix-chrome-click--issue" @click="regenerateImgOfVerification">������</div> </div> <div class="pam-consultant-login__verifyBlock mt-10"> @@ -58,9 +58,9 @@ <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 ErrorMessageBox from '~/assets/ts/errorService'; + import { Role } from '~/shared/models/enum/role'; + import ErrorMessageBox from '~/shared/errorService'; + import loginService from '~/shared/services/login.service' const roleStorage = namespace('localStorage'); @Component({ @@ -79,25 +79,20 @@ password: '', } - get isAlreadyDone():boolean{ - return !!(this.verificationCode && this.consultantDto.username && this.consultantDto.password); - } - + //////////////////////////////////////////////////////////////////// mounted() { this.getInitUserName(); this.regenerateImgOfVerification(); }; - private getInitUserName(): void { - const username = localStorage.getItem('consultantUserName') - if (username) { - this.consultantDto.username = username; - this.isRememberUserName = true; - } + get isAlreadyDone():boolean{ + return !!(this.verificationCode && this.consultantDto.username && this.consultantDto.password); } + + //////////////////////////////////////////////////////////////////// public regenerateImgOfVerification(): void { - getImgOfVerification().then( imgOfBase64 => + loginService.getImgOfVerification().then( imgOfBase64 => this.imgSrc = imgOfBase64 ); }; @@ -111,19 +106,30 @@ this.isAlreadyDone ? this.verify() : ErrorMessageBox('隢Ⅱ隤董����Ⅳ隞亙���Ⅳ��憛怠神摰'); } + + //////////////////////////////////////////////////////////////////// + private getInitUserName(): void { + const username = localStorage.getItem('consultantUserName') + if (username) { + this.consultantDto.username = username; + this.isRememberUserName = true; + } + } + private verify():void{ - getVerificationStatus(this.verificationCode).then( verifySuccess => { + loginService.getVerificationStatus(this.verificationCode).then( verifySuccess => { if(verifySuccess.data){ this.loginWithConsultant() }else{ this.clearValue(); + this.regenerateImgOfVerification(); ErrorMessageBox('撽�Ⅳ頛詨�隤�'); } }); } private loginWithConsultant(): void { - logInToConsultant(this.consultantDto).then(res => { + loginService.logInToConsultant(this.consultantDto).then(res => { this.storageIdToken(res.data.id_token); this.storageRole(Role.ADMIN); this.storageConsultantId(this.consultantDto.username) @@ -135,6 +141,7 @@ } private checkHttpErrorStatus(error:any):void{ this.clearValue(); + this.regenerateImgOfVerification(); switch (error.response.status) { case 401: const errorMsg = error.response.data.detail; -- Gitblit v1.8.0