diff --git a/pages/winners/winners.vue b/pages/winners/winners.vue
index 374c50e..62100ac 100644
--- a/pages/winners/winners.vue
+++ b/pages/winners/winners.vue
@@ -15,7 +15,7 @@
已产生
- 7,000
+ {{ totalWinners.toLocaleString() }}
名幸运持卡人
@@ -46,18 +46,26 @@
-
-
- {{ item.memberName }}
- {{ item.memberIdentityNo }}
- {{ item.memberPhone }}
-
-
-
+
+
+
+ {{ item.memberName }}
+ {{ item.memberIdentityNo }}
+ {{ item.memberPhone }}
+
+
+
+
+
+
+
+
+
+ 暂无数据
@@ -72,9 +80,10 @@ export default {
winnerData: {},
pageNo: 1,
pageSize: 10,
- total: 0,
- loading: false,
- loadStatus: 'loadmore',
+ totals: {},
+ totalWinners: 0,
+ inFlight: 0,
+ loadStatusMap: {},
keyword: ''
}
},
@@ -88,6 +97,10 @@ export default {
(item.memberName && item.memberName.toLowerCase().includes(kw)) ||
(item.memberPhone && item.memberPhone.includes(kw))
)
+ },
+ // xuchao: 各期独立的加载状态,避免并行请求互相覆盖
+ loadStatus() {
+ return this.loadStatusMap[this.currentTab] || 'nomore'
}
},
onLoad() {
@@ -110,45 +123,55 @@ export default {
data[index] = []
})
this.winnerData = data
+ // xuchao: 预置各期 key,保证 totals/loadStatusMap 的响应式
+ this.totals = {}
+ this.loadStatusMap = {}
+ dates.forEach((date, index) => {
+ this.$set(this.totals, index, 0)
+ this.$set(this.loadStatusMap, index, 'loading')
+ })
+ // xuchao: 预取各期第一页,汇总已产生总人数
if (this.tabs.length > 0) {
- this.loadWinnerList(0)
+ this.tabs.forEach((tab, index) => {
+ this.loadWinnerList(index, 1, true)
+ })
}
}
})
},
- loadWinnerList(tabIndex) {
+ loadWinnerList(tabIndex, pageNo, allowConcurrent) {
if (!this.tabs[tabIndex]) return
- if (this.loading) return
- this.loading = true
- this.loadStatus = 'loading'
+ if (this.inFlight > 0 && !allowConcurrent) return
+ this.inFlight++
+ this.$set(this.loadStatusMap, tabIndex, 'loading')
const drawDate = this.tabs[tabIndex].date
this.$u.api.getWinnerList({
- pageNo: this.pageNo,
+ pageNo: pageNo || this.pageNo,
pageSize: this.pageSize,
drawDate: drawDate
}).then(res => {
if (res.errcode === 0 && res.data) {
const list = res.data.list || []
- if (this.pageNo === 1) {
+ const page = pageNo || this.pageNo
+ if (page === 1) {
this.$set(this.winnerData, tabIndex, list)
} else {
this.winnerData[tabIndex] = this.winnerData[tabIndex].concat(list)
}
- this.total = res.data.total || 0
+ this.$set(this.totals, tabIndex, res.data.total || 0)
+ // xuchao: 各期总人数求和,用于顶部幸运持卡人数
+ this.totalWinners = Object.values(this.totals).reduce((sum, n) => sum + n, 0)
}
}).finally(() => {
- this.loading = false
- if (this.winnerData[tabIndex].length === 0) {
- this.loadStatus = 'nomore'
- } else if (this.winnerData[tabIndex].length >= this.total) {
- this.loadStatus = 'nomore'
- } else {
- this.loadStatus = 'loadmore'
- }
+ this.inFlight--
+ const len = this.winnerData[tabIndex].length
+ const total = this.totals[tabIndex] || 0
+ this.$set(this.loadStatusMap, tabIndex, len === 0 || len >= total ? 'nomore' : 'loadmore')
})
},
loadMore() {
- if (this.winnerData[this.currentTab].length < this.total && !this.loading) {
+ const total = this.totals[this.currentTab] || 0
+ if (this.winnerData[this.currentTab].length < total && this.inFlight === 0) {
this.pageNo++
this.loadWinnerList(this.currentTab)
}
@@ -157,13 +180,20 @@ export default {
this.currentTab = index
this.pageNo = 1
if (this.winnerData[index].length === 0) {
- this.loadWinnerList(index)
+ this.loadWinnerList(index, 1)
} else {
- this.loadStatus = this.winnerData[index].length >= this.total ? 'nomore' : 'loadmore'
+ const total = this.totals[index] || 0
+ this.$set(this.loadStatusMap, index, this.winnerData[index].length >= total ? 'nomore' : 'loadmore')
}
},
goBack() {
- uni.navigateBack()
+ // xuchao: 直接通过链接进入(无历史栈)时回到首页
+ const pages = getCurrentPages()
+ if (pages.length > 1) {
+ uni.navigateBack()
+ } else {
+ uni.reLaunch({ url: '/pages/index/index' })
+ }
},
onSearch() {
// 前端过滤,无需重新请求
@@ -408,4 +438,18 @@ export default {
padding: 24px 0;
color: #999999;
}
+
+/* 空态 */
+.empty-area {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ padding: 80px 0;
+ color: #999999;
+}
+
+.empty-text {
+ margin-top: 12px;
+ font-size: 14px;
+}