小程序上拉加载更多,onReachBottom

时间:2018-11-09 19:30:35   收藏:0   阅读:2222

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();

}
})
},

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!