YumiNail后端业务数据库增删改查初始化,前端页面初版

This commit is contained in:
xiaowang
2026-02-13 17:34:32 +08:00
parent 7a6cab8a51
commit c5018b14a5
119 changed files with 11996 additions and 55 deletions
+342
View File
@@ -0,0 +1,342 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>购物车</h1>
<a-button class="edit-btn" type="text" @click="handleEditClick">
编辑
</a-button>
</header>
<!-- 购物车商品列表 -->
<div class="cart-items">
<a-empty v-if="cartItems.length === 0" description="购物车是空的">
<a-button type="primary" @click="handleBrowseProducts">去逛逛</a-button>
</a-empty>
<a-card
v-for="item in cartItems"
:key="item.id"
class="cart-item"
:body-style="{ padding: '16px' }"
>
<div class="item-content">
<!-- 复选框 -->
<a-checkbox v-model:checked="item.selected" @change="handleSelectChange" />
<!-- 商品图片 -->
<div class="item-image" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
</div>
<!-- 商品详情 -->
<div class="item-details">
<h3 class="item-name">{{ item.name }}</h3>
<p class="item-price">${{ item.price }}</p>
<!-- 数量控制和删除按钮 -->
<div class="item-actions">
<a-input-number
v-model:value="item.quantity"
:min="1"
:max="99"
size="small"
@change="(val) => handleQuantityChange(item, val)"
/>
<a-popconfirm
title="确定要删除这个商品吗?"
ok-text="确定"
cancel-text="取消"
@confirm="handleDeleteItem(item)"
>
<a-button type="text" danger size="small">
<DeleteOutlined />
</a-button>
</a-popconfirm>
</div>
</div>
</div>
</a-card>
</div>
<!-- 订单摘要 -->
<div class="summary" v-if="cartItems.length > 0">
<div class="summary-row">
<span>商品数量</span>
<span>{{ totalQuantity }} 件</span>
</div>
<div class="summary-row">
<span>小计</span>
<span>${{ subtotal }}</span>
</div>
<div class="summary-row">
<span>运费</span>
<span>${{ shipping }}</span>
</div>
<div class="summary-row total">
<span>总计</span>
<span class="total-price">${{ total }}</span>
</div>
</div>
<!-- 结算按钮 -->
<div class="checkout-section" v-if="cartItems.length > 0">
<a-button
type="primary"
size="large"
block
@click="handleCheckout"
>
结算 ({{ selectedCount }})
</a-button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import {
LeftOutlined,
DeleteOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
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 shipping = 10
// 计算选中的商品数量
const selectedCount = computed(() => {
return cartItems.value.filter(item => item.selected).length
})
// 计算商品总数量
const totalQuantity = computed(() => {
return cartItems.value.reduce((sum, item) => sum + item.quantity, 0)
})
// 计算小计
const subtotal = computed(() => {
return cartItems.value
.filter(item => item.selected)
.reduce((sum, item) => sum + (item.price * item.quantity), 0)
})
// 计算总价
const total = computed(() => {
return subtotal.value + shipping
})
// 处理返回按钮点击
const handleBackClick = () => {
console.log('返回按钮被点击')
router.back()
}
// 处理编辑按钮点击
const handleEditClick = () => {
console.log('编辑按钮被点击')
}
// 处理选择状态变化
const handleSelectChange = () => {
console.log('选择状态改变')
}
// 处理数量变化
const handleQuantityChange = (item: any, val: number | null) => {
console.log('商品数量改变:', item.name, val)
}
// 处理删除商品
const handleDeleteItem = (item: any) => {
console.log('删除商品:', item.name)
const index = cartItems.value.findIndex(i => i.id === item.id)
if (index > -1) {
cartItems.value.splice(index, 1)
message.success('商品已删除')
}
}
// 处理浏览商品
const handleBrowseProducts = () => {
router.push('/products')
}
// 处理结算
const handleCheckout = () => {
const selectedItems = cartItems.value.filter(item => item.selected)
if (selectedItems.length === 0) {
message.warning('请先选择要结算的商品')
return
}
console.log('结算购物车:', {
items: selectedItems,
subtotal: subtotal.value,
shipping: shipping,
total: total.value
})
message.success('正在跳转到结算页面...')
}
</script>
<style scoped>
.mobile-container {
padding-top: 60px;
min-height: 100vh;
background: #f5f5f5;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
border-bottom: 1px solid #f0f0f0;
background: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.back-btn,
.edit-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.cart-items {
padding: 15px;
padding-bottom: 20px;
}
.cart-item {
margin-bottom: 12px;
border-radius: 12px;
overflow: hidden;
}
.cart-item :deep(.ant-card-body) {
padding: 16px;
}
.item-content {
display: flex;
gap: 12px;
align-items: flex-start;
}
.item-image {
width: 80px;
height: 80px;
border-radius: 8px;
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
font-weight: bold;
color: rgba(0,0,0,0.1);
flex-shrink: 0;
}
.item-details {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 80px;
}
.item-name {
font-size: 15px;
font-weight: 600;
margin: 0 0 4px 0;
line-height: 1.4;
}
.item-price {
color: #ff4d4f;
font-weight: bold;
margin: 0;
font-size: 16px;
}
.item-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 8px;
}
.summary {
margin: 0 15px 15px;
padding: 16px;
background: #fafafa;
border-radius: 12px;
}
.summary-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
font-size: 14px;
color: #666;
}
.summary-row.total {
font-size: 16px;
font-weight: bold;
color: #333;
border-top: 1px solid #e8e8e8;
padding-top: 12px;
margin-top: 4px;
}
.total-price {
color: #ff4d4f;
font-size: 20px;
}
.checkout-section {
position: fixed;
bottom: 60px;
left: 0;
right: 0;
padding: 15px;
background: white;
border-top: 1px solid #f0f0f0;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.checkout-section :deep(.ant-btn-lg) {
height: 48px;
border-radius: 24px;
font-weight: 600;
font-size: 16px;
}
</style>
+422
View File
@@ -0,0 +1,422 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<!-- 用户信息区域 -->
<div class="user-info" @click="handleUserClick">
<div class="avatar">
<a-avatar :size="40" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
</div>
<div class="welcome">
<p class="greeting">Hello!</p>
<p class="username">昵称</p>
</div>
</div>
<!-- 通知按钮 -->
<div class="actions">
<a-badge :count="3" :offset="[-5, 5]">
<BellOutlined class="notification-icon" @click="handleNotificationClick" />
</a-badge>
</div>
</header>
<!-- 搜索区域 -->
<div class="search-section">
<a-input
v-model:value="searchQuery"
placeholder="搜索商品..."
size="large"
@input="handleSearch"
>
<template #prefix>
<SearchOutlined style="color: #999" />
</template>
</a-input>
<a-button class="filter-btn" type="primary" shape="circle" @click="handleFilterClick">
<FilterOutlined />
</a-button>
</div>
<!-- Banner 区域 -->
<div class="banner" @click="handleBannerClick">
<div class="banner-content">
<a-tag color="red" class="banner-tag">限时优惠</a-tag>
<h3>Get Winter Discount</h3>
<h2>20% Off</h2>
<p>For Children</p>
<a-button type="primary" size="small" class="banner-btn">立即购买</a-button>
</div>
<div class="banner-image">
<div class="img-placeholder">Banner</div>
</div>
</div>
<!-- 精选商品区域 -->
<section class="section">
<div class="section-header">
<h3>精选商品</h3>
<a class="see-all" @click="handleSeeAll('featured')">查看全部 <RightOutlined /></a>
</div>
<div class="horizontal-scroll">
<a-card
v-for="item in featuredItems"
:key="item.id"
class="product-card"
:body-style="{ padding: '12px' }"
hoverable
@click="handleProductClick(item)"
>
<div class="product-img" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
</div>
<div class="product-info">
<p class="name">{{ item.name }}</p>
<p class="price">${{ item.price }}</p>
</div>
</a-card>
</div>
</section>
<!-- 热门商品区域 -->
<section class="section popular-section">
<div class="section-header">
<h3>热门商品</h3>
<a class="see-all" @click="handleSeeAll('popular')">查看全部 <RightOutlined /></a>
</div>
<div class="product-grid">
<a-card
v-for="item in popularItems"
:key="item.id"
class="product-card grid-item"
:body-style="{ padding: '12px' }"
hoverable
@click="handleProductClick(item)"
>
<div class="product-img" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
</div>
<div class="product-info">
<p class="name">{{ item.name }}</p>
<p class="price">${{ item.price }}</p>
</div>
</a-card>
</div>
</section>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
BellOutlined,
SearchOutlined,
FilterOutlined,
RightOutlined
} from '@ant-design/icons-vue'
const router = useRouter()
// 搜索关键词
const searchQuery = ref('')
// 精选商品数据
const featuredItems = ref([
{ id: 1, name: 'Watch', price: 40, bgColor: '#ffe4d6' },
{ id: 2, name: 'Nike Shoes', price: 430, bgColor: '#d6eaff' },
{ id: 3, name: 'Airpods', price: 333, bgColor: '#e2ffd6' }
])
// 热门商品数据
const popularItems = ref([
{ id: 4, name: 'LG TV', price: 330, bgColor: '#f0d6ff' },
{ id: 5, name: 'Hoodie', price: 50, bgColor: '#ffd6e2' },
{ id: 6, name: 'Jacket', price: 400, bgColor: '#d6fff0' }
])
// 处理用户头像点击
const handleUserClick = () => {
console.log('用户头像被点击')
router.push('/profile')
}
// 处理通知图标点击
const handleNotificationClick = () => {
console.log('通知图标被点击')
}
// 处理搜索输入
const handleSearch = (val: string) => {
console.log('搜索内容改变:', val)
}
// 处理筛选按钮点击
const handleFilterClick = () => {
console.log('筛选按钮被点击')
}
// 处理 Banner 点击
const handleBannerClick = () => {
console.log('Banner被点击')
}
// 处理查看全部点击
const handleSeeAll = (type: string) => {
console.log(`查看全部: ${type}`)
router.push('/products')
}
// 处理商品卡片点击
const handleProductClick = (item: any) => {
console.log('商品被点击:', item.name)
router.push(`/product/${item.id}`)
}
</script>
<style scoped>
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
}
.user-info {
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
transition: transform 0.2s;
}
.user-info:hover {
transform: scale(1.02);
}
.greeting {
font-size: 12px;
color: #999;
margin: 0;
}
.username {
font-weight: bold;
font-size: 16px;
margin: 0;
}
.actions {
display: flex;
align-items: center;
}
.notification-icon {
font-size: 24px;
cursor: pointer;
color: #333;
transition: color 0.3s;
}
.notification-icon:hover {
color: #1890ff;
}
.search-section {
display: flex;
padding: 10px 20px;
gap: 10px;
align-items: center;
}
.search-section :deep(.ant-input) {
border-radius: 20px;
height: 44px;
}
.filter-btn {
width: 44px;
height: 44px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.banner {
margin: 15px 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 20px;
height: 160px;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
color: white;
overflow: hidden;
position: relative;
cursor: pointer;
transition: transform 0.3s, box-shadow 0.3s;
}
.banner:hover {
transform: translateY(-4px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
.banner-tag {
margin-bottom: 8px;
border: none;
font-weight: 500;
}
.banner-content h3 {
font-size: 14px;
opacity: 0.9;
margin: 0 0 4px 0;
}
.banner-content h2 {
font-size: 28px;
margin: 4px 0;
font-weight: bold;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.banner-content p {
font-size: 14px;
margin: 4px 0 12px 0;
opacity: 0.9;
}
.banner-btn {
border-radius: 20px;
height: 32px;
font-weight: 500;
}
.banner-image {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
}
.img-placeholder {
width: 100px;
height: 100px;
background: rgba(255,255,255,0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
backdrop-filter: blur(10px);
}
.section {
padding: 15px 0;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px 15px;
}
.section-header h3 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.see-all {
color: #1890ff;
font-size: 13px;
cursor: pointer;
display: flex;
align-items: center;
gap: 4px;
transition: color 0.3s;
}
.see-all:hover {
color: #40a9ff;
}
.horizontal-scroll {
display: flex;
overflow-x: auto;
padding: 0 20px;
gap: 15px;
scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar {
display: none;
}
.product-card {
width: 140px;
flex-shrink: 0;
cursor: pointer;
transition: transform 0.3s, box-shadow 0.3s;
}
.product-card:hover {
transform: translateY(-4px);
}
.product-card :deep(.ant-card-body) {
padding: 12px;
}
.product-img {
width: 100%;
aspect-ratio: 1;
border-radius: 12px;
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
font-weight: bold;
color: rgba(0,0,0,0.1);
margin-bottom: 8px;
}
.product-info {
padding: 0;
}
.name {
font-size: 14px;
font-weight: 500;
margin: 0 0 4px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.price {
color: #ff4d4f;
font-weight: bold;
margin: 0;
font-size: 16px;
}
.product-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
padding: 0 20px;
gap: 15px;
}
.grid-item {
width: 100%;
}
.popular-section {
padding-bottom: 20px;
}
</style>
+309
View File
@@ -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>
+305
View File
@@ -0,0 +1,305 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>商品列表</h1>
<a-button class="search-btn" type="text">
<SearchOutlined :style="{ fontSize: '20px' }" />
</a-button>
</header>
<!-- 主内容区域 -->
<div class="main-content">
<!-- 左侧分类边栏 -->
<div class="category-sidebar">
<div
v-for="category in categories"
:key="category"
class="category-item"
:class="{ active: selectedCategory === category }"
@click="handleCategoryClick(category)"
>
{{ category }}
</div>
</div>
<!-- 右侧商品区域 -->
<div class="product-section">
<!-- 商品网格 -->
<div class="product-grid">
<a-card
v-for="item in products"
:key="item.id"
class="product-card"
:body-style="{ padding: '12px' }"
hoverable
@click="handleProductClick(item)"
>
<!-- 商品图片 -->
<div class="product-img" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
<a-badge
v-if="item.tag"
:text="item.tag"
color="#ff4d4f"
class="product-tag"
/>
</div>
<!-- 商品信息 -->
<div class="product-info">
<p class="name">{{ item.name }}</p>
<div class="price-row">
<p class="price">${{ item.price }}</p>
<a-button
type="primary"
size="small"
shape="circle"
@click.stop="handleAddToCart(item)"
>
<ShoppingCartOutlined />
</a-button>
</div>
</div>
</a-card>
</div>
<!-- 加载更多 -->
<div class="load-more">
<a-button v-if="hasMore" type="link" @click="handleLoadMore">
加载更多 <DownOutlined />
</a-button>
<a-typography-text v-else type="secondary">没有更多商品了</a-typography-text>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
LeftOutlined,
SearchOutlined,
ShoppingCartOutlined,
DownOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
const router = useRouter()
// 当前选中的分类
const selectedCategory = ref('全部')
// 分类列表
const categories = ['全部', '电子产品', '服装', '配饰', '家居']
// 商品数据
const products = ref([
{ id: 1, name: 'Watch', price: 40, bgColor: '#ffe4d6', tag: '热销' },
{ id: 2, name: 'LG TV', price: 330, bgColor: '#f0d6ff', tag: '新品' },
{ id: 3, name: 'Jacket', price: 50, bgColor: '#ffd6e2' },
{ id: 4, name: 'Nike Shoes', price: 430, bgColor: '#d6eaff', tag: '限时' },
{ id: 5, name: 'Airpods', price: 333, bgColor: '#e2ffd6' },
{ id: 6, name: 'Hoodie', price: 50, bgColor: '#d6fff0' }
])
// 是否还有更多数据
const hasMore = ref(true)
// 处理返回按钮点击
const handleBackClick = () => {
console.log('返回按钮被点击')
router.push('/')
}
// 处理分类点击
const handleCategoryClick = (category: string) => {
console.log('选择分类:', category)
selectedCategory.value = category
// 这里可以添加筛选逻辑
}
// 处理商品卡片点击
const handleProductClick = (item: any) => {
console.log('商品被点击:', item.name)
router.push(`/product/${item.id}`)
}
// 处理添加到购物车
const handleAddToCart = (item: any) => {
console.log('添加到购物车:', item.name)
message.success(`已将 ${item.name} 添加到购物车`)
}
// 处理加载更多
const handleLoadMore = () => {
console.log('加载更多商品')
// 这里可以添加加载更多逻辑
hasMore.value = false
}
</script>
<style scoped>
.mobile-container {
padding-top: 60px;
min-height: 100vh;
background: #f5f5f5;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
border-bottom: 1px solid #f0f0f0;
background: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.back-btn,
.search-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
/* 主内容区域 */
.main-content {
display: flex;
height: calc(100vh - 60px);
overflow: hidden;
}
/* 左侧分类边栏 */
.category-sidebar {
width: 90px;
background: #f8f8f8;
overflow-y: auto;
border-right: 1px solid #e8e8e8;
}
.category-item {
padding: 16px 12px;
font-size: 13px;
color: #666;
text-align: center;
cursor: pointer;
transition: all 0.3s;
border-left: 3px solid transparent;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.category-item:hover {
background: #e8e8e8;
color: #1890ff;
}
.category-item.active {
background: white;
color: #1890ff;
border-left-color: #1890ff;
font-weight: 600;
}
/* 右侧商品区域 */
.product-section {
flex: 1;
overflow-y: auto;
background: #f5f5f5;
}
.product-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
padding: 0 20px;
gap: 15px;
}
.product-card {
cursor: pointer;
transition: transform 0.3s, box-shadow 0.3s;
}
.product-card:hover {
transform: translateY(-4px);
}
.product-card :deep(.ant-card-body) {
padding: 12px;
}
.product-img {
width: 100%;
aspect-ratio: 1;
border-radius: 12px;
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
font-weight: bold;
color: rgba(0,0,0,0.1);
margin-bottom: 10px;
position: relative;
overflow: hidden;
}
.product-tag {
position: absolute;
top: 8px;
left: 8px;
font-size: 11px;
padding: 2px 8px;
border-radius: 8px;
}
.product-info {
padding: 0;
}
.name {
font-size: 14px;
font-weight: 500;
margin: 0 0 4px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.price-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.price {
color: #ff4d4f;
font-weight: bold;
margin: 0;
font-size: 16px;
}
.load-more {
padding: 20px;
text-align: center;
}
</style>
+341
View File
@@ -0,0 +1,341 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<h1>个人中心</h1>
<a-button class="settings-btn" type="text" @click="handleSettingsClick">
<SettingOutlined :style="{ fontSize: '20px' }" />
</a-button>
</header>
<!-- 用户信息卡片 -->
<div class="profile-info">
<a-card :bordered="false" class="profile-card">
<div class="avatar-section">
<a-badge :dot="hasNotification" :offset="[-5, 5]">
<a-avatar :size="80" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
</a-badge>
<div class="user-details">
<h2 class="username">昵称</h2>
<p class="email">user@example.com</p>
</div>
</div>
<a-button type="primary" block @click="handleEditProfile">
编辑资料
</a-button>
</a-card>
</div>
<!-- 统计数据 -->
<div class="stats-section">
<a-row :gutter="16">
<a-col :span="8">
<a-statistic title="订单" :value="12" />
</a-col>
<a-col :span="8">
<a-statistic title="收藏" :value="5" />
</a-col>
<a-col :span="8">
<a-statistic title="优惠券" :value="3" />
</a-col>
</a-row>
</div>
<!-- 菜单列表 -->
<div class="menu-section">
<a-card :bordered="false" class="menu-card">
<a-list :data-source="menuItems" :split="false">
<template #renderItem="{ item }">
<a-list-item
class="menu-item"
@click="handleMenuClick(item.key)"
>
<template #actions>
<RightOutlined />
</template>
<a-list-item-meta>
<template #avatar>
<div class="menu-icon" :style="{ backgroundColor: item.bgColor }">
<component :is="item.icon" />
</div>
</template>
<template #title>
<span>{{ item.title }}</span>
</template>
<template #description v-if="item.desc">
<span>{{ item.desc }}</span>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
</div>
<!-- 退出登录按钮 -->
<div class="logout-section">
<a-button danger block @click="handleLogout">
退出登录
</a-button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, h } from 'vue'
import { useRouter } from 'vue-router'
import {
SettingOutlined,
RightOutlined,
ShoppingOutlined,
HeartOutlined,
EnvironmentOutlined,
CreditCardOutlined,
BellOutlined,
QuestionCircleOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
const router = useRouter()
// 是否有未读通知
const hasNotification = ref(true)
// 菜单项数据
const menuItems = ref([
{
key: 'orders',
title: '我的订单',
icon: ShoppingOutlined,
bgColor: '#e6f7ff'
},
{
key: 'wishlist',
title: '我的收藏',
icon: HeartOutlined,
bgColor: '#fff1f0'
},
{
key: 'address',
title: '收货地址',
icon: EnvironmentOutlined,
bgColor: '#f6ffed'
},
{
key: 'payment',
title: '支付方式',
icon: CreditCardOutlined,
bgColor: '#fff7e6'
},
{
key: 'notifications',
title: '消息通知',
desc: '3条未读',
icon: BellOutlined,
bgColor: '#f9f0ff'
},
{
key: 'help',
title: '帮助与支持',
icon: QuestionCircleOutlined,
bgColor: '#e6f7ff'
}
])
// 处理编辑资料点击
const handleEditProfile = () => {
console.log('编辑个人资料被点击')
message.info('编辑功能开发中...')
}
// 处理菜单项点击
const handleMenuClick = (key: string) => {
console.log('菜单项被点击:', key)
if (key === 'wishlist') {
router.push('/wishlist')
} else if (key === 'orders') {
message.info('订单功能开发中...')
} else if (key === 'address') {
message.info('地址管理功能开发中...')
} else if (key === 'payment') {
message.info('支付方式功能开发中...')
} else if (key === 'notifications') {
message.info('消息通知功能开发中...')
} else if (key === 'help') {
message.info('帮助中心功能开发中...')
}
}
// 处理退出登录
const handleLogout = () => {
console.log('退出登录被点击')
message.success('已退出登录')
}
// 处理设置图标点击
const handleSettingsClick = () => {
console.log('设置图标被点击')
router.push('/settings')
}
</script>
<style scoped>
.mobile-container {
padding-top: 60px;
min-height: 100vh;
background: #f5f5f5;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
border-bottom: 1px solid #f0f0f0;
background: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.settings-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.profile-info {
padding: 15px;
}
.profile-card {
border-radius: 16px;
overflow: hidden;
}
.profile-card :deep(.ant-card-body) {
padding: 24px;
}
.avatar-section {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 20px;
}
.user-details {
flex: 1;
}
.username {
font-size: 20px;
font-weight: bold;
margin: 0 0 4px 0;
}
.email {
color: #999;
font-size: 14px;
margin: 0;
}
.stats-section {
padding: 0 15px 15px;
display: flex;
justify-content: center;
}
.stats-section :deep(.ant-row) {
width: 100%;
max-width: 400px;
}
.stats-section :deep(.ant-statistic-title) {
font-size: 12px;
color: #999;
}
.stats-section :deep(.ant-statistic-content) {
font-size: 20px;
font-weight: bold;
color: #1890ff;
}
.menu-section {
padding: 0 15px 15px;
}
.menu-card {
border-radius: 16px;
overflow: hidden;
}
.menu-card :deep(.ant-card-body) {
padding: 0;
}
.menu-item {
padding: 16px;
cursor: pointer;
transition: background 0.3s;
border-bottom: 1px solid #f0f0f0;
}
.menu-item:hover {
background: #fafafa;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item :deep(.ant-list-item-action) {
margin-left: 8px;
color: #ccc;
}
.menu-icon {
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.menu-item :deep(.ant-list-item-meta-title) {
font-size: 15px;
font-weight: 500;
color: #333;
}
.menu-item :deep(.ant-list-item-meta-description) {
font-size: 12px;
color: #999;
}
.logout-section {
padding: 0 15px 20px;
}
.logout-section :deep(.ant-btn-dangerous) {
height: 48px;
border-radius: 24px;
font-weight: 600;
font-size: 16px;
}
</style>
+275
View File
@@ -0,0 +1,275 @@
<template>
<div class="mobile-container">
<!-- 头部区域 -->
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>设置</h1>
<div class="empty"></div>
</header>
<!-- 设置菜单 -->
<div class="settings-menu">
<a-card :bordered="false" class="settings-card">
<a-list :data-source="settingsSections" :split="false">
<template #renderItem="{ item }">
<!-- 分组标题 -->
<a-list-item class="section-title" v-if="item.type === 'title'">
<span>{{ item.title }}</span>
</a-list-item>
<!-- 设置项 -->
<a-list-item
v-else
class="setting-item"
@click="handleSettingClick(item.key)"
>
<template #actions>
<component :is="item.actionComponent" v-if="item.actionComponent" :props="item.actionProps" />
<RightOutlined v-else />
</template>
<a-list-item-meta>
<template #avatar>
<div class="setting-icon" :style="{ backgroundColor: item.bgColor }">
<component :is="item.icon" />
</div>
</template>
<template #title>
<span>{{ item.title }}</span>
</template>
<template #description v-if="item.desc">
<span>{{ item.desc }}</span>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
</div>
<!-- 版本信息 -->
<div class="version-info">
<a-typography-text type="secondary">版本 1.0.0</a-typography-text>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
LeftOutlined,
RightOutlined,
LockOutlined,
BellOutlined,
SoundOutlined,
MessageOutlined,
ClearOutlined,
SafetyOutlined,
InfoCircleOutlined
} from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
const router = useRouter()
// 设置项数据
const settingsSections = ref([
// 账户与安全
{
type: 'title',
title: '账户与安全'
},
{
key: 'account',
title: '账号设置',
desc: '修改密码、绑定手机',
icon: LockOutlined,
bgColor: '#e6f7ff'
},
// 通知设置
{
type: 'title',
title: '通知设置'
},
{
key: 'notifications',
title: '消息通知',
icon: BellOutlined,
bgColor: '#f6ffed'
},
{
key: 'message-push',
title: '消息推送',
icon: MessageOutlined,
bgColor: '#fffbe6'
},
// 外观设置
{
type: 'title',
title: '外观设置'
},
{
key: 'theme',
title: '主题设置',
desc: '跟随系统',
icon: SoundOutlined,
bgColor: '#f9f0ff'
},
// 其他设置
{
type: 'title',
title: '其他设置'
},
{
key: 'clear-cache',
title: '清除缓存',
desc: '12.5 MB',
icon: ClearOutlined,
bgColor: '#fff2e8'
},
{
key: 'privacy',
title: '隐私政策',
icon: SafetyOutlined,
bgColor: '#e6f7ff'
},
{
key: 'about',
title: '关于我们',
icon: InfoCircleOutlined,
bgColor: '#f6ffed'
}
])
// 处理返回按钮点击
const handleBackClick = () => {
router.back()
}
// 处理设置项点击
const handleSettingClick = (key: string) => {
console.log('设置项被点击:', key)
switch (key) {
case 'account':
message.info('账号设置功能开发中...')
break
case 'notifications':
message.info('消息通知功能开发中...')
break
case 'message-push':
message.info('消息推送功能开发中...')
break
case 'theme':
message.info('主题设置功能开发中...')
break
case 'clear-cache':
message.success('缓存已清除')
break
case 'privacy':
message.info('隐私政策功能开发中...')
break
case 'about':
message.info('关于我们功能开发中...')
break
default:
break
}
}
</script>
<style scoped>
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 15px;
border-bottom: 1px solid #f0f0f0;
}
.header h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
}
.back-btn,
.empty {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.settings-menu {
padding: 15px;
}
.settings-card {
border-radius: 16px;
overflow: hidden;
}
.settings-card :deep(.ant-card-body) {
padding: 0;
}
.section-title {
padding: 12px 16px;
font-size: 13px;
color: #999;
background: #fafafa;
}
.setting-item {
padding: 16px;
cursor: pointer;
transition: background 0.3s;
border-bottom: 1px solid #f0f0f0;
}
.setting-item:hover {
background: #fafafa;
}
.setting-item:last-child {
border-bottom: none;
}
.setting-item :deep(.ant-list-item-action) {
margin-left: 8px;
color: #ccc;
}
.setting-icon {
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.setting-item :deep(.ant-list-item-meta-title) {
font-size: 15px;
font-weight: 500;
color: #333;
}
.setting-item :deep(.ant-list-item-meta-description) {
font-size: 12px;
color: #999;
}
.version-info {
padding: 20px;
text-align: center;
}
</style>
+172
View File
@@ -0,0 +1,172 @@
<template>
<div class="mobile-container">
<!-- Header -->
<header class="header">
<div class="back-btn" @click="handleBackClick">
<el-icon><ArrowLeft /></el-icon>
</div>
<h1>Wishlist</h1>
<div class="empty"></div>
</header>
<!-- Wishlist Items -->
<div class="wishlist-items">
<div v-for="item in wishlistItems" :key="item.id" class="wishlist-item">
<div class="item-image" :style="{ backgroundColor: item.bgColor }">
<span>{{ item.name[0] }}</span>
</div>
<div class="item-details">
<h3 class="item-name">{{ item.name }}</h3>
<p class="item-price">${{ item.price }}</p>
<div class="item-actions">
<el-button size="small" type="primary" @click="handleAddToCart(item)">
Add to Cart
</el-button>
<el-icon class="delete-icon" @click="handleRemoveItem(item)"><Delete /></el-icon>
</div>
</div>
</div>
</div>
<!-- Empty Wishlist Message -->
<div v-if="wishlistItems.length === 0" class="empty-wishlist">
<el-icon :size="60"><Star /></el-icon>
<p>Your wishlist is empty</p>
<el-button type="primary" @click="handleBrowseProducts">
Browse Products
</el-button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ArrowLeft, Delete, Star } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const wishlistItems = ref([
{ id: 1, name: 'Watch', price: 40, bgColor: '#ffe4d6' },
{ id: 2, name: 'LG TV', price: 330, bgColor: '#f0d6ff' },
{ id: 3, name: 'Jacket', price: 50, bgColor: '#ffd6e2' },
{ id: 4, name: 'Nike Shoes', price: 430, bgColor: '#d6eaff' }
])
const handleBackClick = () => {
console.log('返回按钮被点击')
router.back()
}
const handleAddToCart = (item: any) => {
console.log('添加到购物车:', item.name)
}
const handleRemoveItem = (item: any) => {
console.log('从收藏夹移除:', item.name)
const index = wishlistItems.value.findIndex(i => i.id === item.id)
if (index > -1) {
wishlistItems.value.splice(index, 1)
}
}
const handleBrowseProducts = () => {
console.log('浏览商品')
router.push('/products')
}
</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;
}
.empty {
width: 40px;
}
.wishlist-items {
padding: 20px;
padding-bottom: 20px;
}
.wishlist-item {
display: flex;
gap: 15px;
padding: 15px;
background: #f9f9f9;
border-radius: 15px;
margin-bottom: 15px;
}
.item-image {
width: 80px;
height: 80px;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
font-weight: bold;
color: rgba(0,0,0,0.1);
}
.item-details {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.item-name {
font-size: 16px;
font-weight: bold;
margin: 0 0 5px 0;
}
.item-price {
color: var(--primary-color);
font-weight: bold;
margin: 0 0 10px 0;
}
.item-actions {
display: flex;
justify-content: space-between;
align-items: center;
}
.delete-icon {
color: #ff4757;
cursor: pointer;
font-size: 20px;
}
.empty-wishlist {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
color: #999;
}
.empty-wishlist p {
margin: 20px 0;
font-size: 16px;
}
</style>