From 54e0f8a8fdda164af528e4237ae189e8ad3ed44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Tue, 29 Sep 2026 22:39:34 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=B8=8D=E8=A6=81=20=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E9=A1=B9=E7=9B=AE/=E5=85=A8=E9=83=A8=E7=BB=84?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E9=80=89=E9=A1=B9=EF=BC=8C=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E9=80=89=E5=85=B7=E4=BD=93=E7=9A=84=E9=A1=B9=E7=9B=AE/?= =?UTF-8?q?=E7=BB=84=E5=88=AB=202=E3=80=81=E7=AD=9B=E9=80=89=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=E7=9A=84=E6=95=B0=E6=8D=AE=E8=A6=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- subpackages/mine/scores/scores.js | 52 +++++++++++++++++++++++------ subpackages/mine/scores/scores.wxml | 2 +- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/subpackages/mine/scores/scores.js b/subpackages/mine/scores/scores.js index 3ebb6d7..872b673 100644 --- a/subpackages/mine/scores/scores.js +++ b/subpackages/mine/scores/scores.js @@ -7,9 +7,9 @@ Page({ eventIndex: 0, selectedEventId: '', projects: [], - projectNames: ['全部项目'], + projectNames: [], projectIndex: 0, - groupNames: ['全部组别'], + groupNames: [], groupIndex: 0, keyword: '', rows: [], @@ -49,7 +49,17 @@ Page({ onEventChange(e) { const eventIndex = Number(e.detail.value) || 0; const selected = this.data.events[eventIndex]; - this.setData({ eventIndex, selectedEventId: selected ? selected.id : '', projectIndex: 0, groupIndex: 0, rows: [], searched: false }); + this.setData({ + eventIndex, + selectedEventId: selected ? selected.id : '', + projects: [], + projectNames: [], + projectIndex: 0, + groupNames: [], + groupIndex: 0, + rows: [], + searched: false + }); this.loadFilters() .then(() => this.queryScores()) .catch((err) => wx.showToast({ title: (err && err.message) || '筛选条件加载失败', icon: 'none' })); @@ -59,23 +69,39 @@ Page({ if (!this.data.selectedEventId) return Promise.resolve(); return competition.fetchScoreFilters(this.data.selectedEventId).then((res) => { const projects = Array.isArray(res && res.projects) ? res.projects : []; - const groups = Array.isArray(res && res.groupNames) ? res.groupNames : []; + const groupNames = projects[0] && Array.isArray(projects[0].groupNames) + ? projects[0].groupNames + : []; this.setData({ projects, - projectNames: ['全部项目'].concat(projects.map((item) => item.projectName || item.name || '未命名项目')), + projectNames: projects.map((item) => item.projectName || item.name || '未命名项目'), projectIndex: 0, - groupNames: ['全部组别'].concat(groups), + groupNames, groupIndex: 0 }); }); }, onProjectChange(e) { - this.setData({ projectIndex: Number(e.detail.value) || 0 }); + const projectIndex = Number(e.detail.value) || 0; + const project = this.data.projects[projectIndex]; + this.setData({ + projectIndex, + groupNames: project && Array.isArray(project.groupNames) ? project.groupNames : [], + groupIndex: 0, + rows: [], + searched: false, + expandedId: '' + }); }, onGroupChange(e) { - this.setData({ groupIndex: Number(e.detail.value) || 0 }); + this.setData({ + groupIndex: Number(e.detail.value) || 0, + rows: [], + searched: false, + expandedId: '' + }); }, onKeywordInput(e) { @@ -94,11 +120,17 @@ Page({ // 拦住重复点击"查询"导致的并发请求;首次加载时 loadEvents 已置 loading=true, // 故必须同时判 searched,否则初次查询会被自己拦掉。 if (this.data.loading && this.data.searched) return Promise.resolve(); + const project = this.data.projects[this.data.projectIndex]; + const groupName = this.data.groupNames[this.data.groupIndex]; + if (!this.data.selectedEventId || !project || !groupName) { + this.setData({ rows: [], searched: true, loading: false, expandedId: '' }); + return Promise.resolve(); + } this.setData({ loading: true, expandedId: '' }); return competition.queryScores({ eventId: this.data.selectedEventId, - projectId: this.data.projectIndex > 0 ? this.data.projects[this.data.projectIndex - 1].projectId : undefined, - groupName: this.data.groupIndex > 0 ? this.data.groupNames[this.data.groupIndex] : undefined, + projectId: project.projectId, + groupName, keyword: this.data.keyword }).then((res) => { this.setData({ rows: (res && res.rows) || [], searched: true }); diff --git a/subpackages/mine/scores/scores.wxml b/subpackages/mine/scores/scores.wxml index 6c17c9a..132aba1 100644 --- a/subpackages/mine/scores/scores.wxml +++ b/subpackages/mine/scores/scores.wxml @@ -28,7 +28,7 @@ × - +