wxml
<
button
class=
"buttonget"
disabled=
"{{disabled}}"
data-id=
"2"
bindtap=
"getBtn"
>
{{time}}
</
button
>
wxss
/*获取验证码 */
.buttonget {
background-color:
#fff;
display:
inline-block;
font-size:
26
rpx;
color:
rgb(
136,
136,
136
);
border:
1px
solid
#888;
border-radius:
10
rpx;
width:
160
rpx;
height:
70
rpx;
line-height:
70
rpx;
position:
absolute;
top:
0;
right:
20
rpx;
z-index:
2;
padding-right:
0;
padding-left:
0;
margin-top:
10
rpx;
}
//验证码倒计时函数
getCode:
function (options) {
var that =
this;
var currentTime = that.data.currentTime;
that.setData({
time: currentTime +
'秒'
})
interval = setInterval(
function () {
that.setData({
time: (currentTime -
1) +
'秒'
})
currentTime--;
if (currentTime <=
0) {
clearInterval(interval)
that.setData({
time:
'重新获取',
currentTime:
60,
disabled:
false
})
}
},
1000)
},
//验证码倒计时结束