Commit 8a4ad3c3 by 李伟康

commit

1 parent c638387a
......@@ -64,11 +64,18 @@
/>
</div>
<div
class="btn"
:class="['btn',{'code-disabled':countDown}]"
@touchstart="touchstart"
@touchend="touchend"
@click="getCaptcha"
>输入验证码</div>
>
<template v-if="countDown">
{{count}}秒后获取
</template>
<template v-else>
获取验证码
</template>
</div>
</div>
</div>
<div
......@@ -101,7 +108,10 @@ export default {
mobile: '',
captcha: '',
userCouponId: '',
couponId: ''
couponId: '',
countDown: false,
count: 60,
verificationCount: ''
}
},
mounted () {
......@@ -126,7 +136,7 @@ export default {
})
},
getCaptcha () {
let { mobile } = this
let { mobile,countDown } = this
console.log(mobile)
if (!mobile) {
this.showToast('请输入手机号')
......@@ -137,16 +147,39 @@ export default {
return
}
}
if(countDown) return
this.showLoading()
ssoApi.getCaptcha({ mobile }).then(({ code, message }) => {
this.hideLoading()
if (code == 0) {
this.showToast('发送成功')
this.verificationFlag = true
this.verificationCount = Math.round(new Date() / 1000) + 60
this.countDown = true
this.playCountDown()
} else {
this.showToast(message)
}
})
},
playCountDown(){
let {
count,
verificationCount
} = this
countDownTime = setInterval(() => {
let nowTime = Math.round(new Date() / 1000)
if (nowTime == verificationCount) {
clearInterval(countDownTime)
this.count = 60
this.countDown = false
this.verificationFlag = false
return
}
count--
this.count = count
}, 1 * 1000)
},
receive () {
let { mobile, captcha } = this
if (!captcha) {
......@@ -303,13 +336,15 @@ export default {
color: #5850ff;
margin-left: 13px;
}
.code-disabled {
color: #999;
}
}
}
> .btn {
width: 100%;
height: 57px;
border-top: 1px solid #e5e5e5;
font-weight: 500;
color: #635aff;
font-size: 18px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!