替换商品为作品

This commit is contained in:
xiaowang
2026-03-05 16:08:27 +08:00
parent 0cae87e957
commit 6cbd3bc076
16 changed files with 98 additions and 98 deletions
+15 -15
View File
@@ -12,7 +12,7 @@
</a-button>
</header>
<!-- 购物车商品列表 -->
<!-- 购物车作品列表 -->
<div class="cart-items">
<a-empty v-if="cartItems.length === 0" description="购物车是空的">
<a-button type="primary" @click="handleBrowseProducts">去逛逛</a-button>
@@ -29,7 +29,7 @@
<!-- 复选框 -->
<a-checkbox v-model:checked="item.selected" @change="handleSelectChange" />
<!-- 商品图片 -->
<!-- 作品图片 -->
<div class="item-image" v-if="item.productImage" @click="handleProductClick(item)" style="cursor: pointer;">
<img :src="item.productImage" :alt="item.productTitle" />
</div>
@@ -37,7 +37,7 @@
<span>{{ item.productTitle[0] }}</span>
</div>
<!-- 商品详情 -->
<!-- 作品详情 -->
<div class="item-details">
<h3 class="item-name" @click="handleProductClick(item)" style="cursor: pointer;">{{ item.productTitle }}</h3>
<p class="item-price">¥{{ item.price.toFixed(2) }}</p>
@@ -62,7 +62,7 @@
</a-button>
</div>
<a-popconfirm
title="确定要删除这个商品吗?"
title="确定要删除这个作品吗?"
ok-text="确定"
cancel-text="取消"
@confirm="handleDeleteItem(item)"
@@ -97,7 +97,7 @@
<!-- 订单摘要 -->
<div class="summary" v-if="cartItems.length > 0">
<div class="summary-row">
<span>商品数量</span>
<span>作品数量</span>
<span>{{ totalQuantity }} 件</span>
</div>
<div class="summary-row">
@@ -288,7 +288,7 @@ interface CartItem {
const router = useRouter()
// 购物车商品数据
// 购物车作品数据
const cartItems = ref<CartItem[]>([])
// 图片缓存
@@ -318,7 +318,7 @@ const loadCartItems = async () => {
}
}
// 加载商品图片
// 加载作品图片
const loadProductImages = async (items: CartItem[]) => {
for (const item of items) {
if (item.originalProductImage) {
@@ -383,12 +383,12 @@ const loadAvailableCoupons = async () => {
}
}
// 计算选中的商品数量
// 计算选中的作品数量
const selectedCount = computed(() => {
return cartItems.value.filter(item => item.selected).length
})
// 计算商品总数量
// 计算作品总数量
const totalQuantity = computed(() => {
return cartItems.value.reduce((sum, item) => sum + item.quantity, 0)
})
@@ -478,21 +478,21 @@ const handleIncreaseQuantity = async (item: CartItem) => {
}
}
// 处理删除商品
// 处理删除作品
const handleDeleteItem = async (item: CartItem) => {
try {
await cartApi.removeFromCart(item.productId)
const index = cartItems.value.findIndex(i => i.id === item.id)
if (index > -1) {
cartItems.value.splice(index, 1)
message.success('商品已删除')
message.success('作品已删除')
// 重新加载可用优惠券
await loadAvailableCoupons()
// 更新购物车数量
await updateCartCount()
}
} catch (error) {
message.error('删除商品失败')
message.error('删除作品失败')
}
}
@@ -500,7 +500,7 @@ const handleProductClick = (item: CartItem) => {
router.push(`/product/${item.productId}`)
}
// 处理浏览商品
// 处理浏览作品
const handleBrowseProducts = () => {
router.push('/products')
}
@@ -589,7 +589,7 @@ const loadAvailableArtists = async () => {
const handleCheckout = async () => {
const selectedItems = cartItems.value.filter(item => item.selected)
if (selectedItems.length === 0) {
message.warning('请先选择要结算的商品')
message.warning('请先选择要结算的作品')
return
}
@@ -682,7 +682,7 @@ const toggleArtistSelection = (artist: any) => {
}
}
// 监听选中商品变化,重新加载可用优惠券
// 监听选中作品变化,重新加载可用优惠券
watch(
() => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })),
async () => {