From 2f4d305dfaecf889090bf6ab98728f39b8ee83b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=AF=E5=8D=88=E5=AE=89=E5=BA=B7?= Date: Mon, 2 Aug 2021 23:57:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E9=A1=B5=20(#487)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 1.wx:修复首页线程池问题 * 1.wx:修复首页线程池问题 * 增加商品分页 --- litemall-wx/pages/category/category.js | 30 ++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/litemall-wx/pages/category/category.js b/litemall-wx/pages/category/category.js index 1638225f..97ef0395 100644 --- a/litemall-wx/pages/category/category.js +++ b/litemall-wx/pages/category/category.js @@ -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 +})