From f2c8364d87b1e198f77e9ad1e1205d36b27ead5b Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Thu, 27 Aug 2026 15:17:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=AD=E5=A5=96=E5=90=8D=E5=8D=95?= =?UTF-8?q?=E9=A1=B5=E5=8A=A8=E6=80=81=E4=BA=BA=E6=95=B0=E3=80=81=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=8F=90=E7=A4=BA=E4=B8=8E=E7=A9=BA=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 顶部幸运持卡人数由各期中奖总数动态求和 - 名单不足一页时隐藏加载更多,各期加载状态独立管理 - 无名单时展示暂无数据空态 Co-Authored-By: Claude Haiku 4.5 --- pages/winners/winners.vue | 116 ++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 36 deletions(-) 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 }} - - - + + + + + 暂无数据 @@ -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; +}