diff --git a/pages/register.vue b/pages/register.vue index 01f14b3..54db929 100644 --- a/pages/register.vue +++ b/pages/register.vue @@ -20,7 +20,7 @@ - 发送验证码 + {{loadText}} @@ -50,12 +50,16 @@ code: '', password: '', confirmPassword: '' - } + }, + loading: false, + loadText: '发送验证码', + timeClock: null } }, methods: { sendCode() { let _ts = this; + _ts.timerHandler(); let email = _ts.user.email; if (!email) { return false @@ -73,6 +77,20 @@ console.log(error) }) }, + timerHandler() { + let _ts = this; + _ts.$set(_ts, 'loading', true); + let times = 60; + _ts.timeClock = setInterval(function (){ + times --; + _ts.$set(_ts, 'loadText', times + 's'); + if (times == 0) { + clearInterval(_ts.timeClock); + _ts.$set(_ts, 'loading', false); + _ts.$set(_ts, 'loadText', '发送验证码'); + } + },1000) + }, register() { let _ts = this; _ts.$refs.user.validate((valid) => {