提交 db6a1487 authored 作者: matian's avatar matian

报名弹窗关闭清除数据

上级 279262b4
...@@ -94,15 +94,12 @@ export default { ...@@ -94,15 +94,12 @@ export default {
handleSubmit() { handleSubmit() {
const params = { ...this.ruleForm } const params = { ...this.ruleForm }
api.postNes(params).then((response) => { api.postNes(params).then((response) => {
// this.$notify({ type: 'success', message: response.message })
// this.$dialog.alert({ message: response.message }).then(() => {
// this.$emit('success')
// })
this.$message.success(response.message) this.$message.success(response.message)
this.$emit('success') this.$emit('success')
this.ruleForm.name = '' this.ruleForm.name = ''
this.ruleForm.phone = '' this.ruleForm.phone = ''
this.phoneCode = '' this.phoneCode = ''
this.codeButtonDisabled = false
}) })
}, },
// 校验短信验证码 // 校验短信验证码
......
...@@ -9,6 +9,8 @@ export default { ...@@ -9,6 +9,8 @@ export default {
tabBtnTarget: '', tabBtnTarget: '',
sendCode: '', sendCode: '',
isBtnDisabled: false, isBtnDisabled: false,
disabledTime: 60,
timer: null,
formInfo: { formInfo: {
name: '', name: '',
phone: '', phone: '',
...@@ -16,7 +18,11 @@ export default { ...@@ -16,7 +18,11 @@ export default {
} }
} }
}, },
computed: {
buttonText() {
return this.isBtnDisabled ? `${this.disabledTime}s` : '获取验证码'
}
},
methods: { methods: {
handleMsOver(type) { handleMsOver(type) {
this.tabBtnActive = true this.tabBtnActive = true
...@@ -49,6 +55,11 @@ export default { ...@@ -49,6 +55,11 @@ export default {
message: '报名成功', message: '报名成功',
duration: 5000 duration: 5000
}) })
this.formInfo.name = ''
this.formInfo.phone = ''
this.sendCode = ''
this.isBtnDisabled = false
this.tabBtnActive = false
}) })
.catch((err) => { .catch((err) => {
if (err && err.type === 'checkcode') this.$message.error(err.msg) if (err && err.type === 'checkcode') this.$message.error(err.msg)
...@@ -97,7 +108,9 @@ export default { ...@@ -97,7 +108,9 @@ export default {
this.$message.success('验证码已发送,请注意查收') this.$message.success('验证码已发送,请注意查收')
else this.$message.error('获取验证码失败,请稍后再试') else this.$message.error('获取验证码失败,请稍后再试')
}) })
.catch(() => {}) .catch(() => {
this.clearTimer()
})
} }
}, },
checkSendcode() { checkSendcode() {
...@@ -126,19 +139,21 @@ export default { ...@@ -126,19 +139,21 @@ export default {
}, },
btnDisabledTimer() { btnDisabledTimer() {
this.isBtnDisabled = true this.isBtnDisabled = true
let count = 60 this.disabledTime = 60
document.querySelector('#checkedCode').innerHTML = count + 's' this.timer = setInterval(() => {
const timer = setInterval(() => { this.disabledTime--
count-- if (this.disabledTime < 1) {
if (count < 1) { this.clearTimer()
clearInterval(timer)
this.isBtnDisabled = false
document.querySelector('#checkedCode').innerHTML = '获取验证码'
} else {
document.querySelector('#checkedCode').innerHTML = count + 's'
} }
}, 1000) }, 1000)
},
clearTimer() {
this.isBtnDisabled = false
this.timer && clearInterval(this.timer)
} }
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
...@@ -185,14 +200,14 @@ export default { ...@@ -185,14 +200,14 @@ export default {
v-model="sendCode" v-model="sendCode"
placeholder="请输入验证码" placeholder="请输入验证码"
size="small" size="small"
></el-input ></el-input>
><el-button <el-button
class="btn" class="btn"
:disabled="isBtnDisabled" :disabled="isBtnDisabled"
id="checkedCode" id="checkedCode"
@click="getSendCode" @click="getSendCode"
> >
获取验证码 {{ buttonText }}
</el-button> </el-button>
</div> </div>
<div class="p"> <div class="p">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论