示意圖:

點(diǎn)擊前.png

點(diǎn)擊后.png
wxml
<button disabled='{{disabled}}' data-id="2" bindtap="getVerificationCode">
{{time}}
</button>
js
var interval = null //倒計時函數(shù)
Page({
data: {
fun_id:2,
time: '獲取驗(yàn)證碼', //倒計時
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: '重新發(fā)送',
currentTime:61,
disabled: false
})
}
}, 1000)
},
getVerificationCode(){
this.getCode();
var that = this
that.setData({
disabled:true
})
},
})
wxss 自行補(bǔ)充