...
|
...
|
@@ -4,6 +4,8 @@ Page({ |
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
|
|
|
orderList:[],
|
|
|
navbar: [{
|
|
|
name: '全部'
|
|
|
},
|
...
|
...
|
@@ -30,7 +32,7 @@ Page({ |
|
|
}
|
|
|
],
|
|
|
currentTab: 0,
|
|
|
orderList: '',
|
|
|
// orderList: '',
|
|
|
page: 1,
|
|
|
status: 0,
|
|
|
toCancel: false,
|
...
|
...
|
@@ -38,21 +40,16 @@ Page({ |
|
|
|
|
|
|
|
|
//倒计时
|
|
|
countDownList: [],
|
|
|
actEndTimeList: []
|
|
|
// countDownList: [],
|
|
|
// actEndTimeList: []
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
// let endTimeList = [];
|
|
|
// // 将活动的结束时间参数提成一个单独的数组,方便操作
|
|
|
// goodsList.forEach(o => { endTimeList.push(o.actEndTime) })
|
|
|
// this.setData({ actEndTimeList: endTimeList });
|
|
|
// // 执行倒计时函数
|
|
|
// this.countDown();
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -80,12 +77,11 @@ Page({ |
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
|
|
|
timeFormat(param) {//小于10的格式化函数
|
|
|
timeFormat(param) { //小于10的格式化函数
|
|
|
return param < 10 ? '0' + param : param;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 我的订单
|
|
|
myOrder() {
|
...
|
...
|
@@ -105,107 +101,58 @@ Page({ |
|
|
|
|
|
// 列表值
|
|
|
that.setData({
|
|
|
orderList: res.data.list
|
|
|
orderList: res.data.list,
|
|
|
now_time: res.data.now_time
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
that.countDown()
|
|
|
}).catch((err) => {
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
countDown() {//倒计时函数
|
|
|
// 获取当前时间,同时得到活动结束时间数组
|
|
|
let newTime = new Date().getTime();
|
|
|
let endTimeList = this.data.actEndTimeList;
|
|
|
let countDownArr = [];
|
|
|
|
|
|
// 对结束时间进行处理渲染到页面
|
|
|
endTimeList.forEach(o => {
|
|
|
let endTime = new Date(o).getTime();
|
|
|
let obj = null;
|
|
|
// 如果活动未结束,对时间进行处理
|
|
|
if (endTime - newTime > 0) {
|
|
|
let time = (endTime - newTime) / 1000;
|
|
|
// 获取天、时、分、秒
|
|
|
//团购倒计时
|
|
|
countDown() {
|
|
|
let that = this
|
|
|
let objs = Object.assign([], that.data.orderList)
|
|
|
let now_time = parseInt(new Date().getTime())
|
|
|
// console.log('现在的时间:'+now_time)
|
|
|
|
|
|
for (let obj of objs) {
|
|
|
|
|
|
let end_time = obj.end_time * 1000
|
|
|
// console.log(end_time)
|
|
|
let open_time = obj.open_time * 1000
|
|
|
if (now_time < open_time) {
|
|
|
// console.log(333)
|
|
|
//活动未开始
|
|
|
} else if (now_time > end_time) {
|
|
|
// console.log(222)
|
|
|
//活动结束
|
|
|
} else {
|
|
|
// console.log(1111)
|
|
|
let time = (end_time - now_time) / 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: this.timeFormat(day),
|
|
|
hou: this.timeFormat(hou),
|
|
|
min: this.timeFormat(min),
|
|
|
sec: this.timeFormat(sec)
|
|
|
}
|
|
|
} else {//活动已结束,全部设置为'00'
|
|
|
obj = {
|
|
|
day: '00',
|
|
|
hou: '00',
|
|
|
min: '00',
|
|
|
sec: '00'
|
|
|
}
|
|
|
|
|
|
obj.day = that.timeFormat(day),
|
|
|
obj.hou = that.timeFormat(hou),
|
|
|
obj.min = that.timeFormat(min),
|
|
|
obj.sec = that.timeFormat(sec)
|
|
|
|
|
|
// console.log(obj.day, obj.hou, obj.min, obj.sec)
|
|
|
}
|
|
|
countDownArr.push(obj);
|
|
|
}
|
|
|
that.setData({
|
|
|
orderList: objs
|
|
|
})
|
|
|
// // 渲染,然后每隔一秒执行一次倒计时函数
|
|
|
// this.setData({ countDownList: countDownArr })
|
|
|
// setTimeout(this.countDown, 1000);
|
|
|
console.log(that.data.orderList)
|
|
|
setTimeout(that.countDown, 1000);
|
|
|
},
|
|
|
|
|
|
|
|
|
// 倒计时功能
|
|
|
// timeFunc(num) {
|
|
|
// //let number = res.compare.surplus_time;
|
|
|
// // 时间戳处理
|
|
|
// var totalSecond = num;
|
|
|
// 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;
|
|
|
|
|
|
// that.setData({
|
|
|
// days: dayStr,
|
|
|
// hours: hrStr,
|
|
|
// minutes: minStr,
|
|
|
// seconds: secStr,
|
|
|
// });
|
|
|
// totalSecond--;
|
|
|
// if (totalSecond <= 0) {
|
|
|
// clearInterval(interval);
|
|
|
// wx.showToast({
|
|
|
// title: '活动已结束',
|
|
|
// });
|
|
|
// // 倒计时结束
|
|
|
// that.countDown();
|
|
|
// that.setData({
|
|
|
// days: '00',
|
|
|
// hours: '00',
|
|
|
// minutes: '00',
|
|
|
// seconds: '00',
|
|
|
// });
|
|
|
// }
|
|
|
// }.bind(this), 1000);
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
navbarTap: function (e) {
|
...
|
...
|
|