|
|
// pages/groupBuy/groupBuy.js
|
|
|
const app = getApp()
|
|
|
const time=require('../../../utils/util.js');
|
|
|
const time = require('../../../utils/util.js');
|
|
|
|
|
|
Page({
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -13,7 +14,13 @@ |
|
|
groupList: [],
|
|
|
recordList: [],
|
|
|
pay_info: [],
|
|
|
is_agree: false
|
|
|
is_agree: false,
|
|
|
countDownList: [],
|
|
|
actEndTimeList: [],
|
|
|
goodsList: [{
|
|
|
actEndTime: ''
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
//tab切换
|
...
|
...
|
@@ -62,10 +69,15 @@ |
|
|
|
|
|
// 长按复制
|
|
|
copy: function(e) {
|
|
|
console.log(e)
|
|
|
var index=e.currentTarget.dataset.index
|
|
|
var recordList = this.data.recordList
|
|
|
var chargenum = recordList[index].redeem_code
|
|
|
var that = this;
|
|
|
wx.setClipboardData({
|
|
|
data: that.data.chargenum,
|
|
|
data: chargenum,
|
|
|
success: function(res) {
|
|
|
console.log(res)
|
|
|
wx.showToast({
|
|
|
title: '复制成功',
|
|
|
});
|
...
|
...
|
@@ -73,6 +85,7 @@ |
|
|
});
|
|
|
},
|
|
|
|
|
|
|
|
|
//参与的组团
|
|
|
takeGroup() {
|
|
|
let url = '/portal/Group/group_list'
|
...
|
...
|
@@ -83,9 +96,18 @@ |
|
|
"XX-Token": wx.getStorageSync('token')
|
|
|
}
|
|
|
app.post(url, params, header).then((res) => {
|
|
|
console.log(res)
|
|
|
var groupList = res.list
|
|
|
var goodsList = this.data.goodsList
|
|
|
console.log(groupList.length)
|
|
|
for (var i = 0; i < groupList.length; i++) {
|
|
|
goodsList.push({
|
|
|
actEndTime:''
|
|
|
})
|
|
|
goodsList[i].actEndTime = groupList[i].over_time
|
|
|
}
|
|
|
this.setData({
|
|
|
groupList: res.list
|
|
|
groupList: res.list,
|
|
|
goodsList: goodsList
|
|
|
})
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -100,12 +122,10 @@ |
|
|
"XX-Token": wx.getStorageSync('token')
|
|
|
}
|
|
|
app.post(url, params, header).then((res) => {
|
|
|
console.log(res)
|
|
|
var recordList= res.list
|
|
|
for(var i=0;i<recordList.length;i++){
|
|
|
var recordList = res.list
|
|
|
for (var i = 0; i < recordList.length; i++) {
|
|
|
var chargeTime = recordList[i].create_time
|
|
|
chargeTime = time.formatTimeTwo(chargeTime, 'Y-M-D')
|
|
|
console.log(chargeTime)
|
|
|
recordList[i].create_time = chargeTime
|
|
|
}
|
|
|
this.setData({
|
...
|
...
|
@@ -122,7 +142,7 @@ |
|
|
"XX-Token": wx.getStorageSync('token')
|
|
|
}
|
|
|
app.post(url, params, header).then((res) => {
|
|
|
// console.log(res)
|
|
|
console.log('团购配置人数加个:',res)
|
|
|
this.setData({
|
|
|
pay_info: res.info
|
|
|
})
|
...
|
...
|
@@ -201,6 +221,50 @@ |
|
|
|
|
|
},
|
|
|
|
|
|
timeFormat(param) { //小于10的格式化函数
|
|
|
return param < 10 ? '0' + param : param;
|
|
|
},
|
|
|
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;
|
|
|
// 获取天、时、分、秒
|
|
|
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'
|
|
|
}
|
|
|
}
|
|
|
countDownArr.push(obj);
|
|
|
})
|
|
|
// 渲染,然后每隔一秒执行一次倒计时函数
|
|
|
this.setData({
|
|
|
countDownList: countDownArr
|
|
|
})
|
|
|
setTimeout(this.countDown, 1000);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
...
|
...
|
@@ -208,6 +272,17 @@ |
|
|
this.takeGroup()
|
|
|
this.record()
|
|
|
this.PayDetail()
|
|
|
let endTimeList = [];
|
|
|
// 将活动的结束时间参数提成一个单独的数组,方便操作
|
|
|
this.data.goodsList.forEach(o => {
|
|
|
endTimeList.push(o.actEndTime)
|
|
|
})
|
|
|
this.setData({
|
|
|
actEndTimeList: endTimeList
|
|
|
});
|
|
|
// 执行倒计时函数
|
|
|
this.countDown();
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
|