From 400374484625c083db8d55b620294b2b3b3578eb Mon Sep 17 00:00:00 2001 From: danshihao Date: Mon, 29 Jul 2024 10:56:03 +0800 Subject: [PATCH] =?UTF-8?q?[fix=2087354]=20=E7=99=BB=E5=BD=95-=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E5=85=88=E5=8E=BB=E8=8E=B7=E5=8F=96=E5=85=AC?= =?UTF-8?q?=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/user/Login.vue | 72 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue index 029202a..0817257 100644 --- a/src/views/user/Login.vue +++ b/src/views/user/Login.vue @@ -278,7 +278,7 @@ export default { Vue.ls.remove(ACCESS_TOKEN) this.getRouterData() this.handleChangeCheckCode() - this.getPublicKey() // 获取秘钥 + // this.getPublicKey() // 获取秘钥 }, methods: { ...mapActions(['Login', 'Logout', 'PhoneLogin']), @@ -295,8 +295,10 @@ export default { const that = this const loginParams = {} that.loginBtn = true - that.form.validateFields(['username', 'password', 'inputCode', 'rememberMe'], { force: true }, (err, values) => { + that.form.validateFields(['username', 'password', 'inputCode', 'rememberMe'], { force: true }, async (err, values) => { if (!err) { + // 获取公钥 + await this.getPublicKey() loginParams.remember_me = values.rememberMe loginParams.captcha = that.inputCodeContent loginParams.checkKey = that.currdatetime @@ -326,39 +328,39 @@ export default { e.preventDefault() const that = this this.form.validateFields(['mobile'], { force: true }, (err, values) => { - if (!values.mobile) { - that.cmsFailed('请输入手机号') - } else if (!err) { - this.state.smsSendBtn = true - const interval = window.setInterval(() => { - if (that.state.time-- <= 0) { - that.state.time = 60 - that.state.smsSendBtn = false - window.clearInterval(interval) - } - }, 1000) + if (!values.mobile) { + that.cmsFailed('请输入手机号') + } else if (!err) { + this.state.smsSendBtn = true + const interval = window.setInterval(() => { + if (that.state.time-- <= 0) { + that.state.time = 60 + that.state.smsSendBtn = false + window.clearInterval(interval) + } + }, 1000) - const hide = this.$message.loading('验证码发送中..', 0) - const smsParams = {} - smsParams.mobile = values.mobile - smsParams.smsmode = '0' - postAction('/sys/sms', smsParams) - .then(res => { - if (!res.success) { - setTimeout(hide, 0) - this.cmsFailed(res.message) - } - setTimeout(hide, 500) - }) - .catch(err => { - setTimeout(hide, 1) - clearInterval(interval) - that.state.time = 60 - that.state.smsSendBtn = false - this.requestFailed(err) - }) - } + const hide = this.$message.loading('验证码发送中..', 0) + const smsParams = {} + smsParams.mobile = values.mobile + smsParams.smsmode = '0' + postAction('/sys/sms', smsParams) + .then(res => { + if (!res.success) { + setTimeout(hide, 0) + this.cmsFailed(res.message) + } + setTimeout(hide, 500) + }) + .catch(err => { + setTimeout(hide, 1) + clearInterval(interval) + that.state.time = 60 + that.state.smsSendBtn = false + this.requestFailed(err) + }) } + } ) }, handleChangeCheckCode () { @@ -379,8 +381,10 @@ export default { // 获取RSA公钥 getPublicKey () { // 获取公钥 - getRSAPublicKey().then(res => { + return getRSAPublicKey().then(res => { this.rsaPublicKey = res.result + }).catch(err => { + console.error(err) }) }, loginSuccess () {