作者 刘晓艳

倒计时

... ... @@ -70,7 +70,7 @@
// 长按复制
copy: function(e) {
console.log(e)
var index=e.currentTarget.dataset.index
var index = e.currentTarget.dataset.index
var recordList = this.data.recordList
var chargenum = recordList[index].redeem_code
var that = this;
... ... @@ -86,32 +86,6 @@
},
//参与的组团
takeGroup() {
let url = '/portal/Group/group_list'
let params = {
page: this.data.page
}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((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,
goodsList: goodsList
})
})
},
//成交记录
record() {
let url = '/portal/Group/group_complete'
... ... @@ -142,7 +116,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
})
... ... @@ -217,22 +191,60 @@
icon: 'none'
})
}
},
//参与的组团
takeGroup() {
let url = '/portal/Group/group_list'
let params = {
page: this.data.page
}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((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 = '2018-12-27 13:59:44'
goodsList[i].actEndTime = groupList[i].over_time
}
goodsList.pop()
let endTimeList = [];
goodsList.forEach(o => {
endTimeList.push(o.actEndTime)
})
this.setData({
actEndTimeList: endTimeList
});
// console.log(endTimeList)
this.countDown();
this.setData({
groupList: res.list,
goodsList: goodsList
})
})
},
timeFormat(param) { //小于10的格式化函数
return param < 10 ? '0' + param : param;
},
countDown() { //倒计时函数
// 获取当前时间,同时得到活动结束时间数组
let newTime = new Date().getTime();
let endTimeList = this.data.actEndTimeList;
// console.log(endTimeList)
let countDownArr = [];
// 对结束时间进行处理渲染到页面
endTimeList.forEach(o => {
let endTime = new Date(o).getTime();
// console.log(endTime)
let obj = null;
// 如果活动未结束,对时间进行处理
if (endTime - newTime > 0) {
... ... @@ -258,10 +270,21 @@
}
countDownArr.push(obj);
})
var groupList = this.data.groupList
for (var i = 0; i < groupList.length; i++) {
for (var j = 0; j < countDownArr.length; j++) {
groupList[i].hou = countDownArr[i].hou
groupList[i].min = countDownArr[i].min
groupList[i].sec = countDownArr[i].sec
}
}
// 渲染,然后每隔一秒执行一次倒计时函数
this.setData({
countDownList: countDownArr
countDownList: countDownArr,
groupList: groupList
})
// console.log(this.data.countDownList)
setTimeout(this.countDown, 1000);
},
... ... @@ -272,16 +295,7 @@
this.takeGroup()
this.record()
this.PayDetail()
let endTimeList = [];
// 将活动的结束时间参数提成一个单独的数组,方便操作
this.data.goodsList.forEach(o => {
endTimeList.push(o.actEndTime)
})
this.setData({
actEndTimeList: endTimeList
});
// 执行倒计时函数
this.countDown();
},
... ...
... ... @@ -63,24 +63,37 @@
<view class='list_info_item'>
剩余
<!-- <text>{{item.surplus_time}}</text> -->
<text wx:for="{{countDownList}}" wx:key="countDownList">
<text class=''>{{item.hou}}</text>
<text>:</text>
<text class=''>{{item.min}}</text>
<text>:</text>
<text class=' '>{{item.sec}}</text>
<!-- <text wx:for="{{countDownList}}" wx:key="countDownList">
<text class=''>{{item.hou}}</text>
<text>:</text>
<text class=''>{{item.min}}</text>
<text>:</text>
<text class=' '>{{item.sec}}</text>
</text>
</text> -->
结束
</view>
</view>
<!--
<view class='tui-countdown-content' wx:for="{{countDownList}}" wx:key="countDownList">
<!-- <view class='tui-countdown-content' wx:for="{{countDownList}}" wx:key="countDownList">
剩余
<!-- <text class='tui-conutdown-box'>{{item.day}}</text>天
<text class='tui-conutdown-box'>{{item.day}}</text>天
<text class='tui-conutdown-box'>{{item.hou}}</text>时
<text class='tui-conutdown-box'>{{item.min}}</text>分
<text class='tui-conutdown-box tui-countdown-bg'>{{item.sec}}</text>秒
</view> -->
</view> -->
</view>
<view>
<view class='user_info_box'>
... ...
... ... @@ -107,12 +107,12 @@ Page({
*/
onShareAppMessage: function() {
let that = this;
var id = this.data.id
console.log(id)
var group_id = this.data.id
console.log(group_id)
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title: '科学队长', // 默认是小程序的名称(可以写slogan等)
path: '/pages/my/takeGroupBuy/takeGroupBuy?id=' + id, // 默认是当前页面,必须是以‘/’开头的完整路径
path: '/pages/my/takeGroupBuy/takeGroupBuy?group_id=' + group_id,// 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function(res) {
if (res.errMsg == 'shareAppMessage:ok') {}
... ...
... ... @@ -40,6 +40,7 @@ Page({
})
})
},
//团购规则
getRule() {
let url = '/wxapp/public/arc_group'
... ... @@ -126,6 +127,21 @@ Page({
})
},
checkMobile(){
let url = '/portal/Index/check_mobile'
let params = {}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
if (res.is_binding==0){
wx.navigateTo({
url: '/pages/index/phone-code/phone-code',
})
}
})
},
/**
* 生命周期函数--监听页面加载
... ... @@ -153,6 +169,7 @@ Page({
})
}
})
// this.checkMobile()
},
/**
... ... @@ -166,7 +183,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.checkMobile()
},
/**
... ...
... ... @@ -90,7 +90,7 @@
<text class='service_info' catchtap='serviceProtocol'>服务协议</text>
</view>
<view class='service_btn_box'>
<view>单价:¥{{take_info.price}}</view>
<view>单价:¥{{group_info.price}}</view>
<view class='pay_btn' bindtap='goPay'>参与并支付</view>
</view>
</view>
... ...
... ... @@ -36,7 +36,7 @@
"list": []
},
"miniprogram": {
"current": 2,
"current": 3,
"list": [
{
"id": -1,
... ... @@ -53,7 +53,14 @@
{
"id": -1,
"name": "share",
"pathName": "pages/my/cardIntroduction/cardIntroduction"
"pathName": "pages/my/cardIntroduction/cardIntroduction",
"query": ""
},
{
"id": -1,
"name": "group",
"pathName": "pages/my/groupBuy/groupBuy",
"query": "group_id=60"
}
]
}
... ...