![这里写图片描述](https://img-blog.csdn.net/20171115113114013?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvV3Vfc2h1eHVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![这里写图片描述](https://img-blog.csdn.net/20171115113123617?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvV3Vfc2h1eHVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![这里写图片描述](https://img-blog.csdn.net/20171115113011129?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvV3Vfc2h1eHVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
wxml
<button disabled='{{disabled}}' data-id="2" bindtap="getVerificationCode">
{{time}}
</button>
js
var interval = null
Page({
data: {
date:'请选择日期',
fun_id:2,
time: '获取验证码',
currentTime:61
},
getCode: function (options){
var that = this;
var currentTime = that.data.currentTime
interval = setInterval(function () {
currentTime--;
that.setData({
time: currentTime+'秒'
})
if (currentTime <= 0) {
clearInterval(interval)
that.setData({
time: '重新发送',
currentTime:61,
disabled: false
})
}
}, 100)
},
getVerificationCode(){
this.getCode();
var that = this
that.setData({
disabled:true
})
},
})