小程序端
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
wx.showToast({
title: '加载中',
icon:'loading'
})
var length = this.data.data.length;
// console.log(length)
var length = length+5
var is = this;
// console.log(length)
wx.request({
url: 'http://www.exam.com/index.php/api/shows',
data:{
length:length
},
success:function(res){
// console.log(res.data.data.data)
var data = (res.data.data.data);
is.setData({
data:data
})
if(length > res.data.data.data.length){
wx.showToast({
title: '没有更多数据啦~',
icon:'none'
})
}
}
})
},
后端接口代码
public function show()
{
$data = HouseModel::paginate(5);
return json_encode(['code'=>200,'msg'=>'查询成功','data'=>$data]);
}
public function shows()
{
$length = \request()->get('length');
$data = HouseModel::paginate($length);
return json_encode(['code'=>200,'msg'=>'查询成功','data'=>$data]);
}