Commit 09361cc0 by 高淑倩

modify: 优化集点列表

parent c60b89dd
......@@ -8,29 +8,23 @@ wxService.page({
* 页面的初始数据
*/
data: {
pointList: [],
currentPointList: [], // 合并对象
countdown: null
pointList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
onLoad() { },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow() {
this.getPointList()
},
getPointList() {
......@@ -38,19 +32,17 @@ wxService.page({
title: '加载中'
})
wxService.get(`/sale/touchpoints/pointConsumptionActivity/findAllValidActivityList`).then(res => {
if(res) {
if (res) {
const { result, data } = res.data
if (result == 0) {
this.setData({
pointList: data
})
data.forEach(item=>{
data.forEach(item => {
let currentEndTime = (new Date(item.endTime)).getTime();
let currentTime = (new Date()).getTime();
let distancetime = currentEndTime - currentTime
let result = {
day:'00',
day: '00',
hour: '00',
min: '00',
sec: '00',
......@@ -72,12 +64,13 @@ wxService.page({
if (result.hour < 10) result.hour = '0' + result.hour;
if (result.day < 10) result.day = '0' + result.day;
}
item.countdown = result
this.setData({
countdown: result
})
pointList: data
}, () => {
this.getPointConsumptionCount(item.id)
})
})
}
}
})
......@@ -90,20 +83,22 @@ wxService.page({
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
let obj1 = {...this.data.pointList,...data}
let currentList = []
currentList.push(obj1)
console.log('-', currentList)
const { pointList } = this.data
pointList.forEach(item => {
if (item.id == activityId) {
item.surplusPoints = data.surplusPoints
this.setData({
currentPointList: currentList
pointList
})
}
})
}
}
})
},
handleDetail(e) {
const {id} = e.currentTarget.dataset
wxService.router(`/pages/pointDetail/pointDetail`).search({id})
const { id } = e.currentTarget.dataset
wxService.router(`/pages/pointDetail/pointDetail`).search({ id })
},
/**
* 生命周期函数--监听页面隐藏
......
<!--pages/pointList/pointList.wxml-->
<view class="point-list border_box">
<block wx:for="{{currentPointList}}" wx:key="item">
<view class="point border_box" data-id="{{item[0].id}}" bindtap="handleDetail">
<status-img img="{{item[0].listImage}}" />
<block wx:for="{{pointList}}" wx:key="item">
<view class="point border_box" data-id="{{item.id}}" bindtap="handleDetail">
<status-img img="{{item.listImage}}" />
<view class="progress weui-flex df-j--bt">
<view class="rate">进度:
<text class="rate-num">{{item.surplusPoints}}</text>
/ {{item[0].goal}}
/ {{item.goal}}
</view>
<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>
</block>
</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