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'