| | |
| | | |
| | | <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({ |
| | |
| | | } |
| | | |
| | | 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('驗證碼輸入錯誤'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | 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 { |
| | |
| | | }; |
| | | |
| | | private clearValue():void{ |
| | | if (!this.isRememberUserName) this.consultantDto.username=''; |
| | | this.consultantDto.password = ''; |
| | | this.verificationCode = ''; |
| | | } |