소스 검색

[捉药师] 修复下拉加载触发失效问题

tangyuanwang 1 주 전
부모
커밋
e993e83000
1개의 변경된 파일19개의 추가작업 그리고 8개의 파일을 삭제
  1. 19 8
      pages/notice/list.vue

+ 19 - 8
pages/notice/list.vue

@@ -75,15 +75,26 @@ export default {
 				});
 			}, 300);
 		},
-	  handleScroll() {
-		const observer = uni.createIntersectionObserver(this);
-		observer.relativeToViewport({bottom: 100}).observe('.loading-status', (res) => {
-		  if (res.intersectionRatio > 0 && !this.loading && !this.noMore) {
-			this.notice_system_list();
-			this.page++;
+		handleScroll() {
+		  // 先销毁之前的观察器
+		  if (this.observer) {
+			this.observer.disconnect();
+			this.observer = null;
 		  }
-		});
-	  },
+		  // 创建新的观察器
+		  this.observer = uni.createIntersectionObserver(this);
+		  this.observer.relativeToViewport({
+			bottom: 50 // 调整为更小的阈值,提高触发灵敏度
+		  }).observe('.loading-status', (res) => {
+			if (res.intersectionRatio > 0 && !this.loading && !this.noMore) {
+			  this.loading = true; // 添加加载状态
+			  this.notice_system_list().finally(() => {
+				this.loading = false;
+			  });
+			  this.page++;
+			}
+		  });
+		},
 		formatTimestamp(timestamp) {
 			if (timestamp) {
 				timestamp = timestamp * 1000;