加載第一頁留店商品數據
firstGetGiftData: function () {
this.setData({
page: 1
})
this.getGiftData("正在加載數據");
},
// 下拉加載留店數據
onReachBottom: function () {
console.log("下拉加載");
if (this.data.hasMoreData) {
this.getGiftData("加載更多數據")
}
},
// 獲取留店商品數據
getGiftData: function (message) {
var that = this;
this.setData({
ifstore: 1
})
var shop = wx.getStorageSync('shop');
var purchaseStorage = wx.getStorageSync('purchaseStorage');
console.log("留店商品");
util.reqAsync('shopOrder/storeRetentionList', {
page: that.data.page,
shopId: shop.id,
userId: wx.getStorageSync('scSysUser').id,
merchantId: that.data.merchantId,
rows: that.data.rows
}).then((res) => {
console.log("留店商品列表")
console.log(res);
// 數據增加加購數量,重置加購數量
for (let i = 0; i < res.data.data.length; i++) {
if (!res.data.data[i]["shopNum"]) {
res.data.data[i]["shopNum"] = 1;
res.data.data[i]["pitch"] = 0;
}
}
var purchaselistTem = that.data.purchase;
if (that.data.page == 1) {
purchaselistTem = [];
}
// debugger
if (res.data.data.length < that.data.rows) {
that.setData({
purchase: purchaselistTem.concat(res.data.data),
hasMoreData: false
})
}
else {
that.setData({
purchase: purchaselistTem.concat(res.data.data),
hasMoreData: true,
page: that.data.page + 1
})
}
}).catch((err) => {
console.log(err)
})
},