Merge branch 'master' into xuchao
This commit is contained in:
+22
-6
@@ -16,7 +16,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 场馆列表 -->
|
||||
<scroll-view class="list-area" scroll-y @scrolltolower="loadMore" :lower-threshold="100">
|
||||
<view class="list-area">
|
||||
<view class="venue-card" v-for="item in list" :key="item.shopId" @click="goDetail(item)">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<view class="card-info">
|
||||
@@ -32,9 +32,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="hasScrolled" class="nomore-area">
|
||||
<u-loadmore :status="loadStatus" :loading-text="'加载中...'" :loadmore-text="''" :nomore-text="'我也是有底线的'" />
|
||||
<u-loadmore :status="loadStatus" :load-text="{ loadmore: '', loading: '加载中...', nomore: '我也是有底线的' }" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -51,7 +51,8 @@ export default {
|
||||
lng: '',
|
||||
lat: '',
|
||||
loadStatus: 'loadmore',
|
||||
hasScrolled: false
|
||||
hasScrolled: false,
|
||||
reqSeq: 0
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -64,9 +65,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 = {
|
||||
@@ -78,6 +84,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) {
|
||||
@@ -86,8 +93,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'
|
||||
@@ -106,7 +116,13 @@ export default {
|
||||
}
|
||||
},
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
// xuchao: 直接通过链接进入(无历史栈)时回到首页
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
},
|
||||
goDetail(item) {
|
||||
uni.navigateTo({ url: '/pages/venue/detail?id=' + item.shopId })
|
||||
|
||||
Reference in New Issue
Block a user