diff --git a/src/pages/match/details/index.vue b/src/pages/match/details/index.vue index cb3cea9..9fc2724 100644 --- a/src/pages/match/details/index.vue +++ b/src/pages/match/details/index.vue @@ -890,7 +890,9 @@ export default { this.typeList = this.typeList.slice(0, 3) } this.$refs.breadcrumb.update('全部赛事/' + competition.name) + this.handleStatus() + this.timer = setInterval(this.handleStatus, 1000) }).catch(err => { }) }, // 定时处理时间及状态 @@ -903,99 +905,97 @@ export default { let signUpEndTime = new Date(this.core.dateCompatible(form.signUpEndTime)) // 报名结束时间 let playStartTime = new Date(this.core.dateCompatible(form.playStartTime)) // 比赛开始时间 let playEndTime = new Date(this.core.dateCompatible(form.playEndTime)) // 比赛结束时间 - this.timer = setInterval(() => { - const now = new Date() - if (now < signUpStartTime) { // 报名没开始 - status = 0 - total = signUpStartTime - now - } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 - // 1已报名,2立即报名(没登录的情况下,直接显示立即报名,登录了则取报名信息,有则已报名,无则立即报名) - status = this.token ? - (form.competitionRegistration ? - 1 : - 2) : - 2 - total = signUpEndTime - now - } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 - status = 3 - total = playStartTime - now - } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 - // 如果是完整比赛 - if (form.releaseType) { - // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 - let curStage = null - const stages = form.competitionStage - if (stages) { - this.playingStages = [] - form.competitionRegistration && stages.forEach(e => { - if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) this.playingStages.push(e) - }) - let endText = '' - for (const i in stages) { - const e = stages[i] - const startTime = new Date(e.startTime) - const endTime = new Date(e.endTime) - if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 - endText = '阶段开始' - total = startTime - now - break - } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 - // 非线下赛事 - if (e.method !== 2) { - if (form.competitionRegistration) { // 报名了才能进入比赛 - this.statusList[4] = e.count ? '已提交' : '进入' + e.stageName - curStage = e - } else if (!this.token) { - this.statusList[4] = '进入' + e.stageName - curStage = e - } - } else if (this.offlineCanEntry(e) && form.competitionRegistration) { // 线下(输入了系统链接或者上传文件选择了是,才需要显示进入按钮) - // 当系统链接为空,且上传文件为否时,无需展示入口 - // 当系统链接不为空,且上传文件为否时,点击入口,直接跳转到链接页面,无需弹窗 - // 当上传文件为是时,点击入口需弹窗,共两种样式 + const now = new Date() + if (now < signUpStartTime) { // 报名没开始 + status = 0 + total = signUpStartTime - now + } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 + // 1已报名,2立即报名(没登录的情况下,直接显示立即报名,登录了则取报名信息,有则已报名,无则立即报名) + status = this.token ? + (form.competitionRegistration ? + 1 : + 2) : + 2 + total = signUpEndTime - now + } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 + status = 3 + total = playStartTime - now + } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 + // 如果是完整比赛 + if (form.releaseType) { + // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 + let curStage = null + const stages = form.competitionStage + if (stages) { + this.playingStages = [] + form.competitionRegistration && stages.forEach(e => { + if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) this.playingStages.push(e) + }) + let endText = '' + for (const i in stages) { + const e = stages[i] + const startTime = new Date(e.startTime) + const endTime = new Date(e.endTime) + if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 + endText = '阶段开始' + total = startTime - now + break + } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 + // 非线下赛事 + if (e.method !== 2) { + if (form.competitionRegistration) { // 报名了才能进入比赛 + this.statusList[4] = e.count ? '已提交' : '进入' + e.stageName + curStage = e + } else if (!this.token) { this.statusList[4] = '进入' + e.stageName curStage = e } - endText = '阶段结束' - total = endTime - now - break - } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 - endText = '阶段开始' - total = new Date(stages[i + 1].startTime) - now - break - } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 - this.$set(form, 'stageName', '') - endText = '竞赛结束' - total = playEndTime - now - break + } else if (this.offlineCanEntry(e) && form.competitionRegistration) { // 线下(输入了系统链接或者上传文件选择了是,才需要显示进入按钮) + // 当系统链接为空,且上传文件为否时,无需展示入口 + // 当系统链接不为空,且上传文件为否时,点击入口,直接跳转到链接页面,无需弹窗 + // 当上传文件为是时,点击入口需弹窗,共两种样式 + this.statusList[4] = '进入' + e.stageName + curStage = e } + endText = '阶段结束' + total = endTime - now + break + } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 + endText = '阶段开始' + total = new Date(stages[i + 1].startTime) - now + break + } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 + this.$set(form, 'stageName', '') + endText = '竞赛结束' + total = playEndTime - now + break } - this.endList[4] = endText } - if (!this.choosing) this.curStage = curStage - } else { // 仅发布信息 - total = playEndTime - now + this.endList[4] = endText } - status = 4 - } else if (now > playEndTime) { // 比赛结束 - status = 5 - } - this.status = status - total = total / 1000 - --total - if (total > 86400) { // 超过一天则显示天数 - // clearInterval(this.timer) - this.end = Math.floor(total / 86400) + '天' - } else if (total > 0) { // 一天之内,显示时分秒 - let hours = Math.floor(total / (60 * 60)) - let minutes = Math.floor(total % (60 * 60) / 60) - let seconds = Math.floor(total % (60 * 60) % 60) - time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` - if (total > 0) this.end = time - } else if (this.status === 5) { // 竞赛结束,清除定时器 - clearInterval(this.timer) + if (!this.choosing) this.curStage = curStage + } else { // 仅发布信息 + total = playEndTime - now } - }, 1000) + status = 4 + } else if (now > playEndTime) { // 比赛结束 + status = 5 + } + this.status = status + total = total / 1000 + --total + if (total > 86400) { // 超过一天则显示天数 + // clearInterval(this.timer) + this.end = Math.floor(total / 86400) + '天' + } else if (total > 0) { // 一天之内,显示时分秒 + let hours = Math.floor(total / (60 * 60)) + let minutes = Math.floor(total % (60 * 60) / 60) + let seconds = Math.floor(total % (60 * 60) % 60) + time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` + if (total > 0) this.end = time + } else if (this.status === 5) { // 竞赛结束,清除定时器 + clearInterval(this.timer) + } }, // 该阶段是否符合线下能进入比赛的条件 offlineCanEntry (stage) { diff --git a/src/pages/match/list/index.vue b/src/pages/match/list/index.vue index dcd03b9..9d1fd95 100644 --- a/src/pages/match/list/index.vue +++ b/src/pages/match/list/index.vue @@ -109,11 +109,11 @@
比赛时间:{{ item.playStartTime}} ~ {{ item.playEndTime }}
-
- 比赛范围:{{ item.ranges }} +
+ 比赛范围:{{ item.locations }}
- 比赛类型:{{ item.setup.competitionType ? '团体赛' : '个人赛' }} + 比赛类型:{{ item.competitionType ? '团体赛' : '个人赛' }}
当前阶段:{{ item.curStage.stageName }} @@ -214,7 +214,7 @@ maxlength="6" v-model="enterForm.invitationCode"> - + @@ -249,7 +249,7 @@ maxlength="6" v-model="teamForm.invitationCode"> - + @@ -270,19 +270,19 @@ :close-on-click-modal="false" width="600px" @close="stageClose"> - @@ -449,9 +449,7 @@ export default { invitationCode: '', whetherSignUp: 1 }, - curItem: { - setup: {} - }, + curItem: {}, peopleSignupVisible: false, peopleSignupForm: { registrationInvitationCode: '' @@ -524,120 +522,106 @@ export default { if (eventType === 2 && !competitionScope) form.competitionScope = 3 // 赛事广场下如果competitionScope=0,则传3,赛事广场没有本校内 if (eventType !== 1) data.competitionScope = form.competitionScope // 本校赛事不传范围 this.$post(this.api.competitionAfterLogin, data).then(({ data }) => { - const { records } = data - records.forEach((n, k) => { - n.invitationCode = n.setup.invitationCode - // 比赛范围 - const list = n.contestRangeRespList - if (list) { - const range = [] - list.map(e => { - range.push(e.type ? (e.cityName || e.provinceName) : e.schoolName) // type 1:省市,0:学校 - }) - n.ranges = `${n.range}(${range.join(',')})` - } else { - n.ranges = n.range - } - }); - this.listData = records + this.listData = data.records this.totals = data.total - this.handleStatus() + this.statusInterval() // this.loadIns.close(); }).catch(res => { // this.loadIns.close() }) }, - // 定时处理时间及状态 - handleStatus () { + statusInterval () { this.listData.map(item => { if (item.signUpStartTime && item.signUpEndTime && item.playStartTime && item.playEndTime) { - let total = '' - let time = '' - let status = '' - let signUpStartTime = new Date(this.core.dateCompatible(item.signUpStartTime)) // 报名开始时间 - let signUpEndTime = new Date(this.core.dateCompatible(item.signUpEndTime)) // 报名结束时间 - let playStartTime = new Date(this.core.dateCompatible(item.playStartTime)) // 比赛开始时间 - let playEndTime = new Date(this.core.dateCompatible(item.playEndTime)) // 比赛结束时间 + this.handleStatus(item) let timer = setInterval(() => { - const now = new Date() - if (now < signUpStartTime) { // 报名没开始 - status = 0 - total = signUpStartTime - now - } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 - // whetherToSignUp 0已报名,1未报名 - status = item.whetherToSignUp ? 2 : 1 // 1已报名,2立即报名 - total = signUpEndTime - now - } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 - status = 3 - total = playStartTime - now - } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 - // 如果是完整比赛 - if (item.releaseType) { - // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 - let curStage = null - const stages = item.competitionStageList - if (stages) { - item.playingStages = [] - // 报了名才算作可以进入的阶段 - item.whetherToSignUp === 0 && stages.forEach(e => { - if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) item.playingStages.push(e) - }) - for (const i in stages) { - const e = stages[i] - const startTime = new Date(e.startTime) - const endTime = new Date(e.endTime) - if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '阶段开始') - total = startTime - now - break - } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 - if (item.whetherToSignUp === 0 && (e.method !== 2 || this.offlineCanEntry(e))) this.$set(item, 'stageName', (!this.offlineCanEntry(e) && e.count) ? '已提交' : '进入' + e.stageName) // 报名了并且没参加比赛才能进入比赛 - this.$set(item, 'endText', '阶段结束') - curStage = e - total = endTime - now - break - } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '阶段开始') - total = new Date(stages[i + 1].startTime) - now - break - } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '竞赛结束') - total = playEndTime - now - break - } - } - } - item.curStage = curStage - } else { // 仅发布信息 + this.handleStatus(item) + }, 1000) + this.timerList.push(timer) + } + }) + }, + // 定时处理时间及状态 + handleStatus (item) { + let total = '' + let time = '' + let status = '' + let signUpStartTime = new Date(this.core.dateCompatible(item.signUpStartTime)) // 报名开始时间 + let signUpEndTime = new Date(this.core.dateCompatible(item.signUpEndTime)) // 报名结束时间 + let playStartTime = new Date(this.core.dateCompatible(item.playStartTime)) // 比赛开始时间 + let playEndTime = new Date(this.core.dateCompatible(item.playEndTime)) // 比赛结束时间 + const now = new Date() + if (now < signUpStartTime) { // 报名没开始 + status = 0 + total = signUpStartTime - now + } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 + // whetherToSignUp 0已报名,1未报名 + status = item.whetherToSignUp ? 2 : 1 // 1已报名,2立即报名 + total = signUpEndTime - now + } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 + status = 3 + total = playStartTime - now + } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 + // 如果是完整比赛 + if (item.releaseType) { + // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 + let curStage = null + const stages = item.competitionStageList + if (stages) { + item.playingStages = [] + // 报了名才算作可以进入的阶段 + item.whetherToSignUp === 0 && stages.forEach(e => { + if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) item.playingStages.push(e) + }) + for (const i in stages) { + const e = stages[i] + const startTime = new Date(e.startTime) + const endTime = new Date(e.endTime) + if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 + this.$set(item, 'stageName', '') + this.$set(item, 'endText', '阶段开始') + total = startTime - now + break + } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 + if (item.whetherToSignUp === 0 && (e.method !== 2 || this.offlineCanEntry(e))) this.$set(item, 'stageName', (!this.offlineCanEntry(e) && e.count) ? '已提交' : '进入' + e.stageName) // 报名了并且没参加比赛才能进入比赛 + this.$set(item, 'endText', '阶段结束') + curStage = e + total = endTime - now + break + } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 + this.$set(item, 'stageName', '') + this.$set(item, 'endText', '阶段开始') + total = new Date(stages[i + 1].startTime) - now + break + } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 + this.$set(item, 'stageName', '') this.$set(item, 'endText', '竞赛结束') total = playEndTime - now + break } - status = 4 - } else if (now > playEndTime) { // 比赛结束 - status = 5 - } - this.$set(item, 'status', status) - total = total / 1000 - --total - if (total > 86400) { // 超过一天则显示天数 - // clearInterval(timer) - this.$set(item, 'end', Math.floor(total / 86400) + '天') - } else if (total > 0) { // 一天之内,显示时分秒 - let hours = Math.floor(total / (60 * 60)) - let minutes = Math.floor(total % (60 * 60) / 60) - let seconds = Math.floor(total % (60 * 60) % 60) - time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` - if (total > 0) this.$set(item, 'end', time) - } else if (item.status === 5) { // 竞赛结束,清除定时器 - clearInterval(timer) } - }, 1000) - this.timerList.push(timer) + } + this.$set(item, 'curStage', curStage) + } else { // 仅发布信息 + this.$set(item, 'endText', '竞赛结束') + total = playEndTime - now } - }) + status = 4 + } else if (now > playEndTime) { // 比赛结束 + status = 5 + } + this.$set(item, 'status', status) + total = total / 1000 + --total + if (total > 86400) { // 超过一天则显示天数 + this.$set(item, 'end', Math.floor(total / 86400) + '天') + } else if (total > 0) { // 一天之内,显示时分秒 + let hours = Math.floor(total / (60 * 60)) + let minutes = Math.floor(total % (60 * 60) / 60) + let seconds = Math.floor(total % (60 * 60) % 60) + time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` + if (total > 0) this.$set(item, 'end', time) + } else if (item.status === 5) { } }, // 清除定时器 clearTimer () { @@ -719,7 +703,7 @@ export default { const form = this.enterForm if (!form.teamId) return util.errorMsg('请选择团队') if (!form.invitationCode) return util.errorMsg('请输入团队邀请码') - if (this.curItem.setup.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') + if (this.curItem.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') this.$post(this.api.joinCompetitionTeam, form).then(res => { this.enterVisible = false this.getData() @@ -754,7 +738,7 @@ export default { if (!form.teamName) return util.errorMsg('请输入团队名称') if (this.teamNameRepeat) return util.errorMsg('团队名称重复,请重新输入') if (form.invitationCode.length !== 6) return util.errorMsg('请输入6位数团队邀请码') - if (this.curItem.setup.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') + if (this.curItem.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') this.$post(this.api.addCompetitionTeam, form).then(res => { this.teamVisible = false this.enterVisible = false @@ -764,7 +748,7 @@ export default { }, // 该阶段是否符合线下能进入比赛的条件 offlineCanEntry (stage) { - return stage.method === 2 && stage.competitionStageContentSetting && !!(stage.competitionStageContentSetting.systemLink || stage.competitionStageContentSetting.whetherToUploadFiles) + return stage.method === 2 && !!(stage.systemLink || stage.whetherToUploadFiles) }, @@ -835,7 +819,7 @@ export default { }, // 删除文件表里的文件 handleRemove (file) { - Oss.del(file.url) + Oss.del(file.name) this.fileList = [] this.curFileId && this.$post(this.api.cCompetitionStageFileDel, [this.curFileId]).then(res => { this.curFileId = '' @@ -879,7 +863,7 @@ export default { }, // 线下比赛方式点击进入跳转<比赛地点> toOffline () { - window.open(this.curStageItem.competitionStageContentSetting.systemLink) + window.open(this.curStageItem.systemLink) }, stageClick (e) { }, @@ -907,7 +891,7 @@ export default { // 报名 signup (item) { const { status, id } = item - const { competitionType } = item.setup + const { competitionType } = item // 如果没登录,提示去登录 if (util.local.get(Setting.tokenKey)) { this.curItem = item @@ -915,31 +899,31 @@ export default { // 线下(规则见handleStatus方法) if (item.curStage.method == 2) { // 直接打开系统链接 - if (!item.curStage.competitionStageContentSetting.whetherToUploadFiles) { - window.open(item.curStage.competitionStageContentSetting.systemLink) + if (!item.curStage.whetherToUploadFiles) { + window.open(item.curStage.systemLink) } else { // 显示上传文件弹框 this.curStageItem = item.curStage this.stageVisible = true // 文件路径名称处理 - if (item.curStage.competitionStageContentSetting && item.curStage.competitionStageContentSetting.fileUrl) { - const urls = item.curStage.competitionStageContentSetting.fileUrl.split('|') - const names = item.curStage.competitionStageContentSetting.fileName.split('|') - item.curStage.competitionStageContentSetting.fileList = [] + if (item.curStage.fileUrl) { + const urls = item.curStage.fileUrl.split('|') + const names = item.curStage.fileName.split('|') + item.curStage.fileList = [] urls.map((n, i) => { - item.curStage.competitionStageContentSetting.fileList.push({ + item.curStage.fileList.push({ name: names[i], url: n }) }) } - const file = item.curStage.competitionStageFile + const file = item.curStage.filePath if (file) { - this.curFileId = file.id + this.curFileId = item.curStage.userFileId this.fileList = [{ - name: file.fileName, - url: file.filePath, + name: item.curStage.userFileName, + url: file, }] } } @@ -972,7 +956,7 @@ export default { } this.enterVisible = true } else { // 个人赛报名 - if (item.setup.isNeedCode) { + if (item.isNeedCode) { this.curRow = item this.peopleSignupForm.registrationInvitationCode = '' this.peopleSignupVisible = true diff --git a/src/pages/station/preview/index.vue b/src/pages/station/preview/index.vue index 98fe4bf..f3ef8a0 100644 --- a/src/pages/station/preview/index.vue +++ b/src/pages/station/preview/index.vue @@ -991,10 +991,6 @@ export default { } else if (systemId == 19) { // 沙盘 location.href = `${Setting.sandPath}/#/?curriculumName=${this.curriculumName}&token=${token}&cid=${this.courseId}&mallId=${this.mallId}&systemId=${this.systemIds}&projectId=${this.curProject}&assessmentId=&classId=&stopTime=&referrer=${encodeURIComponent(location.href)}` - } else if (systemId == 21) { - window.open(`http://121.37.29.24:80/yyyflogin?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=3989a0ad671849b99dcbdcc208782333&caseId=9681f86902314b10bc752909121f9ab9&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=7ff5d4715b114b7398b6f26c20fac460`); - } else if (systemId == 22) { - window.open(`https://danbao.czcyedu.com/#/loginFromYyyf?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=eb7d8355119d449184c548b07dc01ed9&caseId=1198241070647873538&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=faaedd82adb9444285a5785e4a3dd4f9`); } else { // python系统 this.toPython(this.curProject) diff --git a/src/pages/touristMatch/list/index.vue b/src/pages/touristMatch/list/index.vue index 9751643..f705691 100644 --- a/src/pages/touristMatch/list/index.vue +++ b/src/pages/touristMatch/list/index.vue @@ -93,11 +93,11 @@
比赛时间:{{ item.playStartTime}} ~ {{ item.playEndTime }}
-
- 比赛范围:{{ item.ranges }} +
+ 比赛范围:{{ item.locations }}
- 比赛类型:{{ item.setup.competitionType ? '团体赛' : '个人赛' }} + 比赛类型:{{ item.competitionType ? '团体赛' : '个人赛' }}
当前阶段:{{ item.curStage.stageName }} @@ -196,7 +196,7 @@ maxlength="6" v-model="enterForm.invitationCode"> - + @@ -231,7 +231,7 @@ maxlength="6" v-model="teamForm.invitationCode"> - + @@ -341,9 +341,7 @@ export default { invitationCode: '', whetherSignUp: 1 }, - curItem: { - setup: {} - }, + curItem: {}, peopleSignupVisible: false, peopleSignupForm: { registrationInvitationCode: '' @@ -389,121 +387,112 @@ export default { keyWord: this.keyword } this.$post(this.api[util.local.get(Setting.tokenKey) ? 'competitionAfterLogin' : 'notLoggedInBeforeStudentEvents'], data).then(({ data }) => { - const { records } = data - const { token } = this - records.forEach((n, k) => { - n.invitationCode = n.setup.invitationCode - // 比赛范围 - const list = n.contestRangeRespList - if (list) { - const range = [] - list.map(e => { - range.push(e.type ? (e.provinceName || e.cityName) : e.schoolName) // type 1:省市,0:学校 - }) - n.ranges = `${n.range}(${range.join(',')})` - } else { - n.ranges = n.range - } - }) - this.listData = records + this.listData = data.records this.totals = data.total - this.handleStatus() + this.statusInterval() this.loadIns.close() }).catch(res => { this.loadIns.close() }) }, // 定时处理时间及状态 - handleStatus () { + statusInterval () { this.listData.map(item => { if (item.signUpStartTime && item.signUpEndTime && item.playStartTime && item.playEndTime) { - let total = '' - let time = '' - let status = '' - let signUpStartTime = new Date(this.core.dateCompatible(item.signUpStartTime)) // 报名开始时间 - let signUpEndTime = new Date(this.core.dateCompatible(item.signUpEndTime)) // 报名结束时间 - let playStartTime = new Date(this.core.dateCompatible(item.playStartTime)) // 比赛开始时间 - let playEndTime = new Date(this.core.dateCompatible(item.playEndTime)) // 比赛结束时间 + this.handleStatus(item) let timer = setInterval(() => { - const now = new Date() - if (now < signUpStartTime) { // 报名没开始 - status = 0 - total = signUpStartTime - now - } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 - // whetherToSignUp 0已报名,1未报名 - status = item.whetherToSignUp === 0 ? 1 : 2 // 1已报名,2立即报名 - total = signUpEndTime - now - } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 - status = 3 - total = playStartTime - now - } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 - // 如果是完整比赛 - if (item.releaseType) { - // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 - let curStage = null - const stages = item.competitionStageList - if (stages) { - item.playingStages = [] - item.whetherToSignUp === 0 && stages.forEach(e => { - if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) item.playingStages.push(e) + this.handleStatus(item) + }, 1000) + this.timerList.push(timer) + } + }) + }, - }) - for (const i in stages) { - const e = stages[i] - const startTime = new Date(e.startTime) - const endTime = new Date(e.endTime) - if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '阶段开始') - total = startTime - now - break - } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 - if ((item.whetherToSignUp === 0 || !util.local.get(Setting.tokenKey)) && (e.method !== 2 || this.offlineCanEntry(e))) this.$set(item, 'stageName', e.count ? '已提交' : '进入' + e.stageName) // 报名了并且没参加比赛才能进入比赛 - this.$set(item, 'endText', '阶段结束') - curStage = e - total = endTime - now - break - } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '阶段开始') - total = new Date(stages[i + 1].startTime) - now - break - } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 - this.$set(item, 'stageName', '') - this.$set(item, 'endText', '竞赛结束') - total = playEndTime - now - break - } - } - } - item.curStage = curStage - } else { // 仅发布信息 + // 定时处理时间及状态 + handleStatus (item) { + console.log("🚀 ~ file: index.vue:413 ~ handleStatus ~ item:", item) + let total = '' + let time = '' + let status = '' + let signUpStartTime = new Date(this.core.dateCompatible(item.signUpStartTime)) // 报名开始时间 + let signUpEndTime = new Date(this.core.dateCompatible(item.signUpEndTime)) // 报名结束时间 + let playStartTime = new Date(this.core.dateCompatible(item.playStartTime)) // 比赛开始时间 + let playEndTime = new Date(this.core.dateCompatible(item.playEndTime)) // 比赛结束时间 + const now = new Date() + if (now < signUpStartTime) { // 报名没开始 + status = 0 + total = signUpStartTime - now + } else if (now > signUpStartTime && now < signUpEndTime) { // 报名进行中 + // whetherToSignUp 0已报名,1未报名 + status = item.whetherToSignUp === 0 ? 1 : 2 // 1已报名,2立即报名 + total = signUpEndTime - now + } else if (now > signUpEndTime && now < playStartTime) { // 报名结束了,但比赛没开始 + status = 3 + total = playStartTime - now + } else if (now > playStartTime && now < playEndTime) { // 比赛进行中 + // 如果是完整比赛 + if (item.releaseType) { + // 进行中的赛事,则遍历每个阶段的开始结束时间,看阶段比赛是否开始 + let curStage = null + const stages = item.competitionStageList + if (stages) { + item.playingStages = [] + item.whetherToSignUp === 0 && stages.forEach(e => { + if (now >= new Date(e.startTime) && now <= new Date(e.endTime) && (e.method !== 2 || this.offlineCanEntry(e))) item.playingStages.push(e) + + }) + for (const i in stages) { + const e = stages[i] + const startTime = new Date(e.startTime) + const endTime = new Date(e.endTime) + if (now < startTime) { // 阶段比赛未开始,不显示进入比赛按钮 + this.$set(item, 'stageName', '') + this.$set(item, 'endText', '阶段开始') + total = startTime - now + break + } else if (now >= startTime && now <= endTime) { // 阶段比赛进行中,显示进入比赛按钮 + if ((item.whetherToSignUp === 0 || !util.local.get(Setting.tokenKey)) && (e.method !== 2 || this.offlineCanEntry(e))) this.$set(item, 'stageName', e.count ? '已提交' : '进入' + e.stageName) // 报名了并且没参加比赛才能进入比赛 + this.$set(item, 'endText', '阶段结束') + curStage = e + total = endTime - now + break + } else if (stages[i + 1] && now > endTime && now < new Date(stages[i + 1].startTime)) { // 过了该阶段的结束时间,但是没到下个阶段的开始时间,不显示进入比赛按钮 + this.$set(item, 'stageName', '') + this.$set(item, 'endText', '阶段开始') + total = new Date(stages[i + 1].startTime) - now + break + } else if (i === stages.length - 1) { // 当前时间在比赛开始结束时间之间,并且是最后一个阶段结束时间之后 + this.$set(item, 'stageName', '') this.$set(item, 'endText', '竞赛结束') total = playEndTime - now + break } - status = 4 - } else if (now > playEndTime) { // 比赛结束 - status = 5 } - this.$set(item, 'status', status) - total = total / 1000 - --total - if (total > 86400) { // 超过一天则显示天数 - // clearInterval(timer) - this.$set(item, 'end', Math.floor(total / 86400) + '天') - } else if (total > 0) { // 一天之内,显示时分秒 - let hours = Math.floor(total / (60 * 60)) - let minutes = Math.floor(total % (60 * 60) / 60) - let seconds = Math.floor(total % (60 * 60) % 60) - time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` - if (total > 0) this.$set(item, 'end', time) - } else if (item.status === 5) { // 竞赛结束,清除定时器 - clearInterval(timer) - } - }, 1000) - this.timerList.push(timer) + } + this.$set(item, 'curStage', curStage) + } else { // 仅发布信息 + this.$set(item, 'endText', '竞赛结束') + total = playEndTime - now } - }) + status = 4 + } else if (now > playEndTime) { // 比赛结束 + status = 5 + } + this.$set(item, 'status', status) + total = total / 1000 + --total + if (total > 86400) { // 超过一天则显示天数 + // clearInterval(timer) + this.$set(item, 'end', Math.floor(total / 86400) + '天') + } else if (total > 0) { // 一天之内,显示时分秒 + let hours = Math.floor(total / (60 * 60)) + let minutes = Math.floor(total % (60 * 60) / 60) + let seconds = Math.floor(total % (60 * 60) % 60) + time = `${this.core.formateTime(hours)}:${this.core.formateTime(minutes)}:${this.core.formateTime(seconds)}` + if (total > 0) this.$set(item, 'end', time) + } else if (item.status === 5) { // 竞赛结束,清除定时器 + + } }, // 清除定时器 clearTimer () { @@ -573,7 +562,7 @@ export default { const form = this.enterForm if (!form.teamId) return util.errorMsg('请选择团队') if (!form.invitationCode) return util.errorMsg('请输入团队邀请码') - if (this.curItem.setup.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') + if (this.curItem.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') this.$post(this.api.joinCompetitionTeam, form).then(res => { this.enterVisible = false this.getData() @@ -583,7 +572,7 @@ export default { // 该阶段是否符合线下能进入比赛的条件 offlineCanEntry (stage) { - return stage.method === 2 && stage.competitionStageContentSetting && !!(stage.competitionStageContentSetting.systemLink || stage.competitionStageContentSetting.whetherToUploadFiles) + return stage.method === 2 && !!(stage.systemLink || stage.whetherToUploadFiles) }, // 创建团队 @@ -612,7 +601,7 @@ export default { if (!form.teamName) return util.errorMsg('请输入团队名称') if (this.teamNameRepeat) return util.errorMsg('团队名称重复,请重新输入') if (form.invitationCode.length !== 6) return util.errorMsg('请输入6位数团队邀请码') - if (this.curItem.setup.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') + if (this.curItem.isNeedCode && !form.registrationInvitationCode) return util.errorMsg('请输入大赛邀请码') this.$post(this.api.addCompetitionTeam, form).then(res => { this.teamVisible = false this.enterVisible = false @@ -644,7 +633,7 @@ export default { // 报名 signup (item) { const { status, id } = item - const { competitionType } = item.setup + const { competitionType } = item // 如果没登录,提示去登录 if (util.local.get(Setting.tokenKey)) { this.curItem = item @@ -666,7 +655,7 @@ export default { } } else if (status == 2) { // 报名 // 团队赛报名 - if (item.setup.competitionType) { + if (item.competitionType) { this.getTeam() this.enterForm = { competitionId: id, @@ -676,7 +665,7 @@ export default { } this.enterVisible = true } else { // 个人赛报名 - if (item.setup.isNeedCode) { + if (item.isNeedCode) { this.curRow = item this.peopleSignupForm.registrationInvitationCode = '' this.peopleSignupVisible = true diff --git a/src/setting.js b/src/setting.js index 48748ca..549dc56 100644 --- a/src/setting.js +++ b/src/setting.js @@ -33,7 +33,7 @@ if (isPro) { host = "http://121.37.12.51/"; // 测试服 // host = 'https://www.occupationlab.com/' // 正式服 // host = "http://192.168.31.217:9000/"; // 榕 - // host = "http://192.168.31.51:9000/"; // 赓 + host = "http://192.168.31.51:9000/"; // 赓 } else if (isSq) { zcPath = `10.20.100.204:8883` }