423 lines
8.5 KiB
Vue
423 lines
8.5 KiB
Vue
<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>
|