| | |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | width:300px; |
| | | height: 150px; |
| | | min-height: 150px; |
| | | max-height: 300px; |
| | | .el-message-box__content{ |
| | | padding: 15px; |
| | | .el-message-box__message p{ |
| | |
| | | } |
| | | |
| | | .el-message-box__btns{ |
| | | margin-top: 10px; |
| | | text-align: center; |
| | | } |
| | | .el-button.el-button--primary{ |
| | |
| | | import axios from 'axios'; |
| | | import { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios'; |
| | | import { MessageBox } from 'element-ui'; |
| | | import ErrorMessageBox from '../errorService'; |
| | | import axios from 'axios'; |
| | | import _ from 'lodash'; |
| | | |
| | | const notRequireInterceptorErrorUrl=[ |
| | | '/otp/verify', |
| | | '/eService/authenticate', |
| | | '/login/validate/get_img_code', |
| | | '/login/validate/verify_img_code', |
| | | ]; |
| | | |
| | | export const service = axios.create({ |
| | | baseURL: process.env.BASE_URL, |
| | | withCredentials: true |
| | | }) |
| | | }); |
| | | |
| | | service.interceptors.request.use( |
| | | (config:AxiosRequestConfig)=>{ |
| | |
| | | }, |
| | | (error:AxiosError)=>{ |
| | | loadingFinish(); |
| | | if (error.config.url !== '/otp/verify') { |
| | | openErrorMessage(); |
| | | } |
| | | showErrorMessageBox(error) |
| | | return Promise.reject(error); |
| | | } |
| | | ); |
| | | |
| | | |
| | | |
| | | function loadingStart(): void { |
| | | window.$nuxt.$loading.start(); |
| | | } |
| | | }; |
| | | |
| | | function loadingFinish(): void { |
| | | window.$nuxt.$loading.finish(); |
| | | } |
| | | }; |
| | | |
| | | function openErrorMessage():void{ |
| | | MessageBox({ |
| | | message: '系統ç¼çé¯èª¤', |
| | | showClose:false, |
| | | showConfirmButton:true, |
| | | confirmButtonText:'確èª', |
| | | customClass:'pam-message-box', |
| | | closeOnClickModal:false, |
| | | }); |
| | | function showErrorMessageBox(error:AxiosError):void{ |
| | | if(!_.includes(notRequireInterceptorErrorUrl,error.config.url)){ |
| | | ErrorMessageBox(); |
| | | } |
| | | }; |
¤ñ¹ï·sÀÉ®× |
| | |
| | | import { MessageBox } from 'element-ui'; |
| | | |
| | | export default function ErrorMessageBox(errorMsg?:string):void{ |
| | | MessageBox({ |
| | | message: errorMsg ? errorMsg:'系統ç¼çé¯èª¤', |
| | | showClose:false, |
| | | showConfirmButton:true, |
| | | confirmButtonText:'確èª', |
| | | customClass:'pam-message-box', |
| | | closeOnClickModal:false, |
| | | }); |
| | | } |
| | |
| | | |
| | | <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 = ''; |
| | | } |
| | |
| | | import { namespace } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, Ref } from 'vue-property-decorator'; |
| | | import { LoginRequest, LoginVerify, loginVerify, OtpInfo, register, RegisterInfo, sendOtp } from '~/assets/ts/api/consultant'; |
| | | import ErrorMessageBox from '~/assets/ts/errorService'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | |
| | | this.phoneSuccessConfirmVisable = true; |
| | | this.storagePhoneOrEmail(this.setRegisterInfo()); |
| | | }).catch(error => { |
| | | if (error.response.status === 401) { |
| | | this.checkHttpErrorStatus(error); |
| | | }); |
| | | } |
| | | private checkHttpErrorStatus(error:any):void{ |
| | | switch (error.response.status) { |
| | | case 401: |
| | | const errorMsg = error.response.data.detail; |
| | | ErrorMessageBox(errorMsg); |
| | | break; |
| | | case 403: |
| | | this.registerDialogVisible = true; |
| | | setTimeout(() => { |
| | | const isScrollBarNeedless = this.contract.scrollHeight <= this.contract.clientHeight; |
| | |
| | | this.isReadContract = true; |
| | | } |
| | | }, 1000); |
| | | break; |
| | | default: |
| | | ErrorMessageBox(); |
| | | break; |
| | | } |
| | | }) |
| | | } |
| | | |
| | | destroyed() { |