فهرست منبع

fix: 边界判断,
删除无效的代码行

joe 4 سال پیش
والد
کامیت
2f8a380afd
1فایلهای تغییر یافته به همراه8 افزوده شده و 15 حذف شده
  1. 8 15
      view/xcx/pages/index/index.js

+ 8 - 15
view/xcx/pages/index/index.js

@@ -396,8 +396,6 @@ Page({
 
         let cindex = tabIndex - 1
         if (isReload) {
-            act.products = []
-            act.page = 1
             this.setData({
                 [`prodCates.children[${cindex}].page`]: 1,
                 [`prodCates.children[${cindex}].products`]: []
@@ -408,8 +406,6 @@ Page({
             [`prodCates.children[${cindex}].loading`]: true,
             [`prodCates.children[${cindex}].loadTitle`]: ''
         });
-        act.loading = true
-        act.loadTitle = ''
 
         var that = this;
         getProductslist({
@@ -431,20 +427,17 @@ Page({
                     price: item.price,
                     vip_price: item.vip_price,
                     sales: item.sales,
-                    isShow: counter / 2 - act.aboveShowRowIndex <= 2 * this.data.rowCacheNum, // 是否显示
+                    isShow: (counter / 2 - act.aboveShowRowIndex) <= 2 * this.data.rowCacheNum, // 是否显示
                 })
             })
-            let firstPage = act.products.length <= 0
-            act.products = app.SplitArray(list, act.products)
-            act.loaded = list.length < PAGE_LIMIT
-            act.loading = false
-            act.loadTitle = act.loaded ? '已全部加载' : '加载更多'
-            act.page += 1
+            // console.log('list.length:', list.length, 'res.data.length:', res.data.length)
+            let products = app.SplitArray(list, act.products)
+            let loaded = list.length < PAGE_LIMIT
             that.setData({
-                [`prodCates.children[${cindex}].loaded`]: act.loaded,
+                [`prodCates.children[${cindex}].loaded`]: loaded,
                 [`prodCates.children[${cindex}].loading`]: false,
-                [`prodCates.children[${cindex}].loadTitle`]: act.loaded ? '已全部加载' : '加载更多',
-                [`prodCates.children[${cindex}].products`]: act.products,
+                [`prodCates.children[${cindex}].loadTitle`]: loaded ? '已全部加载' : '加载更多',
+                [`prodCates.children[${cindex}].products`]: products,
                 [`prodCates.children[${cindex}].page`]: act.page + 1
             });
         }).catch(err => {
@@ -644,7 +637,7 @@ Page({
     },
 
     onPageScroll: throttle(function (obj) {
-        if (this.data.activeTabIndex <= 0 || this.data.activeTabIndex >= this.data.prodCates.children.length) {
+        if (this.data.activeTabIndex <= 0 || this.data.activeTabIndex > this.data.prodCates.children.length) {
             return
         }