提交 d348409b authored 作者: 王鹏飞's avatar 王鹏飞

chore: 优化我的大赛页面

上级 012fcd55
......@@ -3,6 +3,8 @@ import type { Contest } from '../types'
import dayjs from 'dayjs'
import { contestMode } from '@/utils/dictionary'
import { updateTrainCount } from '../api'
import { useMapStore } from '@/stores/map'
interface Props {
data: Contest
}
......@@ -15,6 +17,11 @@ const modeText = $computed(() => {
return contestMode[props.data.mode]
})
const types = useMapStore().getMapValuesByKey('competition_type')
// 赛项类型
const typeText = $computed(() => {
return types.find(item => item.value == props.data.type)?.label
})
// 是否可以训练
const canTrain = $computed(() => {
return dayjs().isBefore(dayjs(parseInt(props.data.end_at) * 1000))
......@@ -33,6 +40,9 @@ const canJoin = $computed(() => {
function handleJoin() {
router.push({ path: '/student/contest/join', query: { id: props.data.id, name: props.data.name } })
}
function formatDate(value: string) {
return dayjs(parseInt(value) * 1000).format('YYYY-MM-DD')
}
</script>
<template>
......@@ -46,12 +56,19 @@ function handleJoin() {
<ul class="info-list">
<li>姓名:{{ data.student_name }}</li>
<li>参赛ID:{{ data.login_id }}</li>
<li>参赛形式:{{ modeText }}</li>
<li>所属学校:{{ data.org_name }}</li>
<li>赛项类型:{{ typeText }}</li>
<li>赛项周期:{{ formatDate(data.start_range) }}{{ formatDate(data.end_range) }}</li>
<li>正式比赛日期:{{ formatDate(data.start_at) }}</li>
</ul>
<el-button round type="primary" @click="handleTrain" v-if="canTrain">我要训练</el-button>
</template>
<template v-else>
<ul class="info-list">
<li>主办单位:{{ data.host_unit.label }}</li>
<li>赛项类型:{{ typeText }}</li>
<li>赛项周期:{{ formatDate(data.start_range) }}{{ formatDate(data.end_range) }}</li>
<li>正式比赛日期:{{ formatDate(data.start_at) }}</li>
</ul>
<el-button round :disabled="!canJoin" type="primary" @click="handleJoin">我要报名</el-button>
</template>
</div>
......@@ -64,7 +81,7 @@ function handleJoin() {
<style lang="scss">
.contest-item-main {
position: relative;
height: 200px;
height: 240px;
border-radius: 10px;
overflow: hidden;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论