diff --git a/packages/community/index/index.vue b/packages/community/index/index.vue index 1d5cff45..9468a05f 100644 --- a/packages/community/index/index.vue +++ b/packages/community/index/index.vue @@ -501,7 +501,6 @@ export default { }, async selectTab(index, item) { - console.log("🚀 ~ selectTab ~ item:", item) const isTabChange = this.selectedTab !== index; if (isTabChange) { this.page_num = 1; @@ -509,6 +508,12 @@ export default { // this.loadMoreText = "下拉加载后续10条,共计30条"; } this.selectedTab = index; + + // 如果不是切换tab,且已经没有更多数据,且已有数据,则不发送请求 + if (!isTabChange && !this.flag && this.infoList.length > 0) { + return; + } + const res = await request(apiArr.infoPage, "POST", { community_id: Number(uni.getStorageSync("changeCommData").id), announcement_category_id: item.id, @@ -529,10 +534,14 @@ export default { // 限制最多3页 this.flag = hasMore; + // 检查数据是否重复 + const isDataDuplicate = !isTabChange && this.infoList.length > 0 && newData.length > 0 && + this.infoList[this.infoList.length - 1].id === newData[0].id; + // 更新数据 if (isTabChange) { this.infoList = newData; - } else { + } else if (!isDataDuplicate) { this.infoList = this.infoList.concat(newData); }