feat: 用户端首页(宫格式布局 + 推荐年卡)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-06-14 17:30:10 +08:00
co-authored by Claude Opus 4.8
parent 6330edba00
commit 2293e67f8c
+188 -1
View File
@@ -1,3 +1,190 @@
<template>
<view><text>页面占位 - 后续任务实现</text></view>
<view class="page">
<!-- 顶部标题区 -->
<view class="header">
<text class="header-title">湖南12301文旅专区</text>
</view>
<!-- 宫格功能入口 -->
<view class="grid">
<view class="grid-item" @click="goTo('/packages/user/pages/card/list')">
<view class="grid-icon" style="background: #E8F0FE;">
<text class="emoji">🎫</text>
</view>
<text class="grid-label">购买年卡</text>
<text class="grid-desc">多种卡种可选</text>
</view>
<view class="grid-item" @click="goTo('/packages/user/pages/card/bind')">
<view class="grid-icon" style="background: #FFF3E0;">
<text class="emoji">📱</text>
</view>
<text class="grid-label">激活/绑定</text>
<text class="grid-desc">激活已购年卡</text>
</view>
<view class="grid-item" @click="showComingSoon">
<view class="grid-icon" style="background: #E8F8F0;">
<text class="emoji">🏔️</text>
</view>
<text class="grid-label">景区预约</text>
<text class="grid-desc">预约入园时间</text>
</view>
<view class="grid-item" @click="showComingSoon">
<view class="grid-icon" style="background: #FCE4EC;">
<text class="emoji">📋</text>
</view>
<text class="grid-label">我的记录</text>
<text class="grid-desc">预约/使用记录</text>
</view>
</view>
<!-- 推荐年卡 -->
<view class="section">
<view class="section-header">
<text class="section-title">推荐年卡</text>
<text class="section-more" @click="goTo('/packages/user/pages/card/list')">查看全部 ›</text>
</view>
<view v-if="cardStore.loading" class="loading">
<text>加载中...</text>
</view>
<view v-else-if="cardStore.cardList.length === 0" class="empty">
<empty-state icon="🎫" text="暂无年卡" />
</view>
<view v-else>
<card-item
v-for="card in displayCards"
:key="card.id"
:card="card"
@click="goToDetail"
/>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useCardStore } from '../../../../store/card'
import CardItem from '../../../../components/card-item.vue'
import EmptyState from '../../../../components/empty-state.vue'
import type { CardInfo } from '../../../../api/types'
const cardStore = useCardStore()
// 首页最多展示 3 张年卡
const displayCards = computed(() => cardStore.cardList.slice(0, 3))
onShow(() => {
cardStore.fetchCardList()
})
function goTo(url: string) {
uni.navigateTo({ url })
}
function goToDetail(card: CardInfo) {
uni.navigateTo({ url: `/packages/user/pages/card/detail?id=${card.id}` })
}
function showComingSoon() {
uni.showToast({ title: '即将上线,敬请期待', icon: 'none' })
}
</script>
<style scoped>
.page {
min-height: 100vh;
background: #f5f5f5;
}
.header {
background: #4A90D9;
padding: 40rpx 30rpx 30rpx;
}
.header-title {
font-size: 36rpx;
font-weight: bold;
color: #fff;
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16rpx;
padding: 20rpx;
margin: -20rpx 16rpx 0;
background: #fff;
border-radius: 16rpx;
position: relative;
z-index: 1;
}
.grid-item {
display: flex;
flex-direction: column;
align-items: center;
padding: 24rpx 0;
}
.grid-icon {
width: 100rpx;
height: 100rpx;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
}
.emoji {
font-size: 44rpx;
}
.grid-label {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 4rpx;
}
.grid-desc {
font-size: 22rpx;
color: #999;
}
.section {
padding: 20rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
}
.section-title {
font-size: 30rpx;
font-weight: bold;
color: #333;
}
.section-more {
font-size: 24rpx;
color: #4A90D9;
}
.loading {
text-align: center;
padding: 60rpx;
color: #999;
font-size: 28rpx;
}
</style>