1. 程式人生 > >小程序上拉加載更多,onReachBottom

小程序上拉加載更多,onReachBottom

cti 程序 arch lda loading 數據 url 加載中 base

onReachBottom: function () {
console.log(1)
var that = this;
var path = ‘/listsearch/‘;
var datalist=null;
var url = app.globalData.http_base_url + path;
// 顯示加載圖標
wx.showLoading({
title: ‘玩命加載中‘,
})
app.globalData.currentPage ++;
var _currentPage = app.globalData.currentPage;
if(that.data.yearselect==undefined){
var selectyear="None"
}else{
var selectyear=that.data.yearselect
}
wx.request({
url:url,
data:{
searchdetail:that.data.SearchContent,
years:selectyear,
page:_currentPage
},
method:‘GET‘,
success:function(res){
console.log(res)
if(res.data.carbonlist.length==0){
wx.showLoading({
title: ‘暫無更多數據‘,
})
}else{
for (var i = 0; i < res.data.carbonlist.length; i++) {
that.data.carbonlist.push(res.data.carbonlist[i]);
}
console.log(that.data.carbonlist)
const pushData=that.data.carbonlist
// 設置數據
that.setData({
carbonlist: pushData
})
// 隱藏加載框
}
wx.hideLoading();

}
})
},

小程序上拉加載更多,onReachBottom