Browse Source

积分中心完善

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

79
subpages/integralCentre/pages/index/index.js

@ -1,6 +1,11 @@
// subpages/integralCentre/pages/index/index.js // subpages/integralCentre/pages/index/index.js
import { pointsRecordlist } from '../../../../utils/api' import {
import { getTimestamp } from '../../../../utils/common' pointsRecordlist,
pointsRankinglist
} from '../../../../utils/api'
import {
getTimestamp
} from '../../../../utils/common'
Page({ Page({
/** /**
@ -9,7 +14,9 @@ Page({
data: { data: {
pageIndex: 1, pageIndex: 1,
pageSize: 10, pageSize: 10,
pointsRecordlist:[],//积分记录列表 pointsRecordlist: [], //积分记录列表
pointsRankinglist: [], //积分排行
rankingType: 0, //排名方式
selectTab: 'tab1', selectTab: 'tab1',
typeList: [{ //排名方式:0-周,1-月 typeList: [{ //排名方式:0-周,1-月
type: '0', type: '0',
@ -26,21 +33,31 @@ Page({
loadMoreType: 'none', loadMoreType: 'none',
loadMoreVisible: false, loadMoreVisible: false,
}, },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.pointsRecordlist(); //初始化加载积分记录列表
},
// tab 切换 // tab 切换
onTabChange(e) { onTabChange(e) {
this.setData({ this.setData({
pageIndex: 1,
pageSize: 10,
loadMoreType: 'none', loadMoreType: 'none',
loadMoreVisible: false, loadMoreVisible: false,
pointsRecordlist:[], pointsRecordlist: [],
pointsRankinglist: [],
selectTab: e.currentTarget.dataset.tab, selectTab: e.currentTarget.dataset.tab,
}) })
if (this.data.selectTab == 'tab1'){ if (this.data.selectTab == 'tab1') {
this.pointsRecordlist();//初始化加载积分记录列表 this.pointsRecordlist(); //初始化加载积分记录列表
}else{ } else {
console.log('积分排行') this.pointsRankinglist(); //积分排行
} }
}, },
onButtonChange: function (e) { // 排行切换
onButtonChange: function(e) {
const list = this.data.typeList const list = this.data.typeList
let that = this; let that = this;
list.forEach(item => { list.forEach(item => {
@ -52,14 +69,18 @@ Page({
}) })
that.setData({ that.setData({
typeList: list, typeList: list,
rankingType: e.currentTarget.dataset.type,
pageIndex: 1,
pageSize: 10,
timestamp: this.data.timestamp,
loadMoreType: 'none',
loadMoreVisible: false,
pointsRankinglist: [],
}) })
that.pointsRankinglist()
}, },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.pointsRecordlist();//初始化加载积分记录列表
},
// 获取事件详情 // 获取事件详情
pointsRecordlist() { pointsRecordlist() {
@ -67,10 +88,9 @@ Page({
const para = { const para = {
pageIndex: this.data.pageIndex, pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize, pageSize: this.data.pageSize,
timestamp: this.data.timestamp timestamp: this.data.timestamp,
} }
pointsRecordlist(para).then(res => { pointsRecordlist(para).then(res => {
console.log('积分记录列表', res)
that.setData({ that.setData({
pointsRecordlist: that.data.pointsRecordlist.concat(res.data), pointsRecordlist: that.data.pointsRecordlist.concat(res.data),
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none', 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}} {{item.name}}
</button> </button>
</view> </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">
<!-- 左边图片 --> <!-- 左边图片 -->
<view class="left-img"> <view class="left-img">
<image class="img-bg" src="../../images/first.png"></image> <image class="img-bg" wx:if="{{index == 0}}" src="../../images/first.png"></image>
<view class="list-number">1</view> <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>
<!-- 名字 --> <!-- 名字 -->
<view class="list-name">马大哈</view> <view class="list-name">{{item.nickName}}</view>
</view> </view>
<view class="right">890</view> <view class="right">{{item.points}}</view>
</view> </view>
</block> </block>
</view> </view>

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

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

Loading…
Cancel
Save