- 新增参赛者、裁判、检录员角色识别及角色化首页与个人中心 - 新增裁判注册、身份认证提示、赛事执裁报名及报名记录查询 - 新增检录工作台,支持检录任务、轮次状态与运动员检录操作 - 新增赛事成绩查询页面及成绩详情展示 - 封装成绩、检录和裁判报名接口,补充请求参数清理逻辑 - 新增检录 Tab 图标、页面路由及本地开发配置 - 新增 Git 忽略规则,排除依赖、构建缓存、日志和本地工具文件
62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
const ROLE = {
|
|
PARTICIPANT: 'participant',
|
|
REFEREE: 'referee',
|
|
CHECKER: 'checker'
|
|
};
|
|
|
|
const ROLE_META = {
|
|
participant: { value: 'participant', label: '参赛者', description: '报名参赛并查询个人成绩' },
|
|
referee: { value: 'referee', label: '裁判', description: '完成裁判认证后参与执裁' },
|
|
checker: { value: 'checker', label: '检录员', description: '查看检录轮次并完成现场检录' }
|
|
};
|
|
|
|
function normalizeRole(value) {
|
|
if (value == null || value === '') return ROLE.PARTICIPANT;
|
|
const raw = String(value).toLowerCase();
|
|
const map = {
|
|
'1': ROLE.PARTICIPANT,
|
|
participant: ROLE.PARTICIPANT,
|
|
athlete: ROLE.PARTICIPANT,
|
|
user: ROLE.PARTICIPANT,
|
|
player: ROLE.PARTICIPANT,
|
|
'参赛者': ROLE.PARTICIPANT,
|
|
'2': ROLE.REFEREE,
|
|
referee: ROLE.REFEREE,
|
|
judge: ROLE.REFEREE,
|
|
'裁判': ROLE.REFEREE,
|
|
'3': ROLE.CHECKER,
|
|
checker: ROLE.CHECKER,
|
|
checkin: ROLE.CHECKER,
|
|
inspector: ROLE.CHECKER,
|
|
'检录员': ROLE.CHECKER
|
|
};
|
|
return map[raw] || ROLE.PARTICIPANT;
|
|
}
|
|
|
|
function getProfileRole(profile) {
|
|
const p = profile && typeof profile === 'object' ? profile : {};
|
|
const raw = p.role != null ? p.role
|
|
: p.userRole != null ? p.userRole
|
|
: p.accountRole != null ? p.accountRole
|
|
: p.roleType != null ? p.roleType
|
|
: p.RoleType != null ? p.RoleType
|
|
: p.userType != null ? p.userType
|
|
: p.identityType;
|
|
if (raw != null && raw !== '') return normalizeRole(raw);
|
|
return normalizeRole(wx.getStorageSync('registeredRole') || ROLE.PARTICIPANT);
|
|
}
|
|
|
|
function updateEventTabBar(role) {
|
|
if (typeof wx === 'undefined' || typeof wx.setTabBarItem !== 'function') return;
|
|
const isChecker = normalizeRole(role) === ROLE.CHECKER;
|
|
wx.setTabBarItem({
|
|
index: 0,
|
|
text: isChecker ? '检录' : '赛事',
|
|
iconPath: isChecker ? 'assets/tab_scan.png' : 'assets/tab_home.png',
|
|
selectedIconPath: isChecker ? 'assets/tab_scan_sel.png' : 'assets/tab_home_sel.png',
|
|
fail() {}
|
|
});
|
|
}
|
|
|
|
module.exports = { ROLE, ROLE_META, normalizeRole, getProfileRole, updateEventTabBar };
|