bayi преди 2 години
родител
ревизия
093ea85401
променени са 2 файла, в които са добавени 21 реда и са изтрити 6 реда
  1. 9 3
      mixins/reachBottom.js
  2. 12 3
      pages/index/index.js

+ 9 - 3
mixins/reachBottom.js

@@ -4,10 +4,15 @@ module.exports = Behavior({
         list: [],
         grade: '',
         pageNo: 1,
-        pageSize: 20,
         totalSize: 0,
         noMoreData: false, // 无更多数据置为 false
     },
+    properties: {
+        pageSize: {
+            type: Number,
+            value: 10
+        }
+    },
     methods: {
         async getData(fn, args) {
             if (this.data.noMoreData) {
@@ -15,7 +20,7 @@ module.exports = Behavior({
             }
             let params = {
                 pageNo: this.data.pageNo,
-                pageSize: 20,
+                pageSize: this.properties.pageSize,
                 ...args
             }
             // 加载状态,用于页面中控制加载动画的显示
@@ -45,13 +50,14 @@ module.exports = Behavior({
 
         },
         resetData() {
+            console.log("触发", this.data.loading);
             if (this.data.loading) return; // 如果接口已经在请求中,则不重置数据,防止用户持续下拉刷新
             this.setData({
                 loading: false,
                 list: [],
                 pageNo: 1,
                 totalSize: 0,
-                noMoreData: true,
+                noMoreData: false,
             })
             this.loadMore(); // 调用页面中的接口请求方法
         },

+ 12 - 3
pages/index/index.js

@@ -42,9 +42,17 @@ Page({
         this.storeBindings.destroyStoreBindings()
     },
     loadMore() {
-        this.getData(getHotrecommendList, {
-            grade: this.data.userInfo.grade
-        })
+        console.log(this.data.currentType, 'zzz');
+        if (this.data.currentType == '1') {
+            this.getData(getHotrecommendList, {
+                grade: this.data.userInfo.grade
+            })
+        } else if (this.data.currentType == '2') {
+            this.getData(getHotrecommendList, {
+                grade: 'PRESCHOOL'
+            })
+        }
+
     },
     onReachBottom() {
         console.log('触底');
@@ -57,6 +65,7 @@ Page({
             this.setData({
                 currentType: target.dataset.type
             })
+            this.resetData()
         }
     },