feat: migrate ice venue module
This commit is contained in:
@@ -0,0 +1,474 @@
|
||||
<template>
|
||||
<view class="home-container">
|
||||
<StatePanel
|
||||
v-if="pageState === 'error'"
|
||||
title="首页内容加载失败"
|
||||
:description="pageMessage"
|
||||
primary-text="重试"
|
||||
type="error"
|
||||
@primary="loadHome"
|
||||
/>
|
||||
|
||||
<block v-else>
|
||||
<!-- 极简无感大图轮播 -->
|
||||
<view class="banner-wrapper">
|
||||
<swiper
|
||||
class="banner-swiper"
|
||||
circular
|
||||
autoplay
|
||||
interval="4000"
|
||||
duration="600"
|
||||
indicator-dots
|
||||
indicator-color="rgba(15, 23, 42, 0.1)"
|
||||
indicator-active-color="#0F172A"
|
||||
>
|
||||
<swiper-item v-for="(banner, index) in banners" :key="index" @tap="onTapBanner(banner)">
|
||||
<view class="banner-item">
|
||||
<image :src="banner.image" mode="aspectFill" class="banner-img" />
|
||||
<view class="banner-overlay">
|
||||
<text class="banner-title">{{ banner.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<!-- 近期课程板块 (克制留白,无封面纯排版) -->
|
||||
<view class="section-container">
|
||||
<view class="section-header">
|
||||
<text class="section-title">近期课程</text>
|
||||
</view>
|
||||
|
||||
<view class="course-list">
|
||||
<view
|
||||
v-for="course in upcomingCourses"
|
||||
:key="course.id"
|
||||
class="course-item"
|
||||
@tap="navigateToDetail('/pages/ice/courses/detail?id=' + course.id)"
|
||||
>
|
||||
<image :src="course.cover" mode="aspectFill" class="course-cover" />
|
||||
<view class="course-info-wrap">
|
||||
<text class="course-name">{{ course.title }}</text>
|
||||
<text class="course-time highlight-blue">时间:{{ formatCourseDate(course.start_time, course.end_time) }}</text>
|
||||
<view class="course-bottom-meta">
|
||||
<text class="course-meta-text">• 教练:{{ course.coach_name }}</text>
|
||||
<text class="course-meta-text">• 人数:已约 {{ course.booked_count }}/{{ course.capacity }}人</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="upcomingCourses.length === 0" class="empty-placeholder">
|
||||
<text>今日暂无课程排期</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 活动资讯版块 -->
|
||||
<view class="section-container last-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">公告活动</text>
|
||||
</view>
|
||||
|
||||
<view class="activity-grid">
|
||||
<view
|
||||
v-for="activity in activities"
|
||||
:key="activity.id"
|
||||
class="activity-card"
|
||||
@tap="navigateToDetail('/pages/ice/activities/detail?id=' + activity.id)"
|
||||
>
|
||||
<image :src="activity.cover" mode="aspectFill" class="activity-cover" />
|
||||
<view class="activity-info">
|
||||
<text class="activity-title">{{ activity.title }}</text>
|
||||
<text class="activity-date">{{ formatDate(activity.created_at) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onPullDownRefresh } from '@dcloudio/uni-app'
|
||||
import { homeApi } from '@/modules/ice/api/home'
|
||||
import { errorMessage } from '@/modules/ice/api/session'
|
||||
import StatePanel from '@/components/ice/StatePanel.vue'
|
||||
|
||||
const todayStr = ref('')
|
||||
const banners = ref([])
|
||||
const upcomingCourses = ref([])
|
||||
const activities = ref([])
|
||||
const pageState = ref('ready')
|
||||
const pageMessage = ref('')
|
||||
|
||||
onMounted(() => {
|
||||
const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
|
||||
const now = new Date()
|
||||
todayStr.value = `${now.getMonth() + 1}月${now.getDate()}日 ${days[now.getDay()]}`
|
||||
loadHome()
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
loadHome().finally(() => {
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
})
|
||||
|
||||
const loadHome = async () => {
|
||||
try {
|
||||
const data = await homeApi.getHome({
|
||||
courseLimit: 2,
|
||||
bannerLimit: 5
|
||||
})
|
||||
banners.value = data.banners
|
||||
upcomingCourses.value = data.upcomingCourses
|
||||
activities.value = data.activities
|
||||
pageState.value = 'ready'
|
||||
pageMessage.value = ''
|
||||
} catch (err) {
|
||||
pageState.value = 'error'
|
||||
pageMessage.value = errorMessage(err, '首页内容加载失败,请稍后重试。')
|
||||
}
|
||||
}
|
||||
|
||||
const navigateToDetail = (url) => {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
const onTapBanner = (banner) => {
|
||||
if (banner.link_type === 'course' && banner.link_value) {
|
||||
navigateToDetail(`/pages/ice/courses/detail?id=${banner.link_value}`)
|
||||
} else if (banner.link_type === 'activity' && banner.link_value) {
|
||||
navigateToDetail(`/pages/ice/activities/detail?id=${banner.link_value}`)
|
||||
}
|
||||
}
|
||||
|
||||
const formatCourseDate = (startStr, endStr) => {
|
||||
const start = new Date(startStr)
|
||||
const end = new Date(endStr)
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
const mm = pad(start.getMonth() + 1)
|
||||
const dd = pad(start.getDate())
|
||||
const startHhMm = `${pad(start.getHours())}:${pad(start.getMinutes())}`
|
||||
const endHhMm = `${pad(end.getHours())}:${pad(end.getMinutes())}`
|
||||
return `${mm}-${dd} ${startHhMm} - ${endHhMm}`
|
||||
}
|
||||
|
||||
const formatDate = (dateStr) => {
|
||||
const date = new Date(dateStr)
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.home-container {
|
||||
padding: $spacing-lg $spacing-md;
|
||||
background-color: $bg-color-soft;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 顶部场馆标题 */
|
||||
.header-section {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
margin-bottom: $spacing-lg;
|
||||
padding: 0 4rpx;
|
||||
|
||||
.venue-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.venue-title {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: $text-color-main;
|
||||
letter-spacing: -0.5rpx;
|
||||
}
|
||||
|
||||
.venue-status-tag {
|
||||
font-size: 20rpx;
|
||||
color: $color-success;
|
||||
font-weight: 500;
|
||||
margin-top: $spacing-xs;
|
||||
}
|
||||
|
||||
.today-date {
|
||||
font-size: 24rpx;
|
||||
color: $text-color-muted;
|
||||
}
|
||||
}
|
||||
|
||||
/* 无圆角,极简轮播 */
|
||||
.banner-wrapper {
|
||||
margin-bottom: $spacing-lg;
|
||||
|
||||
.banner-swiper {
|
||||
height: 320rpx;
|
||||
border-radius: $border-radius-base;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-item {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: $bg-color-hover;
|
||||
}
|
||||
|
||||
.banner-overlay {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(to top, rgba(15, 23, 42, 0.6), transparent);
|
||||
padding: $spacing-md;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
color: #FFFFFF;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
/* 核心快捷卡片入口 */
|
||||
.quick-entry-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-md;
|
||||
margin-bottom: $spacing-xl;
|
||||
}
|
||||
|
||||
.entry-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: $bg-color-main;
|
||||
border: 1rpx solid rgba(226, 232, 240, 0.8);
|
||||
border-radius: $border-radius-base;
|
||||
padding: $spacing-md $spacing-lg;
|
||||
position: relative;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:active {
|
||||
background-color: $bg-color-hover;
|
||||
}
|
||||
|
||||
&.primary-entry {
|
||||
border-color: rgba(14, 165, 233, 0.15);
|
||||
background: linear-gradient(135deg, $bg-color-main 0%, #F0F9FF 100%);
|
||||
|
||||
.entry-num {
|
||||
color: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.entry-icon-wrap {
|
||||
margin-right: $spacing-lg;
|
||||
}
|
||||
|
||||
.entry-num {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: $text-color-light;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.entry-text-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.entry-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $text-color-main;
|
||||
}
|
||||
|
||||
.entry-desc {
|
||||
font-size: 22rpx;
|
||||
color: $text-color-muted;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
.entry-arrow {
|
||||
font-size: 32rpx;
|
||||
color: $text-color-light;
|
||||
}
|
||||
}
|
||||
|
||||
/* 板块通用头部 */
|
||||
.section-container {
|
||||
margin-bottom: $spacing-xl;
|
||||
|
||||
&.last-section {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: $spacing-md;
|
||||
padding: 0 4rpx;
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5rpx;
|
||||
color: $text-color-main;
|
||||
position: relative;
|
||||
padding-left: $spacing-sm;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 10%;
|
||||
bottom: 10%;
|
||||
width: 4rpx;
|
||||
background-color: $text-color-main;
|
||||
}
|
||||
}
|
||||
|
||||
.section-more {
|
||||
font-size: 24rpx;
|
||||
color: $text-color-muted;
|
||||
}
|
||||
}
|
||||
|
||||
/* 课程卡片 */
|
||||
.course-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
}
|
||||
|
||||
.course-item {
|
||||
display: flex;
|
||||
background-color: $bg-color-main;
|
||||
border-radius: $border-radius-base;
|
||||
border: 1rpx solid $bg-color-hover;
|
||||
overflow: hidden;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:active {
|
||||
background-color: $bg-color-hover;
|
||||
}
|
||||
|
||||
.course-cover {
|
||||
width: 180rpx;
|
||||
height: 130rpx;
|
||||
background-color: $bg-color-hover;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.course-info-wrap {
|
||||
flex: 1;
|
||||
padding: $spacing-sm $spacing-md;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.course-name {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: $text-color-main;
|
||||
line-height: 1.3;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.course-time {
|
||||
font-size: 22rpx;
|
||||
color: $text-color-muted;
|
||||
font-weight: 500;
|
||||
|
||||
&.highlight-blue {
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.course-bottom-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-xl;
|
||||
}
|
||||
|
||||
.course-meta-text {
|
||||
font-size: 22rpx;
|
||||
color: $text-color-muted;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* 极简活动卡片(两列横向拼图排版) */
|
||||
.activity-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $spacing-sm;
|
||||
}
|
||||
|
||||
.activity-card {
|
||||
display: flex;
|
||||
background-color: $bg-color-main;
|
||||
border-radius: $border-radius-base;
|
||||
border: 1rpx solid $bg-color-hover;
|
||||
overflow: hidden;
|
||||
|
||||
.activity-cover {
|
||||
width: 180rpx;
|
||||
height: 130rpx;
|
||||
background-color: $bg-color-hover;
|
||||
}
|
||||
|
||||
.activity-info {
|
||||
flex: 1;
|
||||
padding: $spacing-sm $spacing-md;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.activity-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: $text-color-main;
|
||||
line-height: 1.3;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.activity-date {
|
||||
font-size: 20rpx;
|
||||
color: $text-color-light;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-placeholder {
|
||||
text-align: center;
|
||||
padding: $spacing-xl 0;
|
||||
color: $text-color-light;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user