Files
JayuCloud/YumiNail-Frontend/src/views/CartView.vue
T

1647 lines
51 KiB
Vue
Raw Normal View History

2026-04-03 11:44:32 +08:00
<template>
<div class="page">
<main class="content">
<a-empty v-if="!cartItems.length" class="empty-cart" description="购物车还是空的">
2026-04-03 11:44:32 +08:00
<a-button type="primary" @click="router.push('/products')">去逛作品</a-button>
</a-empty>
<template v-else>
<section class="checkout-hero" :class="{ 'has-issues': selectedCount && checkoutIssueCount }">
<div class="hero-main">
<p class="hero-eyebrow">购物车</p>
<h1>{{ selectedCount ? '准备结算' : '选择要结算的作品' }}</h1>
<p>{{ checkoutStatusText }}</p>
2026-04-03 11:44:32 +08:00
</div>
<div class="hero-total">
<span>合计</span>
<strong>¥{{ totalAmount.toFixed(2) }}</strong>
</div>
<div class="hero-metrics">
<div class="metric">
<span>已选项目</span>
<strong>{{ selectedCount }} 项</strong>
2026-04-03 11:44:32 +08:00
</div>
<div
class="metric"
:class="{ 'metric-warning': selectedCount && checkoutIssueCount }"
@click="focusFirstIssue"
2026-04-03 11:44:32 +08:00
>
<span>预约状态</span>
<strong>{{ checkoutIssueCount ? `${checkoutIssueCount} 项待完善` : '已就绪' }}</strong>
2026-04-03 11:44:32 +08:00
</div>
<div class="metric">
<span>作品数量</span>
<strong>{{ totalQuantity }} 件</strong>
2026-04-03 11:44:32 +08:00
</div>
</div>
</section>
2026-04-03 11:44:32 +08:00
<div v-if="selectedCount && firstCheckoutIssue" class="issue-callout">
<div>
<strong>{{ firstCheckoutIssue.message }}</strong>
<span>还有 {{ checkoutIssueCount }} 项需要处理后才能下单</span>
</div>
<a-button size="small" @click="focusFirstIssue">去完善</a-button>
2026-04-03 11:44:32 +08:00
</div>
<div class="checkout-layout">
<section class="cart-list">
<a-card
v-for="item in cartItems"
:key="item.id"
:ref="(element: unknown) => setItemRef(item.id, element)"
class="item-card"
:class="{ 'issue-card': item.selected && hasItemIssue(item) }"
>
<div class="item-row">
<a-checkbox class="item-check" v-model:checked="item.selected" @change="handleToggleSelect" />
<div class="thumb" @click="openProduct(item)">
<img v-if="item.productImage" :src="item.productImage" :alt="item.productTitle" />
<span v-else>{{ item.productTitle[0] }}</span>
</div>
<div class="item-main">
<div class="item-head">
<div class="item-copy">
<div class="title" @click="openProduct(item)">{{ item.productTitle }}</div>
<div class="item-subtitle">
<span>数量 {{ item.quantity }}</span>
<span v-if="item.approximateDuration">预计 {{ item.approximateDuration }}</span>
</div>
</div>
<div class="price">¥{{ Number(item.price || 0).toFixed(2) }}</div>
</div>
<button
type="button"
class="appointment-panel"
:class="{ issue: item.selected && hasItemIssue(item), ready: item.selected && !hasItemIssue(item) }"
@click="openBookingModal(item)"
>
<div class="appointment-content">
<div class="appointment-head">
<span>预约信息</span>
<strong>{{ appointmentStatusText(item) }}</strong>
</div>
<div class="appointment-grid">
<div>
<span>美甲师</span>
<strong>{{ item.artist?.name || '待选择' }}</strong>
</div>
<div>
<span>时间</span>
<strong>{{ item.appointmentTime ? formatAppointmentDisplay(item.appointmentTime) : '待选择' }}</strong>
</div>
</div>
</div>
<RightOutlined />
</button>
<div class="actions">
<div class="qty">
<a-button size="small" :disabled="item.quantity <= 1" @click="changeQuantity(item, -1)">-</a-button>
<span>{{ item.quantity }}</span>
<a-button size="small" :disabled="item.quantity >= 99" @click="changeQuantity(item, 1)">+</a-button>
</div>
<a-popconfirm title="确认删除这件作品吗?" ok-text="确认" cancel-text="取消" @confirm="removeItem(item)">
<a-button type="text" danger size="small">
<DeleteOutlined />
</a-button>
</a-popconfirm>
</div>
</div>
</div>
</a-card>
</section>
<aside class="checkout-side">
<button
v-if="selectedCount"
type="button"
class="coupon-panel"
@click="openCouponModal"
>
<div>
<span>优惠方式</span>
<strong>{{ selectedCoupon ? formatCouponDisplay(selectedCoupon) : '不使用优惠' }}</strong>
</div>
<em v-if="selectedCoupon">-¥{{ discountAmount.toFixed(2) }}</em>
<RightOutlined />
</button>
<section class="summary-panel">
<div class="summary-row"><span>选中项目</span><strong>{{ selectedCount }} 项</strong></div>
<div class="summary-row"><span>作品数量</span><strong>{{ totalQuantity }} 件</strong></div>
<div class="summary-row"><span>小计</span><strong>¥{{ subtotal.toFixed(2) }}</strong></div>
<div v-if="selectedCoupon" class="summary-row discount"><span>优惠</span><strong>-¥{{ discountAmount.toFixed(2) }}</strong></div>
<div class="summary-row total"><span>合计</span><strong>¥{{ totalAmount.toFixed(2) }}</strong></div>
</section>
</aside>
</div>
</template>
2026-04-03 11:44:32 +08:00
</main>
<footer v-if="cartItems.length" class="footer">
<div class="footer-summary">
<span>{{ selectedCount ? `已选 ${selectedCount} 项` : '还未选择作品' }}</span>
<strong>¥{{ totalAmount.toFixed(2) }}</strong>
</div>
2026-04-03 11:44:32 +08:00
<a-button
type="primary"
size="large"
class="checkout-button"
2026-04-03 11:44:32 +08:00
:loading="submittingOrder"
:disabled="submittingOrder || !selectedCount"
2026-04-03 11:44:32 +08:00
@click="checkout"
>
{{ checkoutActionText }}
2026-04-03 11:44:32 +08:00
</a-button>
</footer>
<a-modal
v-model:open="showCouponModal"
title="选择优惠方式"
wrap-class-name="cart-coupon-modal-wrap"
class="cart-coupon-modal"
ok-text="确认"
cancel-text="取消"
:ok-button-props="couponModalOkButtonProps"
:cancel-button-props="couponModalCancelButtonProps"
@ok="applyCouponSelection"
@cancel="showCouponModal = false"
>
2026-04-03 11:44:32 +08:00
<a-radio-group v-model:value="couponSelectionKey" class="coupon-options">
<a-radio :value="NO_COUPON_KEY">不使用优惠</a-radio>
<a-radio v-for="coupon in availableCoupons" :key="getCouponKey(coupon)" :value="getCouponKey(coupon)">
{{ formatCouponDisplay(coupon) }}
</a-radio>
</a-radio-group>
<div class="coupon-tip">
系统会按本次订单金额自动预选减免最高的一张券,也可以手动选择不使用优惠。
2026-04-03 11:44:32 +08:00
</div>
</a-modal>
<a-modal v-model:open="showBookingModal" :title="bookingTitle" @ok="confirmBooking" @cancel="closeBookingModal">
<div class="modal-section">
<div class="section-title">美甲师</div>
<div v-if="availableArtists.length" class="artist-list">
<button
v-for="artist in availableArtists"
:key="artist.id"
type="button"
class="artist-option"
:class="{ active: sameId(draftArtistId, artist.id) }"
@click="draftArtistId = artist.id"
>
<img v-if="artist.avatar" :src="artist.avatar" :alt="artist.name" />
<span>{{ artist.name }}</span>
<em v-if="artist.roleLabel">{{ artist.roleLabel }}</em>
2026-04-03 11:44:32 +08:00
</button>
</div>
<a-empty v-else description="暂无可预约美甲师" />
</div>
<div class="modal-section">
<div class="section-title">预约时间</div>
<a-date-picker
v-model:value="draftAppointmentTime"
class="time-picker"
popup-class-name="yumi-date-picker-panel yumi-date-time-panel"
2026-04-03 11:44:32 +08:00
style="width: 100%"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
input-read-only
:disabled-date="disablePastAppointmentDate"
:disabled-time="disablePastAppointmentTime"
:show-time="{ minuteStep: 30, secondStep: 60, hideDisabledOptions: true }"
placeholder="请选择预约时间"
/>
<div class="quick-time-grid">
<button
v-for="slot in quickAppointmentSlots"
:key="slot.value"
type="button"
class="quick-time"
:class="{ active: draftAppointmentTime === slot.value }"
@click="draftAppointmentTime = slot.value"
>
<span>{{ slot.label }}</span>
<strong>{{ slot.time }}</strong>
</button>
</div>
2026-04-03 11:44:32 +08:00
<div class="helper">{{ bookingHelperText }}</div>
</div>
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* CartView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
2026-04-03 11:44:32 +08:00
import { computed, inject, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { DeleteOutlined, RightOutlined } from '@ant-design/icons-vue'
2026-04-03 11:44:32 +08:00
import { message } from 'ant-design-vue'
import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'
2026-04-03 11:44:32 +08:00
import { cartApi } from '../api/cart'
2026-05-23 18:44:57 +08:00
/**
* Purpose: UserCoupon supports CartView.vue by holding or executing the user coupon page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
import { couponApi, type UserCoupon } from '../api/coupon'
import { fileApi } from '../api/index'
import { orderApi } from '../api/order'
import { shopApi } from '../api/shop'
import type { IdType } from '@/utils/id'
import { sameId, toOptionalIdString } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
2026-05-23 18:44:57 +08:00
/**
* Purpose: router supports CartView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const router = useRouter()
2026-05-23 18:44:57 +08:00
/**
* Purpose: updateCartCount supports CartView.vue by holding or executing the update cart count page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
2026-05-23 18:44:57 +08:00
/**
* Purpose: NO_COUPON_KEY supports CartView.vue by holding or executing the no coupon key page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const NO_COUPON_KEY = 'NONE'
2026-05-23 18:44:57 +08:00
/**
* Purpose: ButtonPropsWithClass supports CartView.vue by holding or executing the button props with class page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
type ButtonPropsWithClass = ButtonProps & { class?: string }
const couponModalOkButtonProps: ButtonPropsWithClass = { class: 'cart-coupon-modal__ok' }
const couponModalCancelButtonProps: ButtonPropsWithClass = { class: 'cart-coupon-modal__cancel' }
2026-04-03 11:44:32 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: ArtistOption supports CartView.vue by holding or executing the artist option page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
interface ArtistOption {
id: IdType
name: string
avatar?: string
userType?: number
roleLabel?: string
participateProduction?: boolean
2026-04-03 11:44:32 +08:00
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: CartItem supports CartView.vue by holding or executing the cart item page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
interface CartItem {
id: IdType
productId: IdType
shopId?: IdType
productTitle: string
productImage: string
originalProductImage?: string
price: number
quantity: number
totalPrice: number
tags: string
tagNames?: string
approximateDuration?: string
bookableArtists?: string
availableBookableArtistCount?: number
bookableArtistRestricted?: boolean
availableArtists?: ArtistOption[]
appointmentTime?: string
selected: boolean
artistId?: IdType
artist?: ArtistOption
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: CheckoutIssue supports CartView.vue by holding or executing the checkout issue page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
interface CheckoutIssue {
key: string
message: string
itemId?: IdType
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: cartItems supports CartView.vue by holding or executing the cart items page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const cartItems = ref<CartItem[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: imageIdCache supports CartView.vue by holding or executing the image id cache page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const imageIdCache = ref<Record<string, string>>({})
2026-05-23 18:44:57 +08:00
/**
* Purpose: itemRefs supports CartView.vue by holding or executing the item refs page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const itemRefs = ref<Record<string, HTMLElement>>({})
2026-05-23 18:44:57 +08:00
/**
* Purpose: availableCoupons supports CartView.vue by holding or executing the available coupons page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const availableCoupons = ref<UserCoupon[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: selectedCoupon supports CartView.vue by holding or executing the selected coupon page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const selectedCoupon = ref<UserCoupon | null>(null)
/** couponSelectionKey is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const couponSelectionKey = ref(NO_COUPON_KEY)
/** couponSelectionTouched is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const couponSelectionTouched = ref(false)
/** showCouponModal is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const showCouponModal = ref(false)
/** showBookingModal is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const showBookingModal = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: currentItem supports CartView.vue by holding or executing the current item page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const currentItem = ref<CartItem | null>(null)
2026-05-23 18:44:57 +08:00
/**
* Purpose: availableArtists supports CartView.vue by holding or executing the available artists page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const availableArtists = ref<ArtistOption[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: draftArtistId supports CartView.vue by holding or executing the draft artist id page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-04-03 11:44:32 +08:00
const draftArtistId = ref<IdType>()
/** draftAppointmentTime is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const draftAppointmentTime = ref('')
/** currentShopHours is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const currentShopHours = ref('')
/** submittingOrder is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const submittingOrder = ref(false)
/** selectedItems is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const selectedItems = computed(() => cartItems.value.filter(item => item.selected))
/** selectedCount is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const selectedCount = computed(() => selectedItems.value.length)
/** totalQuantity is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const totalQuantity = computed(() => selectedItems.value.reduce((sum, item) => sum + item.quantity, 0))
/** subtotal is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const subtotal = computed(() => selectedItems.value.reduce((sum, item) => sum + Number(item.price || 0) * item.quantity, 0))
/** discountAmount is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const discountAmount = computed(() => calculateCouponDiscount(selectedCoupon.value, subtotal.value))
/** totalAmount is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const totalAmount = computed(() => Math.max(0, subtotal.value - discountAmount.value))
/** bookingTitle is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const bookingTitle = computed(() => currentItem.value ? `为 ${currentItem.value.productTitle} 选择预约信息` : '选择预约信息')
/** bookingHelperText is a reactive state variable used by the template and event handlers. */
2026-04-03 11:44:32 +08:00
const bookingHelperText = computed(() => {
const texts: string[] = []
if (currentShopHours.value) texts.push(`门店营业时间:${currentShopHours.value}`)
if (currentItem.value?.approximateDuration) texts.push(`预计时长:${currentItem.value.approximateDuration}`)
return texts.join(' · ') || '请选择至少晚于当前 5 分钟的预约时间'
})
/** quickAppointmentSlots is a reactive state variable used by the template and event handlers. */
const quickAppointmentSlots = computed(() => {
const now = getMinAppointmentDate()
const today = new Date(now)
const nextHour = new Date(now)
nextHour.setMinutes(now.getMinutes() > 30 ? 0 : 30, 0, 0)
if (nextHour.getTime() < now.getTime()) {
nextHour.setHours(nextHour.getHours() + 1)
}
2026-04-03 11:44:32 +08:00
const tomorrowMorning = buildAppointmentDate(1, 10, 0)
const tomorrowAfternoon = buildAppointmentDate(1, 14, 0)
const afterTomorrowAfternoon = buildAppointmentDate(2, 15, 0)
const weekendMorning = nextWeekendMorning(today)
return [nextHour, tomorrowMorning, tomorrowAfternoon, afterTomorrowAfternoon, weekendMorning]
.filter((date, index, list) => date.getTime() >= now.getTime() && list.findIndex(item => item.getTime() === date.getTime()) === index)
.slice(0, 5)
.map(date => ({
value: formatAppointmentValue(date),
label: quickDateLabel(date),
time: `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
}))
})
/** getMinAppointmentDate is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const getMinAppointmentDate = () => {
const date = new Date()
date.setSeconds(0, 0)
date.setMinutes(date.getMinutes() + 5)
return date
}
/** getDayBoundary is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const getDayBoundary = (date: Date) => {
const boundary = new Date(date)
boundary.setHours(0, 0, 0, 0)
return boundary.getTime()
}
/** buildAppointmentDate is a local helper used by this page script. */
const buildAppointmentDate = (daysFromToday: number, hour: number, minute: number) => {
const date = new Date()
date.setDate(date.getDate() + daysFromToday)
date.setHours(hour, minute, 0, 0)
return date
}
/** nextWeekendMorning is a local helper used by this page script. */
const nextWeekendMorning = (fromDate: Date) => {
const date = new Date(fromDate)
const day = date.getDay()
const offset = day === 0 ? 6 : 6 - day
date.setDate(date.getDate() + Math.max(1, offset))
date.setHours(10, 0, 0, 0)
return date
}
/** formatAppointmentValue is a local helper used by this page script. */
const formatAppointmentValue = (date: Date) => {
/** pad is a local helper used by this page script. */
const pad = (value: number) => String(value).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:00`
}
/** quickDateLabel is a local helper used by this page script. */
const quickDateLabel = (date: Date) => {
const today = new Date()
const tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
if (date.toDateString() === today.toDateString()) return '今天'
if (date.toDateString() === tomorrow.toDateString()) return '明天'
return `${date.getMonth() + 1}月${date.getDate()}日`
}
/** getCouponKey is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const getCouponKey = (coupon: UserCoupon) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
/** setItemRef is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const setItemRef = (itemId: IdType, element: unknown) => {
const refKey = toOptionalIdString(itemId)
if (!refKey) {
return
}
if (element && (element as any).$el) {
itemRefs.value[refKey] = (element as any).$el as HTMLElement
return
}
if (element instanceof HTMLElement) {
itemRefs.value[refKey] = element
return
}
delete itemRefs.value[refKey]
}
/** formatCouponDisplay is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const formatCouponDisplay = (coupon: UserCoupon) => {
const badge = coupon.sourceType === 'SYSTEM_VIP' ? '[VIP 自动券]' : '[用户券]'
const benefit = coupon.couponType === 1
? `${coupon.discountValue} 折`
: `满 ${coupon.minAmount} 减 ${coupon.reduceAmount}`
return `${badge} ${coupon.couponName} ${benefit}`
}
/** calculateCouponDiscount is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const calculateCouponDiscount = (coupon: UserCoupon | null, amount: number) => {
if (!coupon || amount <= 0) {
return 0
}
if (coupon.couponType === 1) {
const discountValue = Number(coupon.discountValue || 0)
return discountValue ? amount - amount * discountValue / 10 : 0
}
if (coupon.couponType === 2) {
return Number(coupon.reduceAmount || 0)
}
return 0
}
/** findBestCoupon is a local helper used by this page script. */
const findBestCoupon = (coupons: UserCoupon[]) => {
2026-04-03 11:44:32 +08:00
return coupons
.sort((left, right) => calculateCouponDiscount(right, subtotal.value) - calculateCouponDiscount(left, subtotal.value))[0] || null
}
/** formatAppointmentDisplay is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const formatAppointmentDisplay = (value?: string) => value ? value.replace('T', ' ').slice(0, 16) : '未选择预约时间'
/** isPastAppointment is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const isPastAppointment = (value?: string) => !!value && new Date(value.replace(' ', 'T')).getTime() < getMinAppointmentDate().getTime()
/** hasItemIssue is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const hasItemIssue = (item: CartItem) => !item.artistId || !item.appointmentTime || isPastAppointment(item.appointmentTime)
/** appointmentStatusText is a local helper used by this page script. */
const appointmentStatusText = (item: CartItem) => {
if (!item.selected) {
return '未选中'
}
if (!item.artistId) {
return '待选美甲师'
}
if (!item.appointmentTime) {
return '待选时间'
}
if (isPastAppointment(item.appointmentTime)) {
return '时间已过期'
}
return '已完成'
}
2026-04-03 11:44:32 +08:00
// 购物车结算口径要求单店铺、单美甲师、完整预约信息,避免后端拆单和排班出现歧义。
const checkoutIssues = computed<CheckoutIssue[]>(() => {
const items = selectedItems.value
const issues: CheckoutIssue[] = []
const firstMissingArtist = items.find(item => !item.artistId)
if (firstMissingArtist) {
issues.push({ key: 'artist', message: `请先为“${firstMissingArtist.productTitle}”选择美甲师`, itemId: firstMissingArtist.id })
}
const firstMissingTime = items.find(item => !item.appointmentTime)
if (firstMissingTime) {
issues.push({ key: 'time', message: `请先为“${firstMissingTime.productTitle}”选择预约时间`, itemId: firstMissingTime.id })
}
const firstExpiredTime = items.find(item => isPastAppointment(item.appointmentTime))
if (firstExpiredTime) {
issues.push({ key: 'expired', message: `“${firstExpiredTime.productTitle}”的预约时间已过期,请重新选择`, itemId: firstExpiredTime.id })
}
const selectedShopIds = new Set(
items
.map(item => toOptionalIdString(item.shopId))
.filter((shopId): shopId is string => Boolean(shopId))
)
if (selectedShopIds.size > 1) {
issues.push({ key: 'shop', message: '跨店铺项目请分开结算', itemId: items[0]?.id })
}
const selectedArtistIds = new Set(
items
.map(item => toOptionalIdString(item.artistId))
.filter((artistId): artistId is string => Boolean(artistId))
)
if (selectedArtistIds.size > 1) {
issues.push({ key: 'artist-mix', message: '不同美甲师的项目请分开结算', itemId: items[0]?.id })
}
return issues
})
/** checkoutIssueCount is a reactive state variable used by the template and event handlers. */
const checkoutIssueCount = computed(() => checkoutIssues.value.length)
/** firstCheckoutIssue is a reactive state variable used by the template and event handlers. */
const firstCheckoutIssue = computed(() => checkoutIssues.value[0])
/** checkoutStatusText is a reactive state variable used by the template and event handlers. */
const checkoutStatusText = computed(() => {
if (!selectedCount.value) {
return '勾选需要结算的作品,完善预约信息后即可提交订单'
}
if (checkoutIssueCount.value) {
return `还有 ${checkoutIssueCount.value} 项预约信息待完善`
}
return selectedCoupon.value ? '预约信息已完成,优惠已计算' : '预约信息已完成,可以提交订单'
})
/** checkoutActionText is a reactive state variable used by the template and event handlers. */
const checkoutActionText = computed(() => {
if (!selectedCount.value) {
return '先选择作品'
}
return checkoutIssueCount.value ? '完善预约信息' : '去结算'
})
/** scrollToIssue is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const scrollToIssue = (issue?: CheckoutIssue) => {
const itemId = toOptionalIdString(issue?.itemId)
if (!itemId) {
return
}
const target = itemRefs.value[itemId]
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'center' })
}
}
/** focusFirstIssue is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const focusFirstIssue = () => {
scrollToIssue(checkoutIssues.value[0])
}
/** loadCartItems is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const loadCartItems = async () => {
const response = await cartApi.getCartList() as unknown as any[]
cartItems.value = (response || []).map(item => ({
...item,
selected: true,
originalProductImage: item.productImage,
productImage: '',
appointmentTime: item.appointmentTime
}))
couponSelectionTouched.value = false
couponSelectionKey.value = NO_COUPON_KEY
selectedCoupon.value = null
await Promise.all([loadProductImages(), loadAvailableCoupons()])
}
/** loadProductImages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const loadProductImages = async () => {
for (const item of cartItems.value) {
if (!item.originalProductImage) continue
const match = item.originalProductImage.replace(/<[^>]*>/g, '').match(/\/api\/file\/get\/(\d+)/)
if (!match?.[1]) continue
const imageId = match[1]
try {
if (!imageIdCache.value[imageId]) {
imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
}
item.productImage = imageIdCache.value[imageId] || ''
} catch {
item.productImage = ''
}
}
}
/** loadAvailableCoupons is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const loadAvailableCoupons = async () => {
const currentSelectedKey = selectedCoupon.value ? getCouponKey(selectedCoupon.value) : couponSelectionKey.value
const selectedShopId = selectedItems.value[0]?.shopId
if (!selectedItems.value.length || subtotal.value <= 0) {
availableCoupons.value = []
selectedCoupon.value = null
couponSelectionKey.value = NO_COUPON_KEY
return
}
try {
// 这里只做“最佳 VIP 自动券”兜底预选,普通用户券必须显式点选后才会消耗。
const tags = new Set<string>()
selectedItems.value.forEach(item => {
item.tagNames?.split(',').map(tag => tag.trim()).forEach(tag => {
if (tag) {
tags.add(tag)
}
})
})
const data = await couponApi.getAvailableCoupons(Array.from(tags).join(','), subtotal.value, selectedShopId) as unknown as UserCoupon[]
availableCoupons.value = Array.isArray(data) ? data : []
const matchedCoupon = availableCoupons.value.find(coupon => getCouponKey(coupon) === currentSelectedKey) || null
if (matchedCoupon) {
selectedCoupon.value = matchedCoupon
couponSelectionKey.value = getCouponKey(matchedCoupon)
return
}
if (couponSelectionTouched.value && currentSelectedKey === NO_COUPON_KEY) {
selectedCoupon.value = null
couponSelectionKey.value = NO_COUPON_KEY
return
}
couponSelectionTouched.value = false
const defaultCoupon = findBestCoupon(availableCoupons.value)
if (defaultCoupon) {
selectedCoupon.value = defaultCoupon
couponSelectionKey.value = getCouponKey(defaultCoupon)
2026-04-03 11:44:32 +08:00
} else {
selectedCoupon.value = null
couponSelectionKey.value = NO_COUPON_KEY
}
} catch (error) {
console.error('获取可用优惠失败:', error)
availableCoupons.value = []
selectedCoupon.value = null
couponSelectionKey.value = NO_COUPON_KEY
}
}
/** handleToggleSelect is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const handleToggleSelect = async () => {
await runWithGlobalLoading(() => loadAvailableCoupons())
}
/** changeQuantity is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const changeQuantity = async (item: CartItem, delta: number) => {
const next = item.quantity + delta
if (next < 1 || next > 99) return
item.quantity = next
try {
await runWithGlobalLoading(async () => {
await cartApi.updateCartQuantity({ productId: item.productId, quantity: next })
await loadAvailableCoupons()
})
await updateCartCount()
} catch (error: any) {
2026-04-03 11:44:32 +08:00
item.quantity -= delta
message.error(error?.message || '更新数量失败')
2026-04-03 11:44:32 +08:00
}
}
/** removeItem is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const removeItem = async (item: CartItem) => {
try {
await runWithGlobalLoading(async () => {
await cartApi.removeFromCart(item.productId)
cartItems.value = cartItems.value.filter(current => !sameId(current.id, item.id))
await loadAvailableCoupons()
})
await updateCartCount()
message.success('作品已删除')
} catch (error: any) {
message.error(error?.message || '删除作品失败')
2026-04-03 11:44:32 +08:00
}
}
/** openProduct is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const openProduct = (item: CartItem) => {
router.push('/product/' + item.productId)
}
/** openBookingModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const openBookingModal = async (item: CartItem) => {
currentItem.value = item
draftArtistId.value = item.artistId
draftAppointmentTime.value = item.appointmentTime || ''
showBookingModal.value = true
await runWithGlobalLoading(() => Promise.all([loadArtists(item), loadShopHours(item.shopId)]))
}
/** loadArtists is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const loadArtists = async (item: CartItem) => {
// 购物车里保存的是后端已经按作品可约范围裁剪过的美甲师列表,这里只做前端展示和 ID 保真。
availableArtists.value = Array.isArray(item.availableArtists)
? item.availableArtists
.filter(artist => artist && artist.id !== undefined && artist.id !== null)
.map(artist => ({
id: artist.id,
name: artist.name,
avatar: artist.avatar,
userType: artist.userType,
roleLabel: artist.roleLabel,
participateProduction: artist.participateProduction
2026-04-03 11:44:32 +08:00
}))
: []
if (draftArtistId.value && !availableArtists.value.some(artist => sameId(artist.id, draftArtistId.value))) {
draftArtistId.value = undefined
}
}
/** loadShopHours is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const loadShopHours = async (shopId?: IdType) => {
currentShopHours.value = ''
if (!shopId) return
try {
const shop = await shopApi.getShopById(shopId) as any
currentShopHours.value = shop?.businessHours || ''
} catch {
currentShopHours.value = ''
}
}
/** disablePastAppointmentDate is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const disablePastAppointmentDate = (current: any) => {
if (!current) return false
return current.valueOf() < getDayBoundary(new Date())
}
/** disablePastAppointmentTime is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const disablePastAppointmentTime = (current: any) => {
if (!current || typeof current.format !== 'function') {
return {}
}
const minDate = getMinAppointmentDate()
const minDateText = [
minDate.getFullYear(),
String(minDate.getMonth() + 1).padStart(2, '0'),
String(minDate.getDate()).padStart(2, '0')
].join('-')
if (current.format('YYYY-MM-DD') !== minDateText) {
return {}
}
const minHour = minDate.getHours()
const minMinute = minDate.getMinutes()
return {
disabledHours: () => Array.from({ length: minHour }, (_, index) => index),
disabledMinutes: (selectedHour: number) => selectedHour === minHour
? Array.from({ length: minMinute }, (_, index) => index)
: [],
disabledSeconds: () => []
}
}
/** closeBookingModal is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const closeBookingModal = () => {
showBookingModal.value = false
currentItem.value = null
draftArtistId.value = undefined
draftAppointmentTime.value = ''
availableArtists.value = []
currentShopHours.value = ''
}
/** confirmBooking is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const confirmBooking = () => {
if (!currentItem.value) return closeBookingModal()
if (!draftArtistId.value) return message.warning('请先选择美甲师')
if (!draftAppointmentTime.value) return message.warning('请选择预约时间')
if (isPastAppointment(draftAppointmentTime.value)) return message.warning('预约时间至少需要晚于当前 5 分钟')
currentItem.value.artistId = draftArtistId.value
currentItem.value.artist = availableArtists.value.find(artist => sameId(artist.id, draftArtistId.value))
currentItem.value.appointmentTime = draftAppointmentTime.value
closeBookingModal()
}
/** openCouponModal is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const openCouponModal = () => {
couponSelectionKey.value = selectedCoupon.value ? getCouponKey(selectedCoupon.value) : NO_COUPON_KEY
showCouponModal.value = true
}
/** applyCouponSelection is a local helper used by this page script. */
2026-04-03 11:44:32 +08:00
const applyCouponSelection = () => {
couponSelectionTouched.value = true
if (couponSelectionKey.value === NO_COUPON_KEY) {
selectedCoupon.value = null
} else {
selectedCoupon.value = availableCoupons.value.find(coupon => getCouponKey(coupon) === couponSelectionKey.value) || null
}
showCouponModal.value = false
}
/** checkout is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-04-03 11:44:32 +08:00
const checkout = async () => {
if (submittingOrder.value) {
return
}
const items = selectedItems.value
if (!items.length) {
return message.warning('请先选择要结算的作品')
}
const firstIssue = checkoutIssues.value[0]
if (firstIssue) {
message.warning(firstIssue.message)
scrollToIssue(firstIssue)
return
}
submittingOrder.value = true
try {
await runWithGlobalLoading(() => orderApi.createOrder({
couponId: selectedCoupon.value?.id,
couponSourceType: selectedCoupon.value?.sourceType || (couponSelectionTouched.value && !selectedCoupon.value ? NO_COUPON_KEY : undefined),
items: items.map(item => ({
productId: item.productId,
quantity: item.quantity,
artistId: item.artistId,
appointmentTime: item.appointmentTime
}))
}))
message.success('订单创建成功')
let followupWarningShown = false
try {
await runWithGlobalLoading(() => loadCartItems())
await updateCartCount()
} catch (followupError) {
followupWarningShown = true
console.error('订单创建后刷新购物车失败:', followupError)
message.warning('订单已创建,但购物车刷新失败,请前往订单页查看')
}
try {
await router.push('/orders')
} catch (navigationError) {
console.error('订单创建后跳转订单页失败:', navigationError)
if (!followupWarningShown) {
message.warning('订单已创建,但跳转订单页失败,请手动前往订单页查看')
}
}
} catch (error: any) {
console.error('创建订单失败:', error)
message.error(error?.message || '创建订单失败')
} finally {
submittingOrder.value = false
}
}
onMounted(async () => {
try {
await loadCartItems()
} catch (error: any) {
message.error(error?.message || '获取购物车数据失败')
2026-04-03 11:44:32 +08:00
}
})
</script>
<style scoped>
.page {
min-height: 100vh;
color: var(--text-primary);
background:
linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.92)),
var(--theme-background-image),
var(--theme-page-bg);
background-size: cover, cover, auto;
background-position: center top;
2026-04-03 11:44:32 +08:00
}
.content {
max-width: 1040px;
2026-04-03 11:44:32 +08:00
margin: 0 auto;
padding: 16px 16px calc(150px + env(safe-area-inset-bottom));
2026-04-03 11:44:32 +08:00
}
.empty-cart {
padding: 96px 16px;
2026-04-03 11:44:32 +08:00
}
.checkout-hero {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
margin-bottom: 14px;
padding: 18px;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-gradient-soft);
box-shadow: 0 16px 38px rgba(48, 37, 44, 0.08);
}
.checkout-hero.has-issues {
border-color: var(--theme-accent);
}
.hero-main {
min-width: 0;
}
.hero-eyebrow {
margin: 0 0 6px;
font-size: 12px;
font-weight: 700;
color: var(--theme-primary);
}
.hero-main h1 {
margin: 0;
font-size: 26px;
line-height: 1.18;
letter-spacing: 0;
}
.hero-main p {
margin: 8px 0 0;
color: var(--text-secondary);
line-height: 1.5;
}
.hero-total {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 12px;
padding-top: 2px;
}
.hero-total span,
.metric span,
.appointment-head span,
.appointment-grid span,
.summary-row span,
.coupon-panel span,
.footer-summary span,
.item-subtitle {
color: var(--text-secondary);
}
.hero-total strong {
color: var(--theme-accent);
font-size: 30px;
line-height: 1;
}
.hero-metrics {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
}
.metric {
min-width: 0;
padding: 10px;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent);
}
.metric span,
.metric strong {
display: block;
}
.metric span {
margin-bottom: 4px;
font-size: 12px;
}
.metric strong {
overflow: hidden;
color: var(--theme-primary);
font-size: 14px;
text-overflow: ellipsis;
white-space: nowrap;
}
.metric-warning {
cursor: pointer;
border-color: var(--theme-accent);
}
.metric-warning strong {
color: var(--theme-accent);
}
.issue-callout {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 14px;
padding: 12px;
border: 1px solid var(--theme-border);
border-left: 4px solid var(--theme-accent);
border-radius: 8px;
background: var(--theme-card-bg);
}
.issue-callout strong,
.issue-callout span {
display: block;
}
.issue-callout strong {
margin-bottom: 4px;
color: var(--theme-accent);
}
.issue-callout span {
color: var(--text-secondary);
font-size: 12px;
}
.checkout-layout {
display: grid;
gap: 14px;
}
.cart-list {
display: grid;
gap: 12px;
}
.checkout-side {
display: grid;
gap: 12px;
align-content: start;
}
.item-card {
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-card-bg);
box-shadow: 0 12px 30px rgba(48, 37, 44, 0.06);
}
.item-card :deep(.ant-card-body) {
padding: 12px;
2026-04-03 11:44:32 +08:00
}
.issue-card {
border-color: var(--theme-accent);
box-shadow: var(--theme-focus-shadow);
2026-04-03 11:44:32 +08:00
}
.item-row {
display: grid;
grid-template-columns: auto 84px minmax(0, 1fr);
2026-04-03 11:44:32 +08:00
gap: 12px;
align-items: start;
}
.item-check {
padding-top: 30px;
2026-04-03 11:44:32 +08:00
}
.thumb {
width: 84px;
height: 84px;
border-radius: 12px;
overflow: hidden;
background: var(--theme-primary-soft);
2026-04-03 11:44:32 +08:00
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.thumb img {
width: 100%;
height: 100%;
object-fit: cover;
}
.item-main {
min-width: 0;
}
.item-head {
display: flex;
justify-content: space-between;
gap: 10px;
margin-bottom: 10px;
}
.item-copy {
min-width: 0;
2026-04-03 11:44:32 +08:00
}
.title {
font-size: 15px;
font-weight: 700;
line-height: 1.38;
2026-04-03 11:44:32 +08:00
cursor: pointer;
}
.item-subtitle {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 5px;
font-size: 12px;
}
2026-04-03 11:44:32 +08:00
.price {
flex-shrink: 0;
color: var(--theme-accent);
2026-04-03 11:44:32 +08:00
font-weight: 700;
white-space: nowrap;
2026-04-03 11:44:32 +08:00
}
.appointment-panel {
width: 100%;
2026-04-03 11:44:32 +08:00
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 10px;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-primary-soft);
color: inherit;
text-align: left;
2026-04-03 11:44:32 +08:00
cursor: pointer;
}
.appointment-panel.issue {
border-color: var(--theme-accent);
background: var(--theme-primary-soft);
2026-04-03 11:44:32 +08:00
}
.appointment-panel.ready {
border-color: var(--theme-border);
background: var(--theme-card-bg);
2026-04-03 11:44:32 +08:00
}
.appointment-content {
2026-04-03 11:44:32 +08:00
flex: 1;
min-width: 0;
}
.appointment-head {
display: flex;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.appointment-head strong {
color: var(--theme-primary);
white-space: nowrap;
}
.appointment-panel.issue .appointment-head strong {
color: var(--theme-accent);
}
.appointment-grid {
display: grid;
gap: 6px;
}
.appointment-grid div {
min-width: 0;
}
.appointment-grid span,
.appointment-grid strong {
display: block;
2026-04-03 11:44:32 +08:00
font-size: 13px;
}
.coupon-tip,
.helper {
color: var(--text-secondary);
2026-04-03 11:44:32 +08:00
font-size: 12px;
}
.quick-time-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
gap: 8px;
margin: 10px 0;
}
.quick-time {
display: grid;
gap: 2px;
padding: 10px 12px;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-card-bg);
color: var(--text-primary);
text-align: left;
cursor: pointer;
transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.quick-time:hover,
.quick-time.active {
border-color: var(--theme-primary);
background: var(--theme-primary-soft);
transform: translateY(-1px);
}
.quick-time span {
color: var(--text-secondary);
font-size: 12px;
}
.quick-time strong {
font-size: 16px;
}
2026-04-03 11:44:32 +08:00
.actions,
.qty,
.summary-row {
2026-04-03 11:44:32 +08:00
display: flex;
align-items: center;
justify-content: space-between;
}
.actions {
margin-top: 10px;
}
2026-04-03 11:44:32 +08:00
.qty {
gap: 8px;
}
.coupon-panel,
.summary-panel {
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-card-bg);
box-shadow: 0 12px 30px rgba(48, 37, 44, 0.06);
}
.coupon-panel {
width: 100%;
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto;
gap: 10px;
align-items: center;
padding: 13px;
color: inherit;
text-align: left;
cursor: pointer;
}
.coupon-panel span,
.coupon-panel strong {
display: block;
}
.coupon-panel span {
margin-bottom: 4px;
font-size: 12px;
}
.coupon-panel strong {
overflow: hidden;
color: var(--text-primary);
text-overflow: ellipsis;
white-space: nowrap;
}
.coupon-panel em {
color: var(--theme-accent);
font-style: normal;
font-weight: 700;
white-space: nowrap;
}
.summary-panel {
padding: 13px;
2026-04-03 11:44:32 +08:00
}
.summary-row {
gap: 12px;
padding: 8px 0;
border-bottom: 1px solid var(--theme-border);
}
.summary-row strong {
color: var(--text-primary);
white-space: nowrap;
}
.summary-row.discount strong,
.summary-row.total strong {
color: var(--theme-accent);
2026-04-03 11:44:32 +08:00
}
.summary-row.total {
border-bottom: 0;
2026-04-03 11:44:32 +08:00
font-weight: 700;
}
.footer {
position: fixed;
left: 0;
right: 0;
2026-04-03 11:44:32 +08:00
bottom: 60px;
z-index: 20;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.94);
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
border-top: 1px solid var(--theme-border);
box-shadow: 0 -14px 30px rgba(48, 37, 44, 0.08);
backdrop-filter: blur(16px);
}
.footer-summary {
flex: 1;
min-width: 0;
}
.footer-summary span,
.footer-summary strong {
display: block;
}
.footer-summary span {
margin-bottom: 2px;
font-size: 12px;
}
.footer-summary strong {
color: var(--theme-accent);
font-size: 20px;
}
.checkout-button {
min-width: 138px;
height: 44px;
border: 0;
border-radius: 8px;
font-weight: 700;
background: var(--theme-gradient);
box-shadow: var(--theme-button-shadow);
2026-04-03 11:44:32 +08:00
}
.coupon-options {
display: flex;
flex-direction: column;
gap: 8px;
}
:global(.cart-coupon-modal-wrap .ant-modal) {
max-width: calc(100vw - 24px);
}
:global(.cart-coupon-modal-wrap .ant-modal-content) {
overflow: hidden;
padding: 0;
border: 1px solid var(--theme-border);
border-radius: 8px;
background: var(--theme-card-bg);
box-shadow: 0 24px 64px rgba(48, 37, 44, 0.26);
}
:global(.cart-coupon-modal-wrap .ant-modal-header) {
margin: 0;
padding: 18px 22px 12px;
border-bottom: 1px solid var(--theme-border);
background: var(--theme-card-bg);
}
:global(.cart-coupon-modal-wrap .ant-modal-title) {
color: var(--text-primary);
font-size: 16px;
font-weight: 800;
}
:global(.cart-coupon-modal-wrap .ant-modal-close) {
color: var(--text-secondary);
}
:global(.cart-coupon-modal-wrap .ant-modal-body) {
padding: 18px 22px 14px;
}
:global(.cart-coupon-modal-wrap .ant-modal-footer) {
display: flex;
gap: 10px;
justify-content: flex-end;
margin: 0;
padding: 14px 22px 20px;
border-top: 1px solid var(--theme-border);
background: var(--theme-card-bg);
}
:global(.cart-coupon-modal-wrap .cart-coupon-modal__cancel),
:global(.cart-coupon-modal-wrap .cart-coupon-modal__ok) {
min-width: 82px;
height: 38px;
border-radius: 8px;
font-weight: 700;
}
:global(.cart-coupon-modal-wrap .cart-coupon-modal__cancel) {
color: var(--text-primary);
border-color: var(--theme-border);
background: var(--theme-card-bg);
}
:global(.cart-coupon-modal-wrap .cart-coupon-modal__cancel:hover),
:global(.cart-coupon-modal-wrap .cart-coupon-modal__cancel:focus) {
color: var(--theme-primary);
border-color: var(--theme-primary);
}
:global(.cart-coupon-modal-wrap .cart-coupon-modal__ok) {
color: #ffffff;
border: 0;
background: var(--theme-gradient);
box-shadow: var(--theme-button-shadow);
}
:global(.cart-coupon-modal-wrap .cart-coupon-modal__ok:hover),
:global(.cart-coupon-modal-wrap .cart-coupon-modal__ok:focus) {
color: #ffffff;
background: linear-gradient(135deg, var(--theme-accent) 0%, var(--theme-secondary) 100%);
}
:global(.cart-coupon-modal-wrap .ant-radio-wrapper) {
align-items: flex-start;
margin: 0;
color: var(--text-primary);
line-height: 1.6;
}
:global(.cart-coupon-modal-wrap .ant-radio-wrapper + .ant-radio-wrapper) {
margin-top: 8px;
}
:global(.cart-coupon-modal-wrap .ant-radio-checked .ant-radio-inner) {
border-color: var(--theme-primary);
background: var(--theme-primary);
}
:global(.cart-coupon-modal-wrap .ant-radio-wrapper:hover .ant-radio-inner) {
border-color: var(--theme-primary);
}
2026-04-03 11:44:32 +08:00
.modal-section + .modal-section {
margin-top: 16px;
}
.section-title {
margin-bottom: 8px;
font-weight: 700;
}
.artist-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.artist-option {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border: 1px solid var(--theme-border);
2026-04-03 11:44:32 +08:00
border-radius: 999px;
background: var(--theme-card-bg);
2026-04-03 11:44:32 +08:00
cursor: pointer;
}
.artist-option.active {
border-color: var(--theme-primary);
color: var(--theme-primary);
background: var(--theme-primary-soft);
2026-04-03 11:44:32 +08:00
}
.artist-option img {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
.artist-option em {
color: var(--theme-accent);
font-size: 12px;
font-style: normal;
}
@media (min-width: 560px) {
.checkout-hero {
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
}
.hero-metrics {
grid-column: 1 / -1;
}
.appointment-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (min-width: 900px) {
.content {
padding: 24px 24px calc(150px + env(safe-area-inset-bottom));
}
.checkout-layout {
grid-template-columns: minmax(0, 1fr) 320px;
align-items: start;
}
.checkout-side {
position: sticky;
top: 18px;
}
}
2026-04-03 11:44:32 +08:00
@media (max-width: 767px) {
.content {
padding: 14px 14px calc(150px + env(safe-area-inset-bottom));
}
}
@media (max-width: 420px) {
.hero-metrics {
grid-template-columns: 1fr;
}
.item-row {
grid-template-columns: auto 74px minmax(0, 1fr);
gap: 10px;
}
.thumb {
width: 74px;
height: 74px;
}
.footer {
padding-inline: 12px;
}
.checkout-button {
min-width: 118px;
2026-04-03 11:44:32 +08:00
}
}
</style>