Unverified Commit 2f4d305d authored by 端午安康's avatar 端午安康 Committed by GitHub
Browse files

小程序增加商品分页 (#487)

* 1.wx:修复首页线程池问题

* 1.wx:修复首页线程池问题

* 增加商品分页
parent 14b6d0e9
......@@ -11,7 +11,8 @@ Page({
scrollTop: 0,
scrollHeight: 0,
page: 1,
limit: 10
limit: 10,
pages:1, //总页数
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
......@@ -89,6 +90,21 @@ Page({
onHide: function() {
// 页面隐藏
},
//触底开始下一页
onReachBottom: function () {
var that=this;
var pagenum = that.data.page + 1; //获取当前页数并+1
if(pagenum <=that.data.pages){
that.setData({
page: pagenum, //更新当前页数
})
that.getGoodsList();//重新调用请求获取下一页数据
}else{
util.showErrorToast("已经是最后一页了");
}
},
getGoodsList: function() {
var that = this;
......@@ -98,8 +114,12 @@ Page({
limit: that.data.limit
})
.then(function(res) {
var arr1 = that.data.goodsList; //从data获取当前datalist数组
var arr2 = res.data.list; //从此次请求返回的数据中获取新数组
arr1 = arr1.concat(arr2); //合并数组
that.setData({
goodsList: res.data.list,
goodsList: arr1,
pages: res.data.pages //得到总页数
});
});
},
......@@ -123,9 +143,11 @@ Page({
});
}
this.setData({
id: event.currentTarget.dataset.id
id: event.currentTarget.dataset.id,
page:1, //从第一页开始查
goodsList:[]
});
this.getCategoryInfo();
}
})
\ No newline at end of file
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment