Просмотр исходного кода

花卉宝-拉新人数下拉加载bug

ouyang 2 дней назад
Родитель
Сommit
5099abf2c1
1 измененных файлов с 28 добавлено и 14 удалено
  1. 28 14
      mallApp/src/pages/custom/dividendInvite.vue

+ 28 - 14
mallApp/src/pages/custom/dividendInvite.vue

@@ -3,7 +3,7 @@
   用途:mallApp 我的分红-拉新人数点击进入,展示下线客户及贡献分红
 -->
 <template>
-  <view class="invite-page app-content">
+  <view class="invite-page">
     <view class="search-bar">
       <view class="search-input-wrap">
         <text class="iconfont iconsearch search-icon"></text>
@@ -107,20 +107,33 @@ export default {
     this.loadInviteList()
   },
   methods: {
-    /** 拉取拉新客户列表 */
+    /**
+     * 拉取拉新客户列表
+     * 注意:勿给根节点加 app-content(全局 height:100vh + overflow 会吃掉页面滚动,onReachBottom 不触发)
+     */
     async loadInviteList() {
+      if (this.list.loading) {
+        return
+      }
       const seq = ++this.loadSeq
       this.list.loading = true
-      const res = await getDistributionInviteList({
-        page: this.list.page,
-        keyword: this.keyword,
-        sortField: this.sortField,
-        sortOrder: this.sortOrder
-      })
-      if (seq !== this.loadSeq) {
-        return
+      try {
+        const res = await getDistributionInviteList({
+          page: this.list.page,
+          keyword: this.keyword,
+          sortField: this.sortField,
+          sortOrder: this.sortOrder
+        })
+        if (seq !== this.loadSeq) {
+          return
+        }
+        this.completes(res)
+      } catch (e) {
+        if (seq === this.loadSeq) {
+          this.list.loading = false
+          this.list.finished = true
+        }
       }
-      this.completes(res)
     },
     onSearch() {
       this.resetList()
@@ -180,16 +193,17 @@ export default {
     uni.stopPullDownRefresh()
   },
   async onReachBottom() {
-    if (!this.list.finished) {
-      await this.loadInviteList()
+    if (this.list.finished || this.list.loading) {
+      return
     }
-    uni.stopPullDownRefresh()
+    await this.loadInviteList()
   }
 }
 </script>
 
 <style lang="scss" scoped>
 .invite-page {
+  /* 使用页面级滚动以触发 onReachBottom,勿套 app-content 的内部滚动 */
   min-height: 100vh;
   background: #f5f6f7;
   padding-bottom: 40upx;