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

chore: 优化我的大赛页面

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