Commit 09361cc0 by 高淑倩

modify: 优化集点列表

parent c60b89dd
...@@ -8,29 +8,23 @@ wxService.page({ ...@@ -8,29 +8,23 @@ wxService.page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
pointList: [], pointList: []
currentPointList: [], // 合并对象
countdown: null
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad() { },
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady() {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow() {
this.getPointList() this.getPointList()
}, },
getPointList() { getPointList() {
...@@ -38,19 +32,17 @@ wxService.page({ ...@@ -38,19 +32,17 @@ wxService.page({
title: '加载中' title: '加载中'
}) })
wxService.get(`/sale/touchpoints/pointConsumptionActivity/findAllValidActivityList`).then(res => { wxService.get(`/sale/touchpoints/pointConsumptionActivity/findAllValidActivityList`).then(res => {
if(res) { if (res) {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
this.setData({
pointList: data data.forEach(item => {
})
data.forEach(item=>{
let currentEndTime = (new Date(item.endTime)).getTime(); let currentEndTime = (new Date(item.endTime)).getTime();
let currentTime = (new Date()).getTime(); let currentTime = (new Date()).getTime();
let distancetime = currentEndTime - currentTime let distancetime = currentEndTime - currentTime
let result = { let result = {
day:'00', day: '00',
hour: '00', hour: '00',
min: '00', min: '00',
sec: '00', sec: '00',
...@@ -65,21 +57,22 @@ wxService.page({ ...@@ -65,21 +57,22 @@ wxService.page({
result.hour = Math.floor((distancetime / 1000 / 60 / 60) % 24); result.hour = Math.floor((distancetime / 1000 / 60 / 60) % 24);
result.day = Math.floor((distancetime / 1000 / 60 / 60) / 24); result.day = Math.floor((distancetime / 1000 / 60 / 60) / 24);
result.isOver = false; result.isOver = false;
if (result.ms < 10) result.ms = result.ms; if (result.ms < 10) result.ms = result.ms;
if (result.sec < 10) result.sec = '0' + result.sec; if (result.sec < 10) result.sec = '0' + result.sec;
if (result.min < 10) result.min = '0' + result.min; if (result.min < 10) result.min = '0' + result.min;
if (result.hour < 10) result.hour = '0' + result.hour; if (result.hour < 10) result.hour = '0' + result.hour;
if (result.day < 10) result.day = '0' + result.day; if (result.day < 10) result.day = '0' + result.day;
} }
item.countdown = result
this.setData({ this.setData({
countdown: result pointList: data
}, () => {
this.getPointConsumptionCount(item.id)
}) })
this.getPointConsumptionCount(item.id)
}) })
} }
} }
}) })
}, },
getPointConsumptionCount(activityId) { getPointConsumptionCount(activityId) {
...@@ -90,20 +83,22 @@ wxService.page({ ...@@ -90,20 +83,22 @@ wxService.page({
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
wx.hideLoading() wx.hideLoading()
let obj1 = {...this.data.pointList,...data} const { pointList } = this.data
let currentList = [] pointList.forEach(item => {
currentList.push(obj1) if (item.id == activityId) {
console.log('-', currentList) item.surplusPoints = data.surplusPoints
this.setData({ this.setData({
currentPointList: currentList pointList
})
}
}) })
} }
} }
}) })
}, },
handleDetail(e) { handleDetail(e) {
const {id} = e.currentTarget.dataset const { id } = e.currentTarget.dataset
wxService.router(`/pages/pointDetail/pointDetail`).search({id}) wxService.router(`/pages/pointDetail/pointDetail`).search({ id })
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
......
<!--pages/pointList/pointList.wxml--> <!--pages/pointList/pointList.wxml-->
<view class="point-list border_box"> <view class="point-list border_box">
<block wx:for="{{currentPointList}}" wx:key="item"> <block wx:for="{{pointList}}" wx:key="item">
<view class="point border_box" data-id="{{item[0].id}}" bindtap="handleDetail"> <view class="point border_box" data-id="{{item.id}}" bindtap="handleDetail">
<status-img img="{{item[0].listImage}}" /> <status-img img="{{item.listImage}}" />
<view class="progress weui-flex df-j--bt"> <view class="progress weui-flex df-j--bt">
<view class="rate">进度: <view class="rate">进度:
<text class="rate-num">{{item.surplusPoints}}</text> <text class="rate-num">{{item.surplusPoints}}</text>
/ {{item[0].goal}} / {{item.goal}}
</view> </view>
<view class="time-out">距离结束时间: <view class="time-out">距离结束时间:
<text class="time">{{countdown.day}}天{{countdown.hour}}小时</text> <text class="time">{{item.countdown.day}}天{{item.countdown.hour}}小时</text>
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment