- 新增参赛者、裁判、检录员角色识别及角色化首页与个人中心 - 新增裁判注册、身份认证提示、赛事执裁报名及报名记录查询 - 新增检录工作台,支持检录任务、轮次状态与运动员检录操作 - 新增赛事成绩查询页面及成绩详情展示 - 封装成绩、检录和裁判报名接口,补充请求参数清理逻辑 - 新增检录 Tab 图标、页面路由及本地开发配置 - 新增 Git 忽略规则,排除依赖、构建缓存、日志和本地工具文件
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
const competition = require('../../../utils/competition');
|
|
|
|
Page({
|
|
data: {
|
|
events: [],
|
|
eventNames: [],
|
|
eventIndex: 0,
|
|
selectedEventId: '',
|
|
keyword: '',
|
|
rows: [],
|
|
searched: false,
|
|
loading: true,
|
|
expandedId: ''
|
|
},
|
|
|
|
onLoad() {
|
|
this.loadEvents();
|
|
},
|
|
|
|
onPullDownRefresh() {
|
|
this.loadEvents().finally(() => wx.stopPullDownRefresh());
|
|
},
|
|
|
|
loadEvents() {
|
|
this.setData({ loading: true });
|
|
return competition.fetchScoreEvents()
|
|
.then((events) => {
|
|
const list = Array.isArray(events) ? events : (events && events.rows) || [];
|
|
this.setData({
|
|
events: list,
|
|
eventNames: list.map((item) => item.name),
|
|
eventIndex: 0,
|
|
selectedEventId: list[0] ? list[0].id : ''
|
|
});
|
|
return this.queryScores();
|
|
})
|
|
.catch((err) => {
|
|
this.setData({ rows: [], searched: true });
|
|
wx.showToast({ title: (err && err.message) || '赛事加载失败', icon: 'none' });
|
|
})
|
|
.finally(() => this.setData({ loading: false }));
|
|
},
|
|
|
|
onEventChange(e) {
|
|
const eventIndex = Number(e.detail.value) || 0;
|
|
const selected = this.data.events[eventIndex];
|
|
this.setData({ eventIndex, selectedEventId: selected ? selected.id : '' });
|
|
},
|
|
|
|
onKeywordInput(e) {
|
|
this.setData({ keyword: e.detail.value || '' });
|
|
},
|
|
|
|
onClearKeyword() {
|
|
this.setData({ keyword: '' });
|
|
},
|
|
|
|
onSearch() {
|
|
this.queryScores();
|
|
},
|
|
|
|
queryScores() {
|
|
if (this.data.loading && this.data.searched) return Promise.resolve();
|
|
this.setData({ loading: true, expandedId: '' });
|
|
return competition.queryScores({
|
|
eventId: this.data.selectedEventId,
|
|
keyword: this.data.keyword
|
|
}).then((res) => {
|
|
this.setData({ rows: (res && res.rows) || [], searched: true });
|
|
}).catch((err) => {
|
|
wx.showToast({ title: (err && err.message) || '查询失败', icon: 'none' });
|
|
}).finally(() => this.setData({ loading: false }));
|
|
},
|
|
|
|
onToggleDetail(e) {
|
|
const id = e.currentTarget.dataset.id;
|
|
this.setData({ expandedId: this.data.expandedId === id ? '' : id });
|
|
}
|
|
});
|