一些问题的修复

This commit is contained in:
xiaowang
2026-03-19 14:10:59 +08:00
parent 580a89c64d
commit 3527e248d1
50 changed files with 847 additions and 165 deletions
+144 -58
View File
@@ -42,6 +42,18 @@
<h3 class="item-name" @click="handleProductClick(item)" style="cursor: pointer;">{{ item.productTitle }}</h3>
<p class="item-price">¥{{ item.price.toFixed(2) }}</p>
<!-- 美甲师选择 -->
<div class="artist-selector" @click="showArtistSelection(item)">
<span v-if="item.artist" class="selected-artist">
<img v-if="item.artist.avatar" :src="item.artist.avatar" class="artist-avatar-small" />
<span class="artist-name">{{ item.artist.name }}</span>
</span>
<span v-else class="select-artist">
选择美甲师
</span>
<RightOutlined class="arrow-icon" />
</div>
<!-- 数量控制和删除按钮 -->
<div class="item-actions">
<div class="quantity-control">
@@ -83,7 +95,7 @@
<div class="coupon-header" @click="showCouponModal = true">
<span class="coupon-title">优惠券</span>
<div class="coupon-value">
{{ selectedCoupon ? '已选择: ' + selectedCoupon.couponName : '请选择' }}
{{ selectedCoupon ? selectedCoupon.couponName : '使用优惠券' }}
<RightOutlined :style="{ marginLeft: '4px' }" />
</div>
</div>
@@ -122,14 +134,14 @@
block
@click="handleCheckout"
>
结算 ({{ selectedCount }}) - ¥{{ totalAmount.toFixed(2) }}
确认 {{ selectedCount }} 笔订单- 预计金额 ¥{{ totalAmount.toFixed(2) }}
</a-button>
</div>
<!-- 优惠券选择弹窗 -->
<a-modal
v-model:visible="showCouponModal"
title="选择优惠券"
title="使用优惠券"
width="90%"
@ok="confirmCouponSelection"
@cancel="cancelCouponSelection"
@@ -192,11 +204,10 @@
<!-- 美甲师选择弹窗 -->
<a-modal
v-model:visible="showArtistModal"
title="选择美甲师"
:title='currentEditingItem ? `为"${currentEditingItem.productTitle}"选择美甲师` : "选择美甲师"'
width="90%"
@ok="selectArtistAndCheckout"
@ok="confirmArtistSelection"
@cancel="closeArtistModal"
>
<div class="artist-modal-content">
<a-empty v-if="availableArtists.length === 0" description="暂无可用美甲师" />
@@ -206,8 +217,8 @@
v-for="artist in availableArtists"
:key="artist.id"
class="artist-item"
:class="{ 'selected': selectedArtist && selectedArtist.id === artist.id }"
@click="toggleArtistSelection(artist)"
:class="{ 'selected': currentEditingItem && currentEditingItem.artistId === artist.id }"
@click="selectArtist(artist)"
>
<div class="artist-card">
<div class="artist-avatar">
@@ -238,7 +249,7 @@
<span class="skill-tag" v-for="skill in getArtistSkills(artist)" :key="skill">{{ skill }}</span>
</div>
</div>
<div class="artist-selection-indicator" v-if="selectedArtist && selectedArtist.id === artist.id">
<div class="artist-selection-indicator" v-if="currentEditingItem && currentEditingItem.artistId === artist.id">
<CheckCircleOutlined style="color: #1890ff; font-size: 20px;" />
</div>
</div>
@@ -283,6 +294,18 @@ interface CartItem {
totalPrice: number
tags: string
selected: boolean
artistId?: number
artist?: {
id: number
name: string
avatar?: string
signature?: string
shopName?: string
status?: number
experience?: number
skills?: string
rating?: number
}
}
const router = useRouter()
@@ -516,7 +539,7 @@ const cancelCouponSelection = () => {
// 美甲师选择相关状态
const showArtistModal = ref(false)
const selectedArtist = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number} | null>(null)
const currentEditingItem = ref<CartItem | null>(null)
const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number}[]>([])
// 标签列表
const tagList = ref<TagVO[]>([])
@@ -592,28 +615,30 @@ const handleCheckout = async () => {
return
}
// 加载可用美甲师
await loadAvailableArtists()
// 显示美甲师选择弹窗
showArtistModal.value = true
}
// 选择美甲师并创建订单
const selectArtistAndCheckout = async () => {
if (!selectedArtist.value) {
message.warning('请选择美甲师')
// 检查所有选中的作品是否都选择了美甲师
const itemsWithoutArtist = selectedItems.filter(item => !item.artistId)
if (itemsWithoutArtist.length > 0) {
message.warning(`请为"${itemsWithoutArtist.map(item => item.productTitle).join('、')}"选择美甲师`)
return
}
// 创建订单
try {
await orderApi.createOrder({
couponId: selectedCoupon.value ? selectedCoupon.value.id : undefined,
artistId: selectedArtist.value.id
items: selectedItems.map(item => ({
productId: item.productId,
quantity: item.quantity,
artistId: item.artistId
}))
})
message.success('订单创建成功')
showArtistModal.value = false
// 更新购物车数量(因为订单创建后购物车会被清空)
// 从购物车中移除已购买的商品
const selectedIds = selectedItems.map(item => item.id)
await cartApi.batchRemoveFromCart(selectedIds)
// 更新购物车数据
await loadCartItems()
// 更新购物车数量
await updateCartCount()
router.push('/profile')
} catch (error) {
@@ -621,10 +646,31 @@ const selectArtistAndCheckout = async () => {
}
}
// 显示美甲师选择弹窗
const showArtistSelection = (item: CartItem) => {
currentEditingItem.value = item
loadAvailableArtists()
showArtistModal.value = true
}
// 选择美甲师
const selectArtist = (artist: any) => {
if (currentEditingItem.value) {
currentEditingItem.value.artistId = artist.id
currentEditingItem.value.artist = artist
}
}
// 确认选择
const confirmArtistSelection = () => {
showArtistModal.value = false
currentEditingItem.value = null
}
// 关闭美甲师选择弹窗
const closeArtistModal = () => {
showArtistModal.value = false
selectedArtist.value = null
currentEditingItem.value = null
}
// 获取美甲师头像
@@ -670,17 +716,6 @@ const getArtistSkills = (artist: any) => {
})
}
// 切换美甲师选择状态
const toggleArtistSelection = (artist: any) => {
if (selectedArtist.value && selectedArtist.value.id === artist.id) {
// 取消选择
selectedArtist.value = null
} else {
// 选择新的美甲师
selectedArtist.value = artist
}
}
// 监听选中作品变化,重新加载可用优惠券
watch(
() => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })),
@@ -807,6 +842,55 @@ onMounted(() => {
font-size: 16px;
}
.artist-selector {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
background: #f8f9ff;
border-radius: 8px;
margin-bottom: 10px;
cursor: pointer;
transition: all 0.3s ease;
}
.artist-selector:hover {
background: #e6f7ff;
}
.selected-artist {
display: flex;
align-items: center;
gap: 8px;
color: #1890ff;
font-weight: 500;
}
.artist-avatar-small {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
.select-artist {
color: #999;
font-size: 13px;
display: flex;
align-items: center;
gap: 4px;
}
.arrow-icon {
color: #999;
font-size: 12px;
transition: transform 0.3s ease;
}
.artist-selector:hover .arrow-icon {
transform: translateX(4px);
}
.item-duration {
color: #666;
font-size: 13px;
@@ -907,7 +991,7 @@ onMounted(() => {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18px 20px;
padding: 12px 16px;
cursor: pointer;
background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 100%);
border-bottom: 1px solid #e6f7ff;
@@ -918,29 +1002,29 @@ onMounted(() => {
}
.coupon-title {
font-size: 16px;
font-size: 14px;
font-weight: 600;
color: #333;
display: flex;
align-items: center;
gap: 8px;
gap: 6px;
}
.coupon-title::before {
content: "🎁";
font-size: 18px;
font-size: 14px;
}
.coupon-value {
font-size: 13px;
font-size: 12px;
font-weight: 500;
color: #1890ff;
display: flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
gap: 4px;
padding: 4px 10px;
background: rgba(24, 144, 255, 0.1);
border-radius: 20px;
border-radius: 16px;
transition: all 0.3s ease;
box-shadow: 0 1px 3px rgba(24, 144, 255, 0.2);
}
@@ -952,7 +1036,7 @@ onMounted(() => {
}
.coupon-discount {
padding: 14px 20px;
padding: 10px 16px;
background-color: #f0f9ff;
border-top: 1px solid #e6f7ff;
display: flex;
@@ -961,20 +1045,20 @@ onMounted(() => {
}
.discount-label {
font-size: 14px;
font-size: 12px;
color: #666;
display: flex;
align-items: center;
gap: 6px;
gap: 4px;
}
.discount-label::before {
content: "💰";
font-size: 14px;
font-size: 12px;
}
.discount-amount {
font-size: 18px;
font-size: 16px;
font-weight: 700;
color: #1890ff;
text-shadow: 0 1px 2px rgba(24, 144, 255, 0.3);
@@ -1014,15 +1098,17 @@ onMounted(() => {
.coupon-content {
display: flex;
align-items: center;
padding: 16px;
gap: 16px;
padding: 10px;
gap: 10px;
}
.coupon-value {
font-size: 24px;
font-size: 18px;
font-weight: 600;
color: #ff4d4f;
flex-shrink: 0;
min-width: 50px;
text-align: center;
}
.coupon-info {
@@ -1031,29 +1117,29 @@ onMounted(() => {
}
.coupon-name {
font-size: 15px;
font-size: 13px;
font-weight: 600;
color: #333;
margin-bottom: 4px;
margin-bottom: 2px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.coupon-condition {
font-size: 13px;
font-size: 11px;
color: #666;
margin-bottom: 4px;
margin-bottom: 2px;
}
.coupon-time {
font-size: 12px;
font-size: 10px;
color: #999;
}
.coupon-select {
color: #1890ff;
font-size: 20px;
font-size: 16px;
flex-shrink: 0;
}