马梓彭 b157e73eb2 新增检录进度页面
新增裁判认证页面
对接检录页面
对接成绩查询页面
2026-09-01 23:13:21 +08:00

58 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const competition = require('../../../utils/competition');
Page({
data: {
eventId: null,
progress: null,
viewState: 'loading',
errorMessage: '',
refreshing: false
},
onLoad(options) {
const eventId = Number(options && options.eventId);
if (!eventId) {
this.setData({ viewState: 'error', errorMessage: '缺少赛事ID,无法查询检录进度' });
return;
}
this.setData({ eventId });
this.loadProgress();
},
onPullDownRefresh() {
this.setData({ refreshing: true });
this.loadProgress(true).finally(() => {
this.setData({ refreshing: false });
wx.stopPullDownRefresh();
});
},
onRetry() {
this.loadProgress();
},
loadProgress(silent = false) {
if (!this.data.eventId) return Promise.resolve();
if (!silent) this.setData({ viewState: 'loading', errorMessage: '' });
return competition.fetchCheckinProgress(this.data.eventId)
.then((progress) => {
this.setData({
progress,
viewState: progress.hasData ? 'content' : 'empty',
errorMessage: ''
});
})
.catch((error) => {
const statusCode = Number(error && error.statusCode);
const forbidden = statusCode === 401 || statusCode === 403;
this.setData({
progress: null,
viewState: forbidden ? 'forbidden' : 'error',
errorMessage: forbidden
? (statusCode === 401 ? '登录状态已失效,请重新登录' : '当前账号无权查看该赛事检录进度')
: ((error && error.message) || '检录进度加载失败,请稍后重试')
});
});
}
});