97 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const App = getApp();
Page({
data: {
currentData : 0,
page: 1,
dataList: [],
datalist:[],
datalistTwo:[],
rank:[],
noMore: false, // 没有更多数据
isLoading: true, // 是否正在加载中
},
onLoad: function() {
let _this = this;
// 获取活动列表
_this.getRankList(false, 1);
},
//点击切换滑块index赋值
checkCurrent:function(e){
const that = this;
if (that.data.currentData === e.target.dataset.current){
return false;
}else{
that.setData({
currentData: e.target.dataset.current,
dataList :[],
datalist :[],
datalistTwo :[],
page:1,
last_page:2
})
that.getRankList(false, 1);
}
},
/**
* Api获取活动列表
*/
getRankList(isPage, pageNum) {
let _this = this;
wx.showLoading();
App._post_form('footchina/getRankUser', {
page: pageNum || 1,
user_id: wx.getStorageSync('user_id'),
type:_this.data.currentData
}, result => {
console.log(result);
wx.hideLoading();
let resList = result.data.data,list = _this.data.dataList;
var rank = result.data.data.rank;
if (isPage == true) {
_this.setData({
last_page:resList.list.last_page,
dataList: list.concat(resList.list.data),
isLoading: false,
rank:rank,
// datalistTwo:this.data.datalist.slice(3),
datalistTwo:(list.concat(resList.list.data)).slice(3),
});
} else {
_this.setData({
dataList: resList.list.data,
datalistTwo:resList.list.data.slice(3),
isLoading: false,
rank:rank
});
}
});
},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onShareAppMessage: function() {},
/**
* 下拉到底加载数据
*/
onReachBottom() {
let _this = this;
// 已经是最后一页
if (_this.data.page >= _this.data.last_page) {
_this.setData({
noMore: true
});
return false;
}
// 加载下一页列表
_this.getRankList(true, ++_this.data.page);
}
});