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 @@
×
-
+