feat(app): implement home, booking, and profile pages

Home: brand banner, studio info swiper, smart quick entries based on
membership status, upcoming bookings, card shop horizontal scroll
Booking: 7-day date selector, time period filter, slot cards with
status, booking confirm popup with membership picker
Profile: user card with login, training stats, menu with admin entry
8 reusable components: BrandBanner, StudioInfo, QuickEntry,
UpcomingBooking, CardShop, DateSelector, SlotCard, BookingConfirmPopup,
TimePeriodFilter, UserCard, TrainingStats, ProfileMenu
This commit is contained in:
richarjiang
2026-04-02 14:35:17 +08:00
parent 554fc30954
commit 3a29aca0db
26 changed files with 7766 additions and 74 deletions

View File

@@ -0,0 +1,320 @@
<template>
<view class="card-shop">
<view class="section-header">
<text class="section-title">会员卡</text>
<text class="section-subtitle">选择适合您的套餐</text>
</view>
<!-- Loading skeleton -->
<scroll-view
v-if="loading"
scroll-x
class="cards-scroll"
:show-scrollbar="false"
>
<view class="cards-row">
<view
v-for="i in 3"
:key="i"
class="card-item skeleton-card"
/>
</view>
</scroll-view>
<!-- Card list -->
<scroll-view
v-else-if="cardTypes.length"
scroll-x
class="cards-scroll"
:show-scrollbar="false"
>
<view class="cards-row">
<view
v-for="card in cardTypes"
:key="card.id"
class="card-item"
:class="cardItemClass(card)"
@tap="goToDetail(card.id)"
>
<!-- Card header band -->
<view class="card-header" :class="cardHeaderClass(card)">
<text class="card-type-label">{{ typeLabel(card) }}</text>
</view>
<!-- Card name -->
<text class="card-name">{{ card.name }}</text>
<!-- Pricing -->
<view class="price-row">
<text class="price-current">¥{{ formatPrice(card.price) }}</text>
<text
v-if="card.originalPrice && card.originalPrice > card.price"
class="price-original"
>
¥{{ formatPrice(card.originalPrice) }}
</text>
</view>
<!-- Description -->
<text v-if="card.description" class="card-desc">
{{ truncate(card.description, 40) }}
</text>
<!-- Duration / Times -->
<view class="card-meta">
<view v-if="card.totalTimes" class="meta-item">
<text class="meta-value">{{ card.totalTimes }}</text>
<text class="meta-label"></text>
</view>
<view class="meta-item">
<text class="meta-value">{{ card.durationDays }}</text>
<text class="meta-label">天有效</text>
</view>
</view>
<!-- Buy button -->
<view class="buy-btn">
<text class="buy-btn-text">立即购买</text>
</view>
</view>
</view>
</scroll-view>
<!-- Empty -->
<view v-else class="empty-state">
<text class="empty-text">暂无可购买的会员卡</text>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import type { CardType } from '@mp-pilates/shared'
import { CardTypeCategory } from '@mp-pilates/shared'
import { get } from '../utils/request'
import { formatPrice } from '../utils/format'
const cardTypes = ref<CardType[]>([])
const loading = ref(false)
async function fetchCardTypes() {
loading.value = true
try {
const result = await get<CardType[]>('/membership/card-types')
cardTypes.value = result
.filter((c) => c.isActive)
.sort((a, b) => a.sortOrder - b.sortOrder)
} catch {
uni.showToast({ title: '加载会员卡失败', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(fetchCardTypes)
// Expose refresh method for parent page
defineExpose({ fetchCardTypes })
function goToDetail(id: string) {
uni.navigateTo({ url: `/pages/card/detail?id=${id}` })
}
function typeLabel(card: CardType): string {
const map: Record<CardTypeCategory, string> = {
[CardTypeCategory.TIMES]: '次卡',
[CardTypeCategory.DURATION]: '月卡',
[CardTypeCategory.TRIAL]: '体验',
}
return map[card.type] ?? '会员卡'
}
function cardItemClass(card: CardType): string {
if (card.type === CardTypeCategory.TRIAL) return 'card-item--trial'
if (card.type === CardTypeCategory.DURATION) return 'card-item--duration'
return ''
}
function cardHeaderClass(card: CardType): string {
if (card.type === CardTypeCategory.TRIAL) return 'header--trial'
if (card.type === CardTypeCategory.DURATION) return 'header--duration'
return 'header--times'
}
function truncate(str: string, maxLen: number): string {
return str.length > maxLen ? str.slice(0, maxLen) + '…' : str
}
</script>
<style lang="scss" scoped>
.card-shop {
margin: 24rpx 0 0;
padding-bottom: 40rpx;
}
.section-header {
display: flex;
align-items: baseline;
gap: 16rpx;
padding: 0 24rpx;
margin-bottom: 20rpx;
}
.section-title {
font-size: 32rpx;
font-weight: 700;
color: #1a1a2e;
}
.section-subtitle {
font-size: 24rpx;
color: #999;
}
.cards-scroll {
width: 100%;
}
.cards-row {
display: flex;
flex-direction: row;
gap: 20rpx;
padding: 8rpx 24rpx 16rpx;
width: max-content;
}
/* --- Individual Card --- */
.card-item {
width: 280rpx;
background: #ffffff;
border-radius: 16rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.10);
overflow: hidden;
display: flex;
flex-direction: column;
flex-shrink: 0;
&--trial {
border: 2rpx solid #c9a87c;
}
&--duration {
border: 2rpx solid #9b59b6;
}
}
.skeleton-card {
height: 360rpx;
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 400% 100%;
animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
0% { background-position: 100% 0; }
100% { background-position: -100% 0; }
}
.card-header {
padding: 12rpx 20rpx;
}
.header--times { background: linear-gradient(90deg, #1a1a2e, #2d2d5e); }
.header--duration { background: linear-gradient(90deg, #6c3483, #9b59b6); }
.header--trial { background: linear-gradient(90deg, #7d6608, #c9a87c); }
.card-type-label {
font-size: 22rpx;
font-weight: 600;
color: #ffffff;
letter-spacing: 2rpx;
}
.card-name {
font-size: 30rpx;
font-weight: 700;
color: #1a1a2e;
padding: 20rpx 20rpx 8rpx;
display: block;
}
.price-row {
display: flex;
align-items: baseline;
gap: 12rpx;
padding: 0 20rpx 12rpx;
}
.price-current {
font-size: 40rpx;
font-weight: 800;
color: #c9a87c;
}
.price-original {
font-size: 24rpx;
color: #bbb;
text-decoration: line-through;
}
.card-desc {
font-size: 22rpx;
color: #888;
padding: 0 20rpx 16rpx;
line-height: 1.5;
display: block;
}
.card-meta {
display: flex;
gap: 20rpx;
padding: 0 20rpx 20rpx;
flex: 1;
align-items: flex-end;
}
.meta-item {
display: flex;
align-items: baseline;
gap: 4rpx;
}
.meta-value {
font-size: 28rpx;
font-weight: 700;
color: #1a1a2e;
}
.meta-label {
font-size: 22rpx;
color: #999;
}
.buy-btn {
margin: 0 20rpx 24rpx;
background: #1a1a2e;
border-radius: 40rpx;
padding: 16rpx 0;
display: flex;
align-items: center;
justify-content: center;
}
.buy-btn-text {
font-size: 26rpx;
font-weight: 600;
color: #c9a87c;
}
.empty-state {
padding: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.empty-text {
font-size: 28rpx;
color: #bbb;
}
</style>