加载第一页留店商品数据 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) }) },