小程式上拉載入更多,onReachBottom
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();
}
})
},