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
+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>