You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
4.0 KiB
191 lines
4.0 KiB
// subpages/integralCentre/pages/index/index.js
|
|
import {
|
|
pointsRecordlist,
|
|
pointsRankinglist
|
|
} from '../../../../utils/api'
|
|
import {
|
|
getTimestamp
|
|
} from '../../../../utils/common'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
pointsRecordlist: [], //积分记录列表
|
|
pointsRankinglist: [], //积分排行
|
|
rankingType: 0, //排名方式
|
|
selectTab: 'tab1',
|
|
typeList: [{ //排名方式:0-周,1-月
|
|
type: '0',
|
|
name: '本周排名',
|
|
select: true
|
|
},
|
|
{
|
|
type: '1',
|
|
name: '本月排名',
|
|
select: false
|
|
}
|
|
],
|
|
timestamp: getTimestamp(),
|
|
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 {
|
|
this.pointsRankinglist(); //积分排行
|
|
}
|
|
},
|
|
// 排行切换
|
|
onButtonChange: function(e) {
|
|
const list = this.data.typeList
|
|
let that = this;
|
|
list.forEach(item => {
|
|
if (item.type === e.currentTarget.dataset.type) {
|
|
item.select = true
|
|
} else {
|
|
item.select = false
|
|
}
|
|
})
|
|
that.setData({
|
|
typeList: list,
|
|
rankingType: e.currentTarget.dataset.type,
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
timestamp: this.data.timestamp,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
pointsRankinglist: [],
|
|
})
|
|
|
|
that.pointsRankinglist()
|
|
},
|
|
|
|
|
|
// 获取事件详情
|
|
pointsRecordlist() {
|
|
let that = this
|
|
const para = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp,
|
|
}
|
|
pointsRecordlist(para).then(res => {
|
|
that.setData({
|
|
pointsRecordlist: that.data.pointsRecordlist.concat(res.data),
|
|
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
|
|
})
|
|
}).catch(err => {
|
|
that.setData({
|
|
loadMoreType: 'none',
|
|
pointsRecordlist: []
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
|
|
// 积分记录-积分排行接口
|
|
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)
|
|
})
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
this.setData({
|
|
loadMoreVisible: true
|
|
})
|
|
if (this.data.loadMoreType === 'loading') {
|
|
console.log('加载翻页')
|
|
this.setData({
|
|
pageNo: this.data.pageNo + 1,
|
|
pageSize: this.data.pageSize,
|
|
pageIndex: getTimestamp()
|
|
})
|
|
this.pointsRecordlist()
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
}
|
|
})
|