后台管理页面初版

This commit is contained in:
xiaowang
2026-02-25 10:37:16 +08:00
parent f946f9d31a
commit efe172793c
42 changed files with 3338 additions and 459 deletions
+130 -30
View File
@@ -30,23 +30,34 @@
<!-- 商品图片 -->
<div class="item-image" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
<span>{{ item.title[0] }}</span>
</div>
<!-- 商品详情 -->
<div class="item-details">
<h3 class="item-name">{{ item.name }}</h3>
<p class="item-price">${{ item.price }}</p>
<h3 class="item-name">{{ item.title }}</h3>
<p class="item-price">¥{{ item.price.toFixed(2) }}</p>
<p class="item-duration">预计耗时: {{ item.approximateDuration }}</p>
<!-- 数量控制和删除按钮 -->
<div class="item-actions">
<a-input-number
v-model:value="item.quantity"
:min="1"
:max="99"
size="small"
@change="(val: number | null) => handleQuantityChange(item, val)"
/>
<div class="quantity-control">
<a-button
size="small"
:disabled="item.quantity <= 1"
@click="handleDecreaseQuantity(item)"
>
-
</a-button>
<span class="quantity-value">{{ item.quantity }}</span>
<a-button
size="small"
:disabled="item.quantity >= 99"
@click="handleIncreaseQuantity(item)"
>
+
</a-button>
</div>
<a-popconfirm
title="确定要删除这个商品吗?"
ok-text="确定"
@@ -71,15 +82,15 @@
</div>
<div class="summary-row">
<span>小计</span>
<span>${{ subtotal }}</span>
<span>¥{{ subtotal.toFixed(2) }}</span>
</div>
<div class="summary-row">
<span>运费</span>
<span>${{ shipping }}</span>
<span>预计消耗时间</span>
<span class="duration">{{ totalDuration }}</span>
</div>
<div class="summary-row total">
<span>总计</span>
<span class="total-price">${{ total }}</span>
<span class="total-price">¥{{ subtotal.toFixed(2) }}</span>
</div>
</div>
@@ -105,19 +116,54 @@ import {
DeleteOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import type { ProductVO } from '@/api/product'
const router = useRouter()
// 购物车商品数据
const cartItems = ref([
{ id: 1, name: 'Watch', price: 40, bgColor: '#ffe4d6', quantity: 1, selected: true },
{ id: 2, name: 'Nike Shoes', price: 430, bgColor: '#d6eaff', quantity: 2, selected: true },
{ id: 3, name: 'Airpods', price: 333, bgColor: '#e2ffd6', quantity: 1, selected: false }
// 购物车商品数据(模拟真实产品数据结构)
const cartItems = ref<Array<{
id: number
productId: number
title: string
price: number
imageUrl?: string
bgColor: string
quantity: number
selected: boolean
approximateDuration: string
}>>([
{
id: 1,
productId: 1,
title: '经典美甲',
price: 99,
bgColor: '#ffe4d6',
quantity: 1,
selected: true,
approximateDuration: '30分钟'
},
{
id: 2,
productId: 2,
title: '法式美甲',
price: 168,
bgColor: '#d6eaff',
quantity: 2,
selected: true,
approximateDuration: '45分钟'
},
{
id: 3,
productId: 3,
title: '光疗美甲',
price: 238,
bgColor: '#e2ffd6',
quantity: 1,
selected: false,
approximateDuration: '60分钟'
}
])
// 运费
const shipping = 10
// 计算选中的商品数量
const selectedCount = computed(() => {
return cartItems.value.filter(item => item.selected).length
@@ -135,9 +181,31 @@ const subtotal = computed(() => {
.reduce((sum, item) => sum + (item.price * item.quantity), 0)
})
// 计算总价
const total = computed(() => {
return subtotal.value + shipping
// 计算预计总消耗时间
const totalDuration = computed(() => {
const selectedItems = cartItems.value.filter(item => item.selected)
if (selectedItems.length === 0) return '0分钟'
let totalMinutes = 0
selectedItems.forEach(item => {
const durationStr = item.approximateDuration
const match = durationStr.match(/(\d+)/)
if (match) {
totalMinutes += parseInt(match[1]) * item.quantity
}
})
if (totalMinutes < 60) {
return `${totalMinutes}分钟`
} else {
const hours = Math.floor(totalMinutes / 60)
const minutes = totalMinutes % 60
if (minutes === 0) {
return `${hours}小时`
} else {
return `${hours}小时${minutes}分钟`
}
}
})
// 处理返回按钮点击
@@ -156,9 +224,18 @@ const handleSelectChange = () => {
console.log('选择状态改变')
}
// 处理数量变化
const handleQuantityChange = (item: any, val: number | null) => {
console.log('商品数量改变:', item.name, val)
// 处理减少数量
const handleDecreaseQuantity = (item: any) => {
if (item.quantity > 1) {
item.quantity--
}
}
// 处理增加数量
const handleIncreaseQuantity = (item: any) => {
if (item.quantity < 99) {
item.quantity++
}
}
// 处理删除商品
@@ -186,8 +263,7 @@ const handleCheckout = () => {
console.log('结算购物车:', {
items: selectedItems,
subtotal: subtotal.value,
shipping: shipping,
total: total.value
totalDuration: totalDuration.value
})
message.success('正在跳转到结算页面...')
}
@@ -286,6 +362,12 @@ const handleCheckout = () => {
font-size: 16px;
}
.item-duration {
color: #666;
font-size: 13px;
margin: 4px 0 0 0;
}
.item-actions {
display: flex;
justify-content: space-between;
@@ -293,6 +375,19 @@ const handleCheckout = () => {
margin-top: 8px;
}
.quantity-control {
display: flex;
align-items: center;
gap: 8px;
}
.quantity-value {
min-width: 30px;
text-align: center;
font-weight: 600;
font-size: 16px;
}
.summary {
margin: 0 15px 15px;
padding: 16px;
@@ -322,6 +417,11 @@ const handleCheckout = () => {
font-size: 20px;
}
.duration {
color: #667eea;
font-weight: 600;
}
.checkout-section {
position: fixed;
bottom: 60px;