From b027a8f8ce4968fc5c81a77e54c67397c08fb92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Fri, 18 Jul 2025 15:44:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=20:=20=E4=BC=98=E5=8C=96=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=9A=84=E6=95=B0=E6=8D=AE=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/community/index/index.vue | 54 +++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/community/index/index.vue b/packages/community/index/index.vue index 604be385..c04534d8 100644 --- a/packages/community/index/index.vue +++ b/packages/community/index/index.vue @@ -112,7 +112,7 @@ -
下拉加载后续10条,共计30条
+
{{ loadMoreText }}
@@ -208,6 +208,7 @@ export default { page_size: 10, page_num: 1, flag: false, + loadMoreText: "下拉加载后续10条,共计30条", }; }, async onLoad(options) { @@ -248,7 +249,10 @@ export default { onReachBottom() { if (this.flag) { this.page_num++; - this.getCategoryList(); + const currentItem = this.categoryList[this.selectedTab]; + if (currentItem) { + this.selectTab(this.selectedTab, currentItem); + } } }, @@ -481,6 +485,12 @@ export default { }, async selectTab(index, item) { + const isTabChange = this.selectedTab !== index; + if (isTabChange) { + this.page_num = 1; + this.infoList = []; + this.loadMoreText = "下拉加载后续10条,共计30条"; + } this.selectedTab = index; console.log("选中的tab:", index); const res = await request(apiArr.infoPage, "POST", { @@ -491,20 +501,34 @@ export default { page_num: this.page_num, page_size: this.page_size, }); - if (res.rows && res.rows.length == this.page_size) { - this.flag = true; - } else { - this.flag = false; - } - res.rows = res.rows.map((item) => { - return { - ...item, - list_image: picUrl + item.list_image, - }; - }); - this.infoList.splice(0, this.infoList.length); - this.infoList = this.infoList.concat(res.rows); + // 处理数据 + const newData = res.rows.map((item) => ({ + ...item, + list_image: picUrl + item.list_image, + })); + + // 判断是否还有更多数据 + const hasMore = res.rows.length === this.page_size; + // 限制最多3页 + this.flag = hasMore; + + // 更新数据 + if (isTabChange) { + this.infoList = newData; + } else { + this.infoList = this.infoList.concat(newData); + } + + // 更新提示文本 + if (this.infoList.length > 10 && !hasMore) { + uni.showToast({ + title: "没有更多了", + icon: "none", + }); + } else { + this.loadMoreText = `下拉加载后续10条`; + } }, detail(e) {