From 1f1b86feb3cbe33fe8dd19f87d550da8d5be3d2a Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Thu, 3 Sep 2026 09:56:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3/=E5=9C=BA=E9=A6=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=94=B9=E7=94=A8=E9=A1=B5=E9=9D=A2=E7=BA=A7?= =?UTF-8?q?=E8=A7=A6=E5=BA=95=E5=8A=A0=E8=BD=BD=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=9B=B4=E5=A4=9A=E6=B0=B8=E4=B8=8D=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scroll-view 无固定高度导致 scrolltolower 永不触发,列表卡在首页 10 条;改为普通 view + onReachBottom 页面级触底 - 新增请求序号取代机制:翻页在途时搜索不再被吞、过期响应整体丢弃 - 本页不足一页即钉住 total,防止翻页途中数据变动导致无限空翻 Co-Authored-By: Claude Fable 5 --- pages/discount/discount.vue | 20 +++++++++++++++----- pages/venue/venue.vue | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/pages/discount/discount.vue b/pages/discount/discount.vue index 7f57d56..14a1b6b 100644 --- a/pages/discount/discount.vue +++ b/pages/discount/discount.vue @@ -16,7 +16,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -52,7 +52,8 @@ export default { lng: '', lat: '', loadStatus: 'loadmore', - hasScrolled: false + hasScrolled: false, + reqSeq: 0 } }, onLoad() { @@ -72,9 +73,14 @@ export default { .finally(() => this.loadList()) } }, + // xuchao: 改用页面级触底加载(scroll-view 无固定高度时 scrolltolower 永不触发) + onReachBottom() { + this.loadMore() + }, methods: { loadList() { - if (this.loading) return + // xuchao: 请求序号 —— 新请求直接取代在途请求,过期响应整体丢弃(修复搜索竞态,故不再用 loading 提前 return) + const seq = ++this.reqSeq this.loading = true this.loadStatus = 'loading' const params = { @@ -86,6 +92,7 @@ export default { if (this.lng) params.lng = this.lng if (this.lat) params.lat = this.lat this.$u.api.getStoreList(params).then(res => { + if (seq !== this.reqSeq) return if (res.errcode === 0 && res.data) { const list = res.data.list || [] if (this.pageNo === 1) { @@ -94,8 +101,11 @@ export default { this.list = this.list.concat(list) } this.total = res.data.total || 0 + // xuchao: 本页不足一页即已到尾部,钉住 total,防止 total 中途变大时空翻 + if (list.length < this.pageSize) this.total = this.list.length } }).finally(() => { + if (seq !== this.reqSeq) return this.loading = false if (this.list.length === 0) { this.loadStatus = 'nomore' @@ -195,7 +205,7 @@ export default { .list-area { padding: 12px; - // xuchao: scroll-view 默认 content-box,100%+padding 会撑出页面横向滚动 + // xuchao: border-box 防止 padding 撑出页面横向滚动 box-sizing: border-box; } diff --git a/pages/venue/venue.vue b/pages/venue/venue.vue index 3dae1ee..8ead7c3 100644 --- a/pages/venue/venue.vue +++ b/pages/venue/venue.vue @@ -16,7 +16,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -49,7 +49,8 @@ export default { lng: '', lat: '', loadStatus: 'loadmore', - hasScrolled: false + hasScrolled: false, + reqSeq: 0 } }, onLoad() { @@ -62,9 +63,14 @@ export default { } this.loadList() }, + // xuchao: 改用页面级触底加载(scroll-view 无固定高度时 scrolltolower 永不触发) + onReachBottom() { + this.loadMore() + }, methods: { loadList() { - if (this.loading) return + // xuchao: 请求序号 —— 新请求直接取代在途请求,过期响应整体丢弃(修复搜索竞态,故不再用 loading 提前 return) + const seq = ++this.reqSeq this.loading = true this.loadStatus = 'loading' const params = { @@ -76,6 +82,7 @@ export default { if (this.lng) params.lng = this.lng if (this.lat) params.lat = this.lat this.$u.api.getStoreList(params).then(res => { + if (seq !== this.reqSeq) return if (res.errcode === 0 && res.data) { const list = res.data.list || [] if (this.pageNo === 1) { @@ -84,8 +91,11 @@ export default { this.list = this.list.concat(list) } this.total = res.data.total || 0 + // xuchao: 本页不足一页即已到尾部,钉住 total,防止 total 中途变大时空翻 + if (list.length < this.pageSize) this.total = this.list.length } }).finally(() => { + if (seq !== this.reqSeq) return this.loading = false if (this.list.length === 0) { this.loadStatus = 'nomore'