手机号验证码校验

This commit is contained in:
zhaoxiao
2021-10-11 15:37:30 +08:00
parent b7f83108db
commit 5c5d5ab062
+23 -19
View File
@@ -238,27 +238,31 @@ export default {
this.cmsFailed('手机号不能为空!') this.cmsFailed('手机号不能为空!')
return return
} }
this.state.smsSendBtn = true this.form.validateFields(['phone'], { force: true }, (err) => {
let interval = window.setInterval(() => { if (!err) {
if (that.state.time-- <= 0) { const hide = this.$message.loading('验证码发送中..', 0)
that.state.time = 60 let smsParams = {
that.state.smsSendBtn = false phone: phone,
window.clearInterval(interval) }
getAction('/sys/sendVerificationCode', smsParams).then(res => {
if (!res.success) {
setTimeout(hide, 1)
this.cmsFailed(res.message)
} else {
this.state.smsSendBtn = true
let interval = window.setInterval(() => {
if (that.state.time-- <= 0) {
that.state.time = 60
that.state.smsSendBtn = false
window.clearInterval(interval)
}
}, 1000)
}
setTimeout(hide, 500)
})
this.getPublicKey()
} }
}, 1000)
const hide = this.$message.loading('验证码发送中..', 0)
let smsParams = {
phone: phone,
}
getAction('/sys/sendVerificationCode', smsParams).then(res => {
if (!res.success) {
setTimeout(hide, 1)
this.cmsFailed(res.message)
}
setTimeout(hide, 500)
}) })
this.getPublicKey()
}, },
cmsFailed(err) { cmsFailed(err) {
this.$notification['error']({ this.$notification['error']({