- 需求的场景描述(希望解决的问题)
ISO 倒计时 iso手机不能显示时间,真机调试可以显示,但是体验版就不显示
- 希望提供的能力
部分代码
if (res.statusCode == 200) {
var startTime = res.data.result.DRABACK_TIME
startTime = startTime.replace(/-/g, ‘/’)
startTime = new Date(startTime).getTime()
var endTimeList = startTime + 172800000
endTimeList = util.formatDate(endTimeList)
that.setData({
actEndTimeList: endTimeList
});
// 执行倒计时函数
that.countdown();
}
countdown: function () {
var that = this;
var endTimes = that.data.actEndTimeList
timer = setInterval(function () {
let countDownArr = [];
let newTime = new Date().getTime();
let endTimeList = endTimes;
let endTime = new Date(endTimeList).getTime();
let obj = null;
if (endTime - newTime > 0) {
let time = (endTime - newTime) / 1000
let day = parseInt(time / (60 * 60 * 24));
let hou = parseInt(time % (60 * 60 * 24) / 3600);
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
obj = {
day: util.timeFormat(day),
hou: util.timeFormat(hou),
min: util.timeFormat(min),
sec: util.timeFormat(sec)
}
} else {
obj = {
day: ‘00’,
hou: ‘00’,
min: ‘00’,
sec: ‘00’
}
}
countDownArr.push(obj);
that.setData({ countDownList: countDownArr })
}, 1000);
},