var message = resultLis[0].planGroup0.message;
//获取时间
var sekillEndTime = resultLis[0].planGroup0.sekillEndTime;//结束时间
var sekillStartTime =resultLis[0].planGroup0.sekillStartTime;//开始时间
//转换成日期格式
var endTime1 = "20" + sekillEndTime.substring(0, 2) + "/" + sekillEndTime.substring(2, 4) + "/" + sekillEndTime.substring(4, 6) + " " + sekillEndTime.substring(6, 8) + ":" + sekillEndTime.substring(8, 10) + ":" + sekillEndTime.substring(10, 12);
var StartTime1 = "20" + sekillStartTime.substring(0, 2) + "/" + sekillStartTime.substring(2, 4) + "/" + sekillStartTime.substring(4, 6) + " " + sekillStartTime.substring(6, 8) + ":" + sekillStartTime.substring(8, 10) + ":" + sekillStartTime.substring(10, 12);
// console.log(endTime1, StartTime1);
//var date1 = new Date(Date.parse(StartTime1));
//var date2 = new Date(Date.parse(endTime1));
//秒抢的开始时间
var date1 = new Date(StartTime1);
//秒抢结束时间
var date2 = new Date(endTime1);
//秒抢的开始时间
var newTime = sekillStartTime.substring(6, 8) + ":" + sekillStartTime.substring(8, 10) + ‘:‘ + sekillStartTime.substring(10, 12);
//获取系统当前时间
var myDate = new Date();
var year = myDate.getFullYear(); //获取年
var month = myDate.getMonth() + 1;//获取月
var day = myDate.getDate(); //获取当日
var hh = myDate.getHours(); //时
var mm = myDate.getMinutes(); //分
var ss = myDate.getSeconds(); //秒
var tm3 = year + "/" + month + "/" + day + " " + hh + ":" + mm + ":" + ss;
var date3= new Date(tm3);
if (message == 1){
if ((parseInt(date1 - date3)) / 1000 <= 0 ){
var totalSecond = (parseInt(date2 - date1)) / 1000;//时间进行转化格式
console.log(totalSecond)
var interval = setInterval(function () {
// 总秒数
var second = totalSecond;
// 天数位
var day = Math.floor(second / 3600 / 24);
var dayStr = day.toString();
if (dayStr.length == 1) dayStr = ‘0‘ + dayStr;
// 小时位
var hr = Math.floor((second - day * 3600 * 24) / 3600);
var hrStr = hr.toString();
if (hrStr.length == 1) hrStr = ‘0‘ + hrStr;
// 分钟位
var min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60);
var minStr = min.toString();
if (minStr.length == 1) minStr = ‘0‘ + minStr;
// 秒位
var sec = second - day * 3600 * 24 - hr * 3600 - min * 60;;
var secStr = sec.toString();
if (secStr.length == 1) secStr = ‘0‘ + secStr;
this.setData({
countDownHour: hrStr,
countDownMinute: minStr,
countDownSecond: secStr,
});
totalSecond--;
if (totalSecond < 0) {
clearInterval(interval);
wx.showToast({
title: ‘活动已结束‘,
});
this.setData({
countDownHour: ‘00‘,
countDownMinute: ‘00‘,
countDownSecond: ‘00‘,
});
}
}.bind(this), 1000);
}else{
this.setData({
countDownHour: ‘00‘,
countDownMinute: ‘00‘,
countDownSecond: ‘00‘,
});
}
} else if (message == 2){
wx.showToast({
title: ‘今日秒杀已经结束‘,
duration: 2000
})
}