diff --git a/subpackages/mine/checkin/checkin.js b/subpackages/mine/checkin/checkin.js index f1e8ee6..5bdcd08 100644 --- a/subpackages/mine/checkin/checkin.js +++ b/subpackages/mine/checkin/checkin.js @@ -7,9 +7,7 @@ Page({ projects: [], projectNames: [], projectIndex: 0, - groups: [], - groupNames: [], - groupIndex: 0, + currentProjectName: '', units: [], pendingUnits: [], checkedUnits: [], @@ -25,7 +23,7 @@ Page({ onLoad() { this.loadContext(); }, onPullDownRefresh() { - this.loadContext(this.currentProjectId(), this.currentGroupId()).finally(() => wx.stopPullDownRefresh()); + this.loadContext(this.currentProjectId()).finally(() => wx.stopPullDownRefresh()); }, currentProjectId() { @@ -33,14 +31,9 @@ Page({ return item && item.eventProjectId; }, - currentGroupId() { - const item = this.data.groups[this.data.groupIndex]; - return item && item.id; - }, - - loadContext(eventProjectId, groupId) { + loadContext(eventProjectId) { this.setData({ loading: true }); - return competition.fetchCurrentCheckin({ eventProjectId, groupId }) + return competition.fetchCurrentCheckin({ eventProjectId }) .then((context) => this.applyContext(context)) .catch((err) => wx.showToast({ title: (err && err.message) || '检录信息加载失败', icon: 'none' })) .finally(() => this.setData({ loading: false })); @@ -50,9 +43,6 @@ Page({ const projects = (context && context.projects) || []; let projectIndex = projects.findIndex((item) => String(item.eventProjectId) === String(context.selectedEventProjectId)); if (projectIndex < 0) projectIndex = 0; - const groups = (projects[projectIndex] && projects[projectIndex].groups) || []; - let groupIndex = groups.findIndex((item) => String(item.id) === String(context.selectedGroupId)); - if (groupIndex < 0) groupIndex = 0; const units = (context && context.units) || []; const pendingUnits = Array.isArray(context && context.pendingUnits) ? context.pendingUnits : units.filter((item) => item.canCheck && !item.checked); const checkedUnits = Array.isArray(context && context.checkedUnits) ? context.checkedUnits : units.filter((item) => item.checked); @@ -84,9 +74,7 @@ Page({ projects, projectNames: projects.map((item) => item.projectName), projectIndex, - groups, - groupNames: groups.map((item) => item.groupName), - groupIndex, + currentProjectName: (projects[projectIndex] && projects[projectIndex].projectName) || '', units, pendingUnits, checkedUnits, @@ -103,33 +91,23 @@ Page({ const projectIndex = Number(e.currentTarget.dataset.index) || 0; if (projectIndex === this.data.projectIndex) return; const project = this.data.projects[projectIndex]; - const group = project && project.groups && project.groups[0]; - if (project && group) this.loadContext(project.eventProjectId, group.id); - }, - - onGroupTap(e) { - if (this.data.loading) return; - const groupIndex = Number(e.currentTarget.dataset.index) || 0; - if (groupIndex === this.data.groupIndex) return; - const group = this.data.groups[groupIndex]; - if (group) this.loadContext(this.currentProjectId(), group.id); + if (project) this.loadContext(project.eventProjectId); }, onStartCheckin() { if (this.data.actionLoading) return; const eventProjectId = this.currentProjectId(); - const groupId = this.currentGroupId(); wx.showModal({ title: '开始检录', - content: '开始后将通知本组报名人员,确认继续吗?', + content: '开始后将按秩序册顺序检录该项目全部组别,并通知报名人员,确认继续吗?', success: (res) => { if (!res.confirm) return; this.setData({ actionLoading: true }); - competition.startCheckin({ eventProjectId, groupId }) + competition.startCheckin({ eventProjectId }) .then((result) => { if (result && result.context) this.applyContext(result.context); wx.showToast({ title: (result && result.message) || '检录已开始', icon: 'none' }); - if (!(result && result.context)) return this.loadContext(eventProjectId, groupId); + if (!(result && result.context)) return this.loadContext(eventProjectId); }) .catch((err) => wx.showToast({ title: (err && err.message) || '开始检录失败', icon: 'none' })) .finally(() => this.setData({ actionLoading: false })); @@ -145,8 +123,7 @@ Page({ this.setData({ actionLoading: true }); competition.scanCheckin({ code: scan.result, - eventProjectId: this.currentProjectId(), - groupId: this.currentGroupId() + eventProjectId: this.currentProjectId() }).then((result) => { // 后端在号码布不匹配时返回 success:false + message 且不带 context, // 必须照样给出提示,否则检录员扫错码时收不到任何反馈。 @@ -156,7 +133,7 @@ Page({ title: (result && result.message) || (ok ? '扫码检录成功' : '扫码检录失败'), icon: ok ? 'success' : 'none' }); - if (!(result && result.context)) return this.loadContext(this.currentProjectId(), this.currentGroupId()); + if (!(result && result.context)) return this.loadContext(this.currentProjectId()); }).catch((err) => wx.showToast({ title: (err && err.message) || '扫码检录失败', icon: 'none' })) .finally(() => this.setData({ actionLoading: false })); } @@ -169,8 +146,7 @@ Page({ this.setData({ updatingKey: unitKey }); competition.markCheckinOnStage({ unitKey, - eventProjectId: this.currentProjectId(), - groupId: this.currentGroupId() + eventProjectId: this.currentProjectId() }).then((context) => { if (context) this.applyContext(context); wx.showToast({ title: '已标记上场', icon: 'success' }); @@ -205,7 +181,6 @@ Page({ competition.updateCheckinStatus({ unitKey, eventProjectId: this.currentProjectId(), - groupId: this.currentGroupId(), checked }).then((res) => { this.applyContext(res); diff --git a/subpackages/mine/checkin/checkin.wxml b/subpackages/mine/checkin/checkin.wxml index a404d95..7a88e34 100644 --- a/subpackages/mine/checkin/checkin.wxml +++ b/subpackages/mine/checkin/checkin.wxml @@ -12,8 +12,8 @@ - 当前组别 - {{context.currentGroupName || '请选择组别'}} + 当前项目 + {{currentProjectName || '请选择项目'}} @@ -40,30 +40,10 @@ - - - - 2 - 选择参赛组别点击后立即切换检录名单 - - - - - - {{item.groupName}}{{item.checkedUnits}}/{{item.totalUnits}} · {{item.isCompleted ? '已完成' : item.progressPercent + '%'}} - - - - + @@ -71,7 +51,7 @@ - 当前组别进度{{checkedCount}} / {{units.length}} 项 + 当前项目进度{{checkedCount}} / {{units.length}} 项 已检录 {{checkedCount}} 项待检录 {{pendingCount}} 项 @@ -83,7 +63,7 @@ {{athlete.name}} 确认检录 - 当前组别暂无待检录项 + 当前项目暂无待检录项 等待前序检录前一检通过后可操作 @@ -95,7 +75,7 @@ 已检录{{checkedUnits.length}} 项 - 仅展示当前选中项目和组别的已检录结果 + 展示当前项目全部组别的已检录结果 diff --git a/utils/competition.js b/utils/competition.js index cecaa7e..e017b7f 100644 --- a/utils/competition.js +++ b/utils/competition.js @@ -41,11 +41,10 @@ function updateCheckinStatus({ unitKey, eventProjectId, groupId, checked }) { function startCheckin({ eventProjectId, groupId } = {}) { if (isEmptyValue(eventProjectId)) return rejectWith('请选择检录项目'); - if (isEmptyValue(groupId)) return rejectWith('请选择检录组别'); return request({ path: API.checkinStart, method: 'POST', - data: { eventProjectId, groupId }, + data: withScope({ eventProjectId }, eventProjectId, groupId), needAuth: true }); }