YumiNail后端业务数据库增删改查初始化,前端页面初版
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<div class="mobile-container">
|
||||
|
||||
<!-- Header -->
|
||||
<header class="header">
|
||||
<div class="back-btn" @click="handleBackClick">
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
</div>
|
||||
<h1>Product Detail</h1>
|
||||
<div class="actions">
|
||||
<el-icon @click="handleFavoriteClick"><Star /></el-icon>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Product Image -->
|
||||
<div class="product-image" :style="{ backgroundColor: product.bgColor }">
|
||||
<span class="product-letter">{{ product.name[0] }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Product Info -->
|
||||
<div class="product-info">
|
||||
<div class="info-header">
|
||||
<h2 class="product-name">{{ product.name }}</h2>
|
||||
<div class="price-tag">${{ product.price }}</div>
|
||||
</div>
|
||||
<div class="rating">
|
||||
<el-rate v-model="product.rating" disabled show-score text-color="#ff9900" />
|
||||
</div>
|
||||
<p class="description">{{ product.description }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Size Selection -->
|
||||
<div class="size-section">
|
||||
<h3>Size</h3>
|
||||
<div class="size-options">
|
||||
<div v-for="size in sizes" :key="size"
|
||||
class="size-option"
|
||||
:class="{ active: selectedSize === size }"
|
||||
@click="handleSizeClick(size)">
|
||||
{{ size }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Color Selection -->
|
||||
<div class="color-section">
|
||||
<h3>Color</h3>
|
||||
<div class="color-options">
|
||||
<div v-for="color in colors" :key="color.name"
|
||||
class="color-option"
|
||||
:class="{ active: selectedColor === color.name }"
|
||||
:style="{ backgroundColor: color.value }"
|
||||
@click="handleColorClick(color.name)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quantity -->
|
||||
<div class="quantity-section">
|
||||
<h3>Quantity</h3>
|
||||
<div class="quantity-control">
|
||||
<el-button @click="decreaseQuantity" :disabled="quantity <= 1">-</el-button>
|
||||
<span class="quantity">{{ quantity }}</span>
|
||||
<el-button @click="increaseQuantity">+</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons">
|
||||
<el-button class="add-cart-btn" @click="handleAddToCart">
|
||||
Add to Cart
|
||||
</el-button>
|
||||
<el-button class="buy-now-btn" type="primary" @click="handleBuyNow">
|
||||
Buy Now
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ArrowLeft, Star } from '@element-plus/icons-vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const product = ref({
|
||||
id: 1,
|
||||
name: 'Watch',
|
||||
price: 40,
|
||||
bgColor: '#ffe4d6',
|
||||
rating: 4.5,
|
||||
description: 'This is a premium quality watch with excellent design and durability. Perfect for any occasion.'
|
||||
})
|
||||
|
||||
const sizes = ['S', 'M', 'L', 'XL']
|
||||
const colors = [
|
||||
{ name: 'red', value: '#ff6b6b' },
|
||||
{ name: 'blue', value: '#4ecdc4' },
|
||||
{ name: 'black', value: '#2c3e50' },
|
||||
{ name: 'white', value: '#ecf0f1' }
|
||||
]
|
||||
|
||||
const selectedSize = ref('M')
|
||||
const selectedColor = ref('black')
|
||||
const quantity = ref(1)
|
||||
|
||||
onMounted(() => {
|
||||
const productId = route.params.id
|
||||
console.log('产品ID:', productId)
|
||||
})
|
||||
|
||||
const handleBackClick = () => {
|
||||
console.log('返回按钮被点击')
|
||||
router.back()
|
||||
}
|
||||
|
||||
const handleFavoriteClick = () => console.log('收藏按钮被点击')
|
||||
|
||||
const handleSizeClick = (size: string) => {
|
||||
console.log('选择尺码:', size)
|
||||
selectedSize.value = size
|
||||
}
|
||||
|
||||
const handleColorClick = (color: string) => {
|
||||
console.log('选择颜色:', color)
|
||||
selectedColor.value = color
|
||||
}
|
||||
|
||||
const decreaseQuantity = () => {
|
||||
if (quantity.value > 1) {
|
||||
quantity.value--
|
||||
console.log('数量减少:', quantity.value)
|
||||
}
|
||||
}
|
||||
|
||||
const increaseQuantity = () => {
|
||||
quantity.value++
|
||||
console.log('数量增加:', quantity.value)
|
||||
}
|
||||
|
||||
const handleAddToCart = () => {
|
||||
console.log('添加到购物车:', {
|
||||
product: product.value,
|
||||
size: selectedSize.value,
|
||||
color: selectedColor.value,
|
||||
quantity: quantity.value
|
||||
})
|
||||
}
|
||||
|
||||
const handleBuyNow = () => {
|
||||
console.log('立即购买:', {
|
||||
product: product.value,
|
||||
size: selectedSize.value,
|
||||
color: selectedColor.value,
|
||||
quantity: quantity.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
.back-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.actions {
|
||||
width: 40px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 80px;
|
||||
font-weight: bold;
|
||||
color: rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.product-info {
|
||||
padding: 20px;
|
||||
}
|
||||
.info-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.product-name {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
.price-tag {
|
||||
font-size: 24px;
|
||||
color: var(--primary-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
.rating {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.description {
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.size-section, .color-section, .quantity-section {
|
||||
padding: 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
.size-section h3, .color-section h3, .quantity-section h3 {
|
||||
margin: 0 0 15px 0;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.size-options {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.size-option {
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border: 2px solid #ddd;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.size-option.active {
|
||||
border-color: var(--primary-color);
|
||||
background-color: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.color-options {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
.color-option {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
border: 3px solid transparent;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.color-option.active {
|
||||
border-color: var(--primary-color);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.quantity-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
.quantity {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
min-width: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.add-cart-btn, .buy-now-btn {
|
||||
flex: 1;
|
||||
height: 50px;
|
||||
border-radius: 25px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.add-cart-btn {
|
||||
background-color: #f5f5f5;
|
||||
border: none;
|
||||
color: #333;
|
||||
}
|
||||
.buy-now-btn {
|
||||
background-color: var(--primary-color);
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user