Browse Source

积分中心完善

master
zhaoyongnian 5 years ago
parent
commit
a96f9afc98
  1. 67
      subpages/integralCentre/pages/index/index.js
  2. 13
      subpages/integralCentre/pages/index/index.wxml
  3. 2
      subpages/integralCentre/pages/index/index.wxss

67
subpages/integralCentre/pages/index/index.js

@ -1,6 +1,11 @@
// subpages/integralCentre/pages/index/index.js
import { pointsRecordlist } from '../../../../utils/api'
import { getTimestamp } from '../../../../utils/common'
import {
pointsRecordlist,
pointsRankinglist
} from '../../../../utils/api'
import {
getTimestamp
} from '../../../../utils/common'
Page({
/**
@ -10,6 +15,8 @@ Page({
pageIndex: 1,
pageSize: 10,
pointsRecordlist: [], //积分记录列表
pointsRankinglist: [], //积分排行
rankingType: 0, //排名方式
selectTab: 'tab1',
typeList: [{ //排名方式:0-周,1-月
type: '0',
@ -26,20 +33,30 @@ Page({
loadMoreType: 'none',
loadMoreVisible: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.pointsRecordlist(); //初始化加载积分记录列表
},
// tab 切换
onTabChange(e) {
this.setData({
pageIndex: 1,
pageSize: 10,
loadMoreType: 'none',
loadMoreVisible: false,
pointsRecordlist: [],
pointsRankinglist: [],
selectTab: e.currentTarget.dataset.tab,
})
if (this.data.selectTab == 'tab1') {
this.pointsRecordlist(); //初始化加载积分记录列表
} else {
console.log('积分排行')
this.pointsRankinglist(); //积分排行
}
},
// 排行切换
onButtonChange: function(e) {
const list = this.data.typeList
let that = this;
@ -52,25 +69,28 @@ Page({
})
that.setData({
typeList: list,
rankingType: e.currentTarget.dataset.type,
pageIndex: 1,
pageSize: 10,
timestamp: this.data.timestamp,
loadMoreType: 'none',
loadMoreVisible: false,
pointsRankinglist: [],
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.pointsRecordlist();//初始化加载积分记录列表
that.pointsRankinglist()
},
// 获取事件详情
pointsRecordlist() {
let that = this
const para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
timestamp: this.data.timestamp
timestamp: this.data.timestamp,
}
pointsRecordlist(para).then(res => {
console.log('积分记录列表', res)
that.setData({
pointsRecordlist: that.data.pointsRecordlist.concat(res.data),
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
@ -84,6 +104,31 @@ Page({
})
},
// 积分记录-积分排行接口
pointsRankinglist() {
let that = this
const para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
timestamp: this.data.timestamp,
rankingType: this.data.rankingType, //排名方式:0-周,1-月
}
pointsRankinglist(para).then(res => {
that.setData({
pointsRankinglist: that.data.pointsRankinglist.concat(res.data),
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
})
}).catch(err => {
that.setData({
loadMoreType: 'none',
pointsRankinglist: []
})
console.log(err)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

13
subpages/integralCentre/pages/index/index.wxml

@ -32,17 +32,20 @@
{{item.name}}
</button>
</view>
<view class="ph-list">
<view class="ph-list" wx:for-index="index" wx:for-item="item" wx:key="index" wx:for="{{pointsRankinglist}}" data-id="{{item.id}}">
<view class="left">
<!-- 左边图片 -->
<view class="left-img">
<image class="img-bg" src="../../images/first.png"></image>
<view class="list-number">1</view>
<image class="img-bg" wx:if="{{index == 0}}" src="../../images/first.png"></image>
<image class="img-bg" wx:elif="{{index == 1}}" src="../../images/second.png"></image>
<image class="img-bg" wx:elif="{{index == 2}}" src="../../images/third.png"></image>
<image class="img-bg" wx:else src="../../images/fourth.png"></image>
<view class="list-number">{{index+1}}</view>
</view>
<!-- 名字 -->
<view class="list-name">马大哈</view>
<view class="list-name">{{item.nickName}}</view>
</view>
<view class="right">890</view>
<view class="right">{{item.points}}</view>
</view>
</block>
</view>

2
subpages/integralCentre/pages/index/index.wxss

@ -188,7 +188,7 @@ button::after {
}
.left .left-img {
position: fixed;
position: relative;
width: 41rpx;
height: 38rpx;
}

Loading…
Cancel
Save