微信小程序上拉刷新数据

js:
data:{
rec_data:[],
//每页显示的行数:
pageSize: 5,
//页码(从1开始):
pageNum: 1,
isfromSearch: true,
}
onLoad: function (options) {
var that = this
that.getMyBadInfo(that.data.pageNum, that.data.pageSize)

},
onReachBottom: function () {
console.log(“下拉刷新”)
var that = this;
wx.showLoading({
title: ‘玩命加载中…’,
});
var pageNam = that.data.pageNum + 1;
var pageSize = that.data.pageSize;
console.log(“pageNam” + pageNam)
that.setData({
pageNum: pageNam,
isfromSearch: false
})
that.getMyBadInfo(pageNam, pageSize);
wx.hideLoading();
},
getMyBadInfo(pageNum, pageSize) {
var that = this
wx.request({
url: app.globalData.url + ‘你的接口?pageNum=’ + pageNum + “&&pageSize=” + pageSize,
header: app.globalData.header,
method: ‘GET’,
success: function (res) {
console.log(‘获取信息’, res.data)
let rec_data = res.data.data;
let allProject = [];
that.data.isfromSearch ? allProject = res.data.data : allProject = that.data.rec_data.concat(res.data.data)
that.setData({
rec_data: allProject,
})
}
})

},

你可能感兴趣的:(微信小程序上拉刷新数据)