diff --git a/sgzb-ui/src/views/login.vue b/sgzb-ui/src/views/login.vue index 7144b430..d0aeb302 100644 --- a/sgzb-ui/src/views/login.vue +++ b/sgzb-ui/src/views/login.vue @@ -115,8 +115,8 @@ - - + - 这是一段信息 + + + + + + + + - 取 消 - 确 定 + 确 定 @@ -299,6 +325,8 @@ export default { message: '请输入短信验证码', }, ], + }, + phoneLoginCodeRules: { code: [ { required: true, @@ -318,20 +346,19 @@ export default { show: 1, count: '', timer: null, + dialogCodeVisible: false, // 图形验证码弹框 } }, watch: { /* 账户,手机号登录切换时,清空表单的校验 5.27 删除之前南网跳转的监听 */ activeName: { handler(newVal) { - this.$refs['loginForm'].clearValidate() - this.$refs['phoneLoginFormRef'].clearValidate() - + // this.$refs['loginForm'].clearValidate() + this.resetForm('loginForm') + this.resetForm('phoneLoginFormRef') // 切换登录方式时 根据切换方式 自动获取新的图形验证码 if (newVal === 'account') { this.getCode(1) - } else { - this.getCode(2) } }, deep: true, @@ -364,24 +391,28 @@ export default { }, //获取短信验证码 getTextCode() { - this.$refs.phoneLoginFormRef.validateField( - ['phone', 'code'], - async (valid) => { - if (!valid) { - const sendParams = { - phone: this.phoneLoginParams.phone, - code: this.phoneLoginParams.code, - uuid: this.phoneLoginParams.uuid, - } + this.$refs.phoneLoginFormRef.validateField('phone', (valid) => { + if (!valid) { + this.getCode(2) + this.dialogCodeVisible = true + } + }) + }, - const res = await sendCode(sendParams) - - if (res.code == 200) { - this.$modal.msgSuccess('发送成功') - const TIME_COUNT = 60 - if (!this.timer) { - this.count = TIME_COUNT - this.show = 2 + /* 图形验证码弹框中确定按钮 */ + submitSendCode() { + this.$refs.phoneLoginCodeFormRef.validate((valid) => { + if (valid) { + const sendParams = { + phone: this.phoneLoginParams.phone, + code: this.phoneLoginParams.code, + uuid: this.phoneLoginParams.uuid, + } + sendCode(sendParams) + .then((res) => { + if (res.code == 200) { + this.$modal.msgSuccess('发送成功') + const TIME_COUNT = 60 this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { this.count-- @@ -392,35 +423,21 @@ export default { } }, 1000) } - } - } - }, - ) - // if (regExp.test(this.loginForm.phone)) { - // sendCode({ phone: this.loginForm.phone }).then((res) => { - // if (res.code == 200) { - // this.$modal.msgSuccess('发送成功') - // const TIME_COUNT = 60 - // if (!this.timer) { - // this.count = TIME_COUNT - // this.show = 2 - // this.timer = setInterval(() => { - // if (this.count > 0 && this.count <= TIME_COUNT) { - // this.count-- - // } else { - // this.show = 3 - // clearInterval(this.timer) - // this.timer = null - // } - // }, 1000) - // } - // } - // }) - // } else { - // this.$modal.msgError('请输入正确手机号') - // } + }) + .finally(() => { + this.dialogCodeVisible = false + this.phoneLoginParams.code = '' + }) + } + }) + }, + /* 图形验证码弹框关闭按钮 */ + handleClose() { + this.dialogCodeVisible = false + this.$refs['phoneLoginFormRef'].clearValidate() + this.$refs['phoneLoginCodeFormRef'].clearValidate() + this.phoneLoginParams.code = '' }, - getCookie() { const username = Cookies.get('username') const password = Cookies.get('password') @@ -604,4 +621,8 @@ export default { .code-container .el-form-item__content { display: flex; } + +.el-dialog__body { + padding: 30px 20px 0 20px; +}