timeOut: function(time) {
var that = this;
var end = new Date(time).getTime();
var Interval = setInterval(function() {
var start = new Date().getTime()
var x = end - start;
if (x > 0) {
var seconds = x / 1000;
seconds = parseInt(seconds); //秒数取整
var day = parseInt(seconds / 86400);
seconds %= 86400;
var hour = parseInt(seconds / 3600);
seconds %= 3600;
var min = parseInt(seconds / 60);
var sec = seconds %= 60;
if (day < 10) {
day = '0' + day
}
if (hour < 10) {
hour = '0' + hour
}
if (min < 10) {
min = '0' + min
}
if (sec < 10) {
sec = '0' + sec
}
that.setData({
time: day + '天 ' + hour + ': ' + min + ': ' + sec,
})
} else {
clearInterval(Interval);
that.setData({
time: '0天 00: 00: 00',
isMask: true
})
// wx.navigateBack({
// delta: 1
// })
}
}, 1000)
}
timeOut(2019/11/26) // 参数:倒计时结束的时间