pages 里面的 product 文件夹
product .wxml
product .js
pageGoods: function () {
var _this = this;
util.my_ajax({
url: 你的接口,
data: {
current: _this.data.page, // 页码
limit: 10, // 每次出来的数量
userId: _this.data.userId, // 你需要传的参数
status: ‘SALE’, // 你需要传的参数
activityStatus: _this.data.activityStatus // 你需要传的参数
},
success: function (response) {
console.log(response.items)
_this.setData({
total: response.total // 所有数据的总数量
})
if (_this.data.pageGoods.length > 0) {
_this.setData({
pageGoods: _this.data.pageGoods.concat(response.items)
})
} else {
_this.setData({
pageGoods: response.items
})
}
}
});
},
// 上拉加载
onReachBottom: function () {
var _this = this
var current = _this.data.page
if (current <= Math.ceil(_this.data.total / 10)) {
current++
_this.setData({
page: current
})
_this.pageGoods();
} else {
wx.showToast({
title: '到底了',
})
return false
}
},