Commit 8a4ad3c3 by 李伟康

commit

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