var currentTime = 59 //倒计时的事件(单位:s)
var interval = null //倒计时函数

Page({
data: {
time:59 //倒计时
},
onLoad:function(){
this.countdown();
},
// 倒计时
countdown:function(){
var that = this;
interval = setInterval(function () {
currentTime--;
that.setData({
time: currentTime
})

if (currentTime <= 0) {
clearInterval(interval)
currentTime = -1
}
}, 1000)
}

}

05-26 04:58