523 lines
12 KiB
Vue
523 lines
12 KiB
Vue
<template>
|
|
<view class="page-container">
|
|
<template v-if="detailData">
|
|
|
|
<view style="flex: 1;overflow-y: auto">
|
|
<!-- 活动图片 -->
|
|
<view class="event-header">
|
|
<t-image :src=config.fileDomain+detailData.cover shape="round"
|
|
class="event-cover" fit="fill"/>
|
|
</view>
|
|
|
|
<!-- 活动标题与标签 -->
|
|
<view class="event-title-section">
|
|
<view class="event-title">{{ detailData.title }}</view>
|
|
</view>
|
|
|
|
<!-- 活动基本信息 -->
|
|
<view class="event-info-section">
|
|
<!-- 报名时间 -->
|
|
<view class="info-item">
|
|
<t-icon name="calendar" size="20px"/>
|
|
<view class="info-text-container">
|
|
<text class="info-text-title">报名时间</text>
|
|
<text class="info-text">{{ formatDate(detailData.signStartTime) }} 至
|
|
{{ formatDate(detailData.signEndTime) }}
|
|
</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 活动时间 -->
|
|
<view class="info-item">
|
|
<t-icon name="alarm" size="20px"/>
|
|
<view class="info-text-container">
|
|
<text class="info-text-title">活动时间</text>
|
|
<text class="info-text">{{ formatDate(detailData.startTime) }} 至 {{
|
|
formatDate(detailData.endTime)
|
|
}}
|
|
</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 活动地点 -->
|
|
<view class="info-item">
|
|
<t-icon name="location" size="20px"/>
|
|
<view class="info-text-container">
|
|
<text class="info-text-title">活动地点</text>
|
|
<text class="info-text">{{ detailData.address }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 活动详情区域 -->
|
|
<view class="activity-detail-section">
|
|
<view class="section-title">活动详情</view>
|
|
<rich-text class="rich-content" :nodes="detailData.content"></rich-text>
|
|
</view>
|
|
|
|
<!-- 比赛项目 -->
|
|
<view class="activity-detail-section" v-if="detailData.items && detailData.items.length > 0">
|
|
<view class="section-title">比赛项目</view>
|
|
|
|
<view class="event-items">
|
|
<view v-for="(item, index) in detailData.items" :key="index" class="event-item">
|
|
<view class="event-item-header">
|
|
<view class="event-item-index">{{ index + 1 }}</view>
|
|
<text class="event-item-name">{{ item.name }}</text>
|
|
</view>
|
|
|
|
<view class="event-item-content">
|
|
<!-- 项目图片区域 -->
|
|
<t-image :src=config.fileDomain+item.img shape="round"
|
|
class="event-item-image" fit="fill"/>
|
|
|
|
<!-- 项目信息区域 -->
|
|
<view class="event-item-info">
|
|
<view class="event-item-section">
|
|
<view class="event-item-section-title">
|
|
<t-icon name="flag" size="16px" color="var(--td-brand-color-5)"/>
|
|
<text>比赛方法</text>
|
|
</view>
|
|
<view class="event-item-section-content">{{ item.form }}</view>
|
|
</view>
|
|
|
|
<view class="event-item-section">
|
|
<view class="event-item-section-title">
|
|
<t-icon name="chart-bar" size="16px" color="var(--td-brand-color-5)"/>
|
|
<text>评分标准</text>
|
|
</view>
|
|
<view class="event-item-section-content">{{ item.rule }}</view>
|
|
</view>
|
|
|
|
<view class="event-item-section">
|
|
<view class="event-item-section-title">
|
|
<t-icon name="help-circle" size="16px" color="var(--td-brand-color-5)"/>
|
|
<text>比赛规则</text>
|
|
</view>
|
|
<view class="event-item-section-content">{{ item.ruleForm }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 底部操作栏 -->
|
|
<view class="footer-bar">
|
|
<!-- <t-button theme="primary" block @click="navigateToSignUp">立即报名</t-button>-->
|
|
<t-button theme="primary" block :disabled="bottomButton.disabled" @click="bottomButton.onClick">
|
|
{{ bottomButton.text }}
|
|
</t-button>
|
|
</view>
|
|
</template>
|
|
|
|
<!-- 加载中状态 -->
|
|
<template v-else>
|
|
<view class="loading-container">
|
|
<t-loading theme="dots" size="40rpx"/>
|
|
<text>加载中...</text>
|
|
</view>
|
|
</template>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {ref, onMounted, computed} from 'vue';
|
|
import {onLoad} from '@dcloudio/uni-app';
|
|
import {Toast} from 'tdesign-mobile-vue';
|
|
import {useRequest} from "@/utils/request";
|
|
import {config} from "@/utils/config";
|
|
|
|
const request = useRequest();
|
|
const actId = ref(null);
|
|
const isSignUp = ref(null);
|
|
const detailData = ref(null);
|
|
|
|
// 格式化日期
|
|
const formatDate = (dateStr) => {
|
|
if (!dateStr) return '';
|
|
try {
|
|
const date = new Date(dateStr);
|
|
return `${date.getFullYear()}.${(date.getMonth() + 1).toString().padStart(2, '0')}.${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
|
|
} catch (error) {
|
|
return dateStr;
|
|
}
|
|
};
|
|
|
|
// 底部按钮文字
|
|
const bottomButton = computed(() => {
|
|
const {signStartTime, signEndTime} = detailData.value
|
|
if (signStartTime && signEndTime) {
|
|
const now = new Date();
|
|
const startTime = new Date(signStartTime);
|
|
const endTime = new Date(signEndTime);
|
|
if (now >= startTime && now <= endTime) {
|
|
return {
|
|
text: isSignUp.value ? '修改报名信息' : '立即报名',
|
|
disabled: false,
|
|
onClick: navigateToSignUp
|
|
}
|
|
} else if (now < startTime) {
|
|
return {
|
|
text: `报名开始时间:${formatDate(signStartTime)}`,
|
|
disabled: true,
|
|
onClick: () => {
|
|
}
|
|
}
|
|
} else {
|
|
return {
|
|
text: `报名结束时间:${formatDate(signEndTime)}`,
|
|
disabled: true,
|
|
onClick: () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
// 跳转到报名页面
|
|
const navigateToSignUp = () => {
|
|
if (!actId.value) return;
|
|
uni.navigateTo({
|
|
url: `/pages/activity/registration-form/index?id=${actId.value}`
|
|
});
|
|
};
|
|
|
|
// 获取活动详情
|
|
const getActivityDetail = async (id) => {
|
|
try {
|
|
const {code, data} = await request.get(`/client/activity/get/${id}`);
|
|
if (code === 0 && data) {
|
|
detailData.value = data;
|
|
} else {
|
|
// Toast({message: '获取活动详情失败', theme: 'error'});
|
|
}
|
|
} catch (error) {
|
|
console.error('获取活动详情错误', error);
|
|
// Toast({message: '获取活动详情失败', theme: 'error'});
|
|
}
|
|
};
|
|
|
|
// 判断是否报名
|
|
async function getIsSignUp() {
|
|
try {
|
|
const {code, data} = await request.get('/client/activity/is-sign-up/' + actId.value)
|
|
if (code === 0) {
|
|
isSignUp.value = data
|
|
} else {
|
|
Toast({message: '判断是否报名失败', theme: 'error'});
|
|
}
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
}
|
|
|
|
// 页面加载
|
|
onLoad((option) => {
|
|
if (option.id) {
|
|
actId.value = option.id;
|
|
getActivityDetail(option.id);
|
|
getIsSignUp();
|
|
} else {
|
|
Toast({message: '未找到活动ID', theme: 'error'});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
/* 活动图片区域 */
|
|
.event-header {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 420rpx;
|
|
}
|
|
|
|
.event-cover {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.bottom-placeholder {
|
|
width: 100%;
|
|
height: 120rpx;
|
|
}
|
|
|
|
.event-title-section {
|
|
padding: 24rpx;
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
.event-title {
|
|
font-size: 36rpx;
|
|
font-weight: bold;
|
|
line-height: 1.4;
|
|
color: #333333;
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.event-tag {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
background-color: rgba(var(--td-brand-color-5), 0.1);
|
|
color: var(--td-brand-color-5);
|
|
font-size: 24rpx;
|
|
padding: 6rpx 12rpx;
|
|
border-radius: 6rpx;
|
|
|
|
.t-icon {
|
|
margin-right: 4rpx;
|
|
}
|
|
}
|
|
|
|
/* 活动信息区域 */
|
|
.event-info-section {
|
|
margin-top: 16rpx;
|
|
background-color: #ffffff;
|
|
padding: 0 24rpx;
|
|
}
|
|
|
|
.info-item {
|
|
display: flex;
|
|
padding: 24rpx 0;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
|
|
.t-icon {
|
|
color: var(--td-brand-color-5);
|
|
margin-right: 16rpx;
|
|
flex-shrink: 0;
|
|
margin-top: 4rpx;
|
|
}
|
|
}
|
|
|
|
.info-text-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex: 1;
|
|
}
|
|
|
|
.info-text-title {
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
margin-bottom: 6rpx;
|
|
}
|
|
|
|
.info-text {
|
|
font-size: 28rpx;
|
|
color: #333333;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
/* 活动详情区域 */
|
|
.activity-detail-section {
|
|
margin-top: 16rpx;
|
|
background-color: #ffffff;
|
|
padding: 24rpx;
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 32rpx;
|
|
font-weight: 500;
|
|
color: #333333;
|
|
margin-bottom: 24rpx;
|
|
position: relative;
|
|
padding-left: 24rpx;
|
|
|
|
&::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 8rpx;
|
|
width: 8rpx;
|
|
height: 32rpx;
|
|
background-color: var(--td-brand-color-5);
|
|
border-radius: 4rpx;
|
|
}
|
|
}
|
|
|
|
.rich-content {
|
|
font-size: 28rpx;
|
|
line-height: 1.6;
|
|
color: #333333;
|
|
}
|
|
|
|
/* 比赛项目 */
|
|
.event-items {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24rpx;
|
|
}
|
|
|
|
.event-item {
|
|
background-color: #ffffff;
|
|
border-radius: 12rpx;
|
|
overflow: hidden;
|
|
//box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
|
border: 1px solid #f0f0f0;
|
|
height: auto;
|
|
max-height: none;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.event-item:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.event-item-header {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 20rpx 24rpx;
|
|
background-color: #f9f9f9;
|
|
border-left: 8rpx solid var(--td-brand-color-5);
|
|
position: relative;
|
|
}
|
|
|
|
.event-item-index {
|
|
background-color: var(--td-brand-color-5);
|
|
color: #ffffff;
|
|
width: 40rpx;
|
|
height: 40rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
font-size: 24rpx;
|
|
font-weight: bold;
|
|
margin-right: 16rpx;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.event-item-name {
|
|
color: #333333;
|
|
font-size: 30rpx;
|
|
font-weight: 500;
|
|
flex: 1;
|
|
margin-right: 8rpx;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.event-item-content {
|
|
padding: 0;
|
|
}
|
|
|
|
.event-item-image {
|
|
width: 100%;
|
|
height: 300rpx;
|
|
display: block;
|
|
}
|
|
|
|
.event-item-info {
|
|
padding: 24rpx;
|
|
max-height: 600rpx;
|
|
overflow-y: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
}
|
|
|
|
.event-item-section {
|
|
margin-bottom: 24rpx;
|
|
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
|
|
.event-item-section-title {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 12rpx;
|
|
|
|
.t-icon {
|
|
margin-right: 8rpx;
|
|
}
|
|
|
|
text {
|
|
font-size: 28rpx;
|
|
font-weight: 500;
|
|
color: #333333;
|
|
}
|
|
}
|
|
|
|
.event-item-section-content {
|
|
font-size: 28rpx;
|
|
color: #666666;
|
|
line-height: 1.5;
|
|
word-break: break-all;
|
|
padding-left: 32rpx;
|
|
}
|
|
|
|
/* 底部按钮区域 */
|
|
.footer-bar {
|
|
//position: fixed;
|
|
//bottom: 0;
|
|
//left: 0;
|
|
//right: 0;
|
|
flex-shrink: 0;
|
|
background-color: #ffffff;
|
|
padding: 24rpx;
|
|
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
|
|
z-index: 100;
|
|
}
|
|
|
|
/* 加载状态 */
|
|
.loading-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 80vh;
|
|
|
|
text {
|
|
margin-top: 24rpx;
|
|
color: #999999;
|
|
font-size: 28rpx;
|
|
}
|
|
}
|
|
|
|
/* 内容折叠样式 */
|
|
.content-collapsed {
|
|
max-height: 200rpx;
|
|
overflow: hidden;
|
|
position: relative;
|
|
|
|
&::after {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 60rpx;
|
|
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
|
|
}
|
|
}
|
|
|
|
.expand-button {
|
|
margin-top: 12rpx;
|
|
text-align: center;
|
|
color: var(--td-brand-color-5);
|
|
font-size: 26rpx;
|
|
padding: 8rpx 0;
|
|
}
|
|
|
|
.scrollable-content {
|
|
max-height: 300rpx;
|
|
overflow-y: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
padding-right: 10rpx;
|
|
}
|
|
|
|
::v-deep .t-swiper {
|
|
height: auto !important;
|
|
min-height: 500px;
|
|
}
|
|
|
|
::v-deep .t-swiper-item {
|
|
height: auto !important;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
</style>
|