| | |
| | | </template> |
| | | </div> |
| | | |
| | | |
| | | <el-row type="flex" justify="center" class="pam-login-page__action-bar mt-30 mb-30"> |
| | | <el-row type="flex" justify="center" class="pam-login-page__action-bar mt-30"> |
| | | <el-button |
| | | type="primary" |
| | | v-if="(connectDevice === 'MOBILE' && onPhoneVerifyStep === 'INPUT_OTP') || (connectDevice === 'EMAIL' && onEmailVerifyResendStatus === 'CAN_RESEND')" |
| | |
| | | </el-button> |
| | | </el-row> |
| | | |
| | | <el-dialog |
| | | title="歡迎新使用者" |
| | | :custom-class="'pam-register-dialog'" |
| | | :visible.sync="registerDialogVisible" |
| | | :fullscreen="true" |
| | | :close-on-click-modal="false" |
| | | :show-close="false" |
| | | center> |
| | | <span> |
| | | <PopUpFrame |
| | | :isOpen.sync="registerDialogVisible" |
| | | :dialogWidth="'90%'" |
| | | :drawerSize="'95%'" |
| | | class="pam-register-dialog" |
| | | @closePopUp="isReadContract = false" |
| | | > |
| | | <div class="subTitle text--center mb-20">歡迎新使用者</div> |
| | | <el-row> |
| | | <input |
| | | class="pam-input" |
| | |
| | | </el-row> |
| | | <el-row class="pt-10"> |
| | | <div |
| | | v-if="registerDialogVisible" |
| | | class="mdTxt pam-register-dialog__contract" |
| | | ref="contract" |
| | | @scroll="detectContractReadStatus"> |
| | |
| | | </label> |
| | | </div> |
| | | </el-row> |
| | | </span> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button |
| | | type="primary" |
| | | :disabled="!name || !agreeContract || !isReadContract" |
| | | @click="applyAccount" |
| | | >建立新帳號 |
| | | </el-button> |
| | | </span> |
| | | </el-dialog> |
| | | <div class="text--center mt-10"> |
| | | <el-button |
| | | type="primary" |
| | | :disabled="!name || !agreeContract || !isReadContract" |
| | | @click="applyAccount" |
| | | >建立新帳號 |
| | | </el-button> |
| | | </div> |
| | | </PopUpFrame> |
| | | |
| | | <PopUpFrame class="pam-popUpFrame" |
| | | :isOpen.sync="emailOtpConfirmVisable"> |
| | | :isOpen.sync="emailOtpConfirmVisable" |
| | | :drawerSize="'35%'" |
| | | > |
| | | <div class="pam-popUp-title text--center">已將驗證訊息發送至</div> |
| | | <div class="pam-popUp-title text--center">{{email}}</div> |
| | | <div class="pam-popUp-title text--center">請查看電子郵件並完成驗證流程</div> |
| | |
| | | </PopUpFrame> |
| | | |
| | | <PopUpFrame class="pam-popUpFrame" |
| | | :isOpen.sync="registerSuccessConfirmVisable"> |
| | | :isOpen.sync="registerSuccessConfirmVisable" |
| | | @closePopUp="confirmApplySuccess" |
| | | :drawerSize="'35%'" |
| | | > |
| | | <div class="pam-popUp-title text--center"> |
| | | 歡迎您登入成功,如您預約諮詢,顧問會以您留下的{{ connectDevice === 'MOBILE' ? '手機號碼' : 'Email'}}與您聯繫 |
| | | </div> |
| | | <div class="pam-popUp-txt text--center mb-10 mt-5" |
| | | >即將轉跳頁面...{{autoRedirectCounter}}秒</div> |
| | | <div class="pam-popUp-confirm-bolck pam-paragraph"> |
| | | <div class="text--center"> |
| | | <el-button |
| | | type="primary" |
| | | @click="confirmApplySuccess" |
| | | @click="registerSuccessConfirmVisable = false" |
| | | >我知道了</el-button> |
| | | </div> |
| | | </div> |
| | | </PopUpFrame> |
| | | |
| | | <PopUpFrame class="pam-popUpFrame" |
| | | :isOpen.sync="phoneSuccessConfirmVisable"> |
| | | <div class="pam-popUp-title text--center mb-50" |
| | | :isOpen.sync="phoneSuccessConfirmVisable" |
| | | @closePopUp="confirmApplySuccess" |
| | | :drawerSize="'30%'" |
| | | > |
| | | <div class="pam-popUp-title text--center" |
| | | >歡迎您登入成功</div> |
| | | <div class="pam-popUp-txt text--center mb-30 mt-5 xsTxt" |
| | | >即將轉跳頁面...{{autoRedirectCounter}}秒</div> |
| | | <div class="pam-popUp-confirm-bolck pam-paragraph"> |
| | | <div class="text--center"> |
| | | <el-button |
| | | type="primary" |
| | | @click="confirmApplySuccess" |
| | | @click="phoneSuccessConfirmVisable = false" |
| | | >我知道了</el-button> |
| | | </div> |
| | | </div> |
| | |
| | | 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 { OtpErrorCode } from '~/assets/ts/models/enum/otpErrorCode'; |
| | | import { Role } from '~/assets/ts/models/enum/Role'; |
| | | |
| | | const roleStorage = namespace('localStorage'); |
| | |
| | | emailResendInterval: any; |
| | | emailOtpInfo!: OtpInfo; |
| | | |
| | | autoRedirectCounter = 3; |
| | | autoRedirectInterval: any; |
| | | |
| | | name = ''; |
| | | agreeContract = false; |
| | | isReadContract = false; |
| | |
| | | |
| | | applyAccount_onAction = false; |
| | | |
| | | previousPath = ''; |
| | | mounted() { |
| | | const phoneOtpTime = localStorage.getItem('phoneOtpTime'); |
| | | const emailOtpTime = localStorage.getItem('emailOtpTime'); |
| | |
| | | get phoneCounter() { |
| | | let min = Math.floor(this.otpCounterSec / 60); |
| | | let sec = Math.floor(this.otpCounterSec % 60); |
| | | return `${min < 10 ? '0' + min : min} : ${sec < 10 ? '0' + sec : sec}`; |
| | | return `${min < 10 ? '0' + min : min}:${sec < 10 ? '0' + sec : sec}`; |
| | | } |
| | | |
| | | get emailOtpCounter() { |
| | | let min = Math.floor(this.emailCounterSec / 60); |
| | | let sec = Math.floor(this.emailCounterSec % 60); |
| | | return `${min < 10 ? '0' + min : min} : ${sec < 10 ? '0' + sec : sec}`; |
| | | return `${min < 10 ? '0' + min : min}:${sec < 10 ? '0' + sec : sec}`; |
| | | } |
| | | |
| | | get showPhoneOtpCodeField(): boolean { |
| | |
| | | this.storageOtpTime(type, otpInfo); |
| | | this.startOtpSetting(type); |
| | | this.startOtpCount(type); |
| | | } else { |
| | | const errorMsg = OtpErrorCode[otpInfo.failCode] ? OtpErrorCode[otpInfo.failCode]:'OTP系統錯誤'; |
| | | ErrorMessageBox(errorMsg); |
| | | } |
| | | }); |
| | | }; |
| | |
| | | this.storageIdToken(res.data.id_token); |
| | | this.storageRole(Role.USER); |
| | | this.storagePhoneOrEmail(registerInfo); |
| | | this.autoRedirect(); |
| | | this.registerSuccessConfirmVisable = true; |
| | | }).catch(() => { |
| | | this.applyAccount_onAction = false; |
| | |
| | | confirmApplySuccess(): void { |
| | | this.phoneSuccessConfirmVisable = false; |
| | | this.registerSuccessConfirmVisable = false; |
| | | this.$router.go(-1); |
| | | this.redirect(); |
| | | } |
| | | |
| | | private autoRedirect() { |
| | | this.autoRedirectInterval = setInterval(() => { |
| | | this.autoRedirectCounter -= 1; |
| | | |
| | | if (this.autoRedirectCounter === 0) { |
| | | clearInterval(this.autoRedirectInterval); |
| | | this.redirect(); |
| | | } |
| | | }, 1000) |
| | | } |
| | | |
| | | private redirect() { |
| | | const backToPrevious = ['questionnaire', 'myConsultantList']; |
| | | const find = backToPrevious.findIndex(item => this.previousPath.includes(item)); |
| | | console.log(this.previousPath, find, 'redirect'); |
| | | find > -1 ? this.$router.go(-1) : this.$router.push('/'); |
| | | } |
| | | |
| | | beforeRouteEnter (to, from, next) { |
| | | next(vm => { |
| | | console.log(from.path, 'beforeRouteEnter'); |
| | | vm.previousPath = from.path; |
| | | }) |
| | | } |
| | | |
| | | login() { |
| | | const login: LoginVerify = this.setLoginInfo(); |
| | |
| | | this.storageIdToken(res.data.id_token); |
| | | this.storageRole(Role.USER); |
| | | this.phoneSuccessConfirmVisable = true; |
| | | this.autoRedirect(); |
| | | this.storagePhoneOrEmail(this.setRegisterInfo()); |
| | | }).catch(error => { |
| | | if (error.response.status === 401) { |
| | | this.registerDialogVisible = true; |
| | | setTimeout(() => { |
| | | const isScrollBarNeedless = this.contract.scrollHeight <= this.contract.clientHeight; |
| | | if (isScrollBarNeedless) { |
| | | this.isReadContract = true; |
| | | } |
| | | }, 1000); |
| | | this.checkHttpErrorStatus(error); |
| | | }); |
| | | } |
| | | private checkHttpErrorStatus(error:any):void{ |
| | | switch (error.response.status) { |
| | | case 401: |
| | | const errorMsg = OtpErrorCode[error.response?.data?.detail] ? OtpErrorCode[error.response?.data?.detail]:'OTP系統錯誤'; |
| | | ErrorMessageBox(errorMsg); |
| | | break; |
| | | case 403: |
| | | this.registerDialogVisible = true; |
| | | setTimeout(() => { |
| | | const isScrollBarNeedless = this.contract.scrollHeight <= this.contract.clientHeight; |
| | | if (isScrollBarNeedless) { |
| | | this.isReadContract = true; |
| | | } |
| | | }, 1000); |
| | | break; |
| | | default: |
| | | ErrorMessageBox('',error); |
| | | break; |
| | | } |
| | | }) |
| | | } |
| | | |
| | | destroyed() { |
| | | this.removeOtpTime(); |
| | | clearInterval(this.otpInterval); |
| | | clearInterval(this.emailResendInterval); |
| | | clearInterval(this.autoRedirectInterval); |
| | | } |
| | | |
| | | private phoneDiffTime(parseOtpTime: any) { |
| | |
| | | display: flex; |
| | | flex: 1; |
| | | align-items: flex-end; |
| | | @include desktop { |
| | | margin-bottom: 30px; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | .pam-register-dialog__contract { |
| | | $DEVICE_EXTRA_HEIGHT: 42px; |
| | | $ALIGN_PADDING: 60px; |
| | | $TOP_CONTENT_HEIGHT: 186px; |
| | | $BOTTOM_CONTENT_HEIGHT: 131px; |
| | | max-height: calc(100vh - $DEVICE_EXTRA_HEIGHT - $ALIGN_PADDING - $TOP_CONTENT_HEIGHT - $BOTTOM_CONTENT_HEIGHT); |
| | | overflow-y: scroll; |
| | | border-radius: 6px; |
| | | border: 1px solid #707070; |
| | | padding: 20px; |
| | | } |
| | | |
| | | .pam-radio { |
| | | color: $PRIMARY_RED; |
| | | align-items: center; |
| | |
| | | i { |
| | | font-size: 27px; |
| | | padding-right: 5px; |
| | | } |
| | | } |
| | | |
| | | .pam-register-dialog { |
| | | padding: 30px 20px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | border-radius: 0; |
| | | &.el-dialog { |
| | | border-radius: 0; |
| | | } |
| | | .el-dialog__header { |
| | | padding: 0; |
| | | margin-bottom: 30px; |
| | | .el-dialog__title { |
| | | @extend .subTitle; |
| | | } |
| | | } |
| | | .el-dialog__body { |
| | | flex: 1; |
| | | padding: 0; |
| | | margin-bottom: 30px; |
| | | } |
| | | .el-dialog__footer { |
| | | padding: 0 !important; |
| | | } |
| | | } |
| | | |
| | |
| | | font-size: 20px; |
| | | line-height: 27px; |
| | | } |
| | | |
| | | .pam-popUp-txt { |
| | | font-size: 18px; |
| | | color: $MID_GREY; |
| | | } |
| | | |
| | | .disabled { |
| | | color: #A7A8AA; |
| | | } |