feat: 商城改版、约课页合并三Tab、课程已预约状态后端注入

- 商城页改为Tab切换(储值卡/会员卡)+卡片列表,新增商品详情页
- 约课页合并会员卡/团课/门票三Tab,日期横滑选择器
- 会员卡预约新增详情页+二次确认弹窗
- 课程列表已预约状态改为后端返回booked/booking_id/booking_type
- 前端移除冗余的loadBookings调用,直接读session.booked字段
- 导航栏仅首页custom,其余页面恢复原生导航栏
- membership API支持date参数筛选
This commit is contained in:
gqt
2026-07-13 20:37:31 +08:00
parent 5c97e8b1f8
commit b06cf69942
11 changed files with 1063 additions and 256 deletions
@@ -1,74 +1,59 @@
<template>
<view class="mall-page">
<view v-if="isLoading" class="load-more-tip">加载中...</view>
<view class="section">
<view class="section-header">
<text class="section-title">次卡套餐</text>
<view class="tab-bar">
<view
class="tab-item"
:class="{ active: activeTab === 'stored_value' }"
@tap="activeTab = 'stored_value'"
>
储值卡
</view>
<view class="card-list">
<view v-for="plan in plans" :key="`plan-${plan.id}`" class="card plan-card">
<view class="card-top">
<text class="item-name">{{ plan.name }}</text>
<text class="item-price">¥{{ plan.price }}</text>
</view>
<text class="item-meta">总次数 {{ plan.total_count }}</text>
<view v-if="plan.courses.length" class="course-tags">
<text v-for="course in plan.courses" :key="course.id" class="course-tag">{{ course.title }}</text>
</view>
<button
class="primary-button buy-btn"
:disabled="submittingId === `plan-${plan.id}`"
@tap="buyPlan(plan)"
>
{{ submittingId === `plan-${plan.id}` ? '提交中...' : '立即购买' }}
</button>
</view>
<view v-if="!isLoading && plans.length === 0" class="empty-state">暂无可购买的次卡套餐</view>
<view
class="tab-item"
:class="{ active: activeTab === 'membership' }"
@tap="activeTab = 'membership'"
>
会员卡
</view>
</view>
<view class="section">
<view class="section-header">
<text class="section-title">储蓄卡</text>
</view>
<view class="card-list">
<view v-for="card in cards" :key="`card-${card.id}`" class="card value-card">
<view class="card-top">
<text class="item-name">{{ card.name }}</text>
<text class="item-price">¥{{ card.price }}</text>
</view>
<view class="value-row">
<text class="value-label">支付</text>
<text class="value-pay">¥{{ card.price }}</text>
<text class="value-arrow">到账</text>
<text class="value-face">¥{{ card.face_value }}</text>
</view>
<button
class="primary-button buy-btn"
:disabled="submittingId === `card-${card.id}`"
@tap="buyCard(card)"
>
{{ submittingId === `card-${card.id}` ? '提交中...' : '立即购买' }}
</button>
<view v-if="isLoading" class="load-more-tip">加载中...</view>
<view v-else class="card-list">
<view
v-for="item in currentList"
:key="item.id"
class="card item-card"
@tap="goDetail(item)"
>
<view class="card-body">
<text class="item-name">{{ item.name }}</text>
<text class="item-price">¥{{ item.price }}</text>
</view>
<view v-if="!isLoading && cards.length === 0" class="empty-state">暂无可购买的储蓄卡</view>
</view>
<view v-if="currentList.length === 0" class="empty-state">暂无可购买的商品</view>
</view>
</view>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { membershipApi } from '@/modules/comprehensive/api/membership'
import { storedValueApi } from '@/modules/comprehensive/api/storedValue'
import { useComprehensiveSessionStore } from '@/modules/comprehensive/stores/session'
const session = useComprehensiveSessionStore()
const activeTab = ref('stored_value')
const plans = ref([])
const cards = ref([])
const isLoading = ref(false)
const submittingId = ref('')
const currentList = computed(() => {
if (activeTab.value === 'membership') {
return plans.value.map((p) => ({ ...p, _type: 'membership' }))
}
return cards.value.map((c) => ({ ...c, _type: 'stored_value' }))
})
onMounted(async () => {
await session.init()
@@ -89,39 +74,10 @@ const loadPage = async () => {
}
}
const ensureLogin = async () => {
if (session.isLoggedIn) return true
try {
await session.login()
return true
} catch (error) {
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
return false
}
}
const buyPlan = async (plan) => {
if (submittingId.value) return
if (!(await ensureLogin())) return
submittingId.value = `plan-${plan.id}`
try {
const order = await membershipApi.createMembershipOrder(plan.id)
uni.navigateTo({ url: `/pages/comprehensive/pay/index?order_id=${order.id}` })
} finally {
submittingId.value = ''
}
}
const buyCard = async (card) => {
if (submittingId.value) return
if (!(await ensureLogin())) return
submittingId.value = `card-${card.id}`
try {
const order = await storedValueApi.createOrder(card.id)
uni.navigateTo({ url: `/pages/comprehensive/pay/index?order_id=${order.id}` })
} finally {
submittingId.value = ''
}
const goDetail = (item) => {
uni.navigateTo({
url: `/pages/comprehensive/mall/detail?type=${item._type}&id=${item.id}`
})
}
defineExpose({ refresh: loadPage })
@@ -130,40 +86,70 @@ defineExpose({ refresh: loadPage })
<style lang="scss" scoped>
.mall-page {
min-height: 100vh;
padding: $spacing-md $spacing-md calc($spacing-lg + env(safe-area-inset-bottom));
background: $bg-color-soft;
}
.section {
margin-bottom: $spacing-lg;
.tab-bar {
position: sticky;
top: 0;
z-index: 10;
display: flex;
height: 88rpx;
background: $bg-color-main;
border-bottom: 1rpx solid $border-color;
}
.section-header {
margin-bottom: $spacing-sm;
.tab-item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 700;
color: $text-color-muted;
transition: all 0.2s ease;
}
.section-title {
.tab-item.active {
color: $text-color-main;
font-size: 32rpx;
font-weight: 900;
position: relative;
}
.tab-item.active::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 48rpx;
height: 4rpx;
border-radius: 2rpx;
background: $text-color-main;
}
.card-list {
display: flex;
flex-direction: column;
gap: $spacing-md;
gap: $spacing-sm;
padding: $spacing-md;
padding-bottom: calc($spacing-lg + env(safe-area-inset-bottom));
}
.plan-card,
.value-card {
.item-card {
display: flex;
flex-direction: column;
transition: all 0.2s ease;
}
.card-top {
.item-card:active {
background-color: $bg-color-hover;
}
.card-body {
display: flex;
justify-content: space-between;
align-items: baseline;
align-items: center;
gap: $spacing-sm;
}
@@ -171,7 +157,7 @@ defineExpose({ refresh: loadPage })
flex: 1;
color: $text-color-main;
font-size: 30rpx;
font-weight: 900;
font-weight: 800;
line-height: 1.35;
}
@@ -180,56 +166,4 @@ defineExpose({ refresh: loadPage })
font-size: 36rpx;
font-weight: 900;
}
.item-meta {
display: block;
margin-top: $spacing-sm;
color: $text-color-muted;
font-size: 24rpx;
}
.course-tags {
display: flex;
flex-wrap: wrap;
gap: $spacing-xs;
margin-top: $spacing-sm;
}
.course-tag {
padding: 4rpx 14rpx;
border-radius: $border-radius-sm;
background: $color-primary-light;
color: $color-primary;
font-size: 22rpx;
font-weight: 700;
}
.value-row {
display: flex;
align-items: center;
gap: $spacing-xs;
margin-top: $spacing-sm;
color: $text-color-muted;
font-size: 24rpx;
}
.value-label,
.value-arrow {
color: $text-color-light;
}
.value-pay {
color: $text-color-main;
font-weight: 800;
}
.value-face {
color: $color-success;
font-weight: 900;
}
.buy-btn {
margin-top: $spacing-md;
height: 80rpx;
}
</style>