2025-07-26 15:35:53 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="shop-page">
|
|
|
|
|
|
<!-- 导航栏 -->
|
|
|
|
|
|
<nav class="navbar">
|
|
|
|
|
|
<div class="nav-center">
|
|
|
|
|
|
<h1 class="nav-title">积分商城</h1>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="nav-right">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
@click="$router.push('/points')"
|
|
|
|
|
|
class="points-btn"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><Coin /></el-icon>
|
|
|
|
|
|
{{ userPoints }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 搜索栏 -->
|
|
|
|
|
|
<div class="search-section">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="searchKeyword"
|
|
|
|
|
|
placeholder="搜索商品"
|
|
|
|
|
|
class="search-input"
|
|
|
|
|
|
@input="handleSearch"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #prefix>
|
|
|
|
|
|
<el-icon><Search /></el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 分类筛选 -->
|
|
|
|
|
|
<div class="category-section">
|
|
|
|
|
|
<el-scrollbar>
|
|
|
|
|
|
<div class="category-list">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="category in categories"
|
|
|
|
|
|
:key="category.id"
|
|
|
|
|
|
:class="['category-item', { active: selectedCategory === category.id }]"
|
|
|
|
|
|
@click="selectCategory(category.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon>{{ category.icon }}</el-icon>
|
|
|
|
|
|
<span>{{ category.name }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 商品列表 -->
|
|
|
|
|
|
<div class="products-section">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<h3>热门商品</h3>
|
|
|
|
|
|
<el-dropdown @command="handleSort">
|
|
|
|
|
|
<span class="sort-btn">
|
|
|
|
|
|
{{ sortText }}
|
|
|
|
|
|
<el-icon><ArrowDown /></el-icon>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item command="default">默认排序</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="price_asc">价格从低到高</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="price_desc">价格从高到低</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="sales">销量优先</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-loading="loading" class="products-grid">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="product in filteredProducts"
|
|
|
|
|
|
:key="product.id"
|
|
|
|
|
|
class="product-card"
|
|
|
|
|
|
@click="goToProduct(product.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="product-image">
|
2025-07-28 12:22:11 +08:00
|
|
|
|
<img :src="getImageUrl(product.image)" :alt="product.name" />
|
2025-07-26 15:35:53 +08:00
|
|
|
|
<div v-if="product.discount" class="discount-badge">
|
|
|
|
|
|
{{ product.discount }}折
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="product-info">
|
|
|
|
|
|
<h4 class="product-name">{{ product.name }}</h4>
|
|
|
|
|
|
<p class="product-desc">{{ truncateText(product.description, 50) }}</p>
|
|
|
|
|
|
<div class="product-price">
|
|
|
|
|
|
<span class="current-price">
|
|
|
|
|
|
<el-icon><Coin /></el-icon>
|
|
|
|
|
|
{{ product.points }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span v-if="product.originalPoints" class="original-price">
|
|
|
|
|
|
{{ product.originalPoints }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="product-stats">
|
|
|
|
|
|
<span class="sales">已售 {{ product.sales }}</span>
|
|
|
|
|
|
<span class="stock">库存 {{ product.stock }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="product-actions">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click.stop="addToCart(product)"
|
|
|
|
|
|
:disabled="product.stock === 0"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ product.stock === 0 ? '缺货' : '兑换' }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 空状态 -->
|
|
|
|
|
|
<div v-if="!loading && filteredProducts.length === 0" class="empty-state">
|
|
|
|
|
|
<el-icon size="60"><Box /></el-icon>
|
|
|
|
|
|
<p>暂无商品</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 加载更多 -->
|
|
|
|
|
|
<div v-if="hasMore" class="load-more">
|
|
|
|
|
|
<el-button @click="loadMore" :loading="loadingMore">
|
|
|
|
|
|
加载更多
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 购物车悬浮按钮 -->
|
|
|
|
|
|
<div class="cart-fab" @click="showCart = true">
|
|
|
|
|
|
<el-badge :value="cartCount" :hidden="cartCount === 0">
|
|
|
|
|
|
<el-icon size="24"><ShoppingCart /></el-icon>
|
|
|
|
|
|
</el-badge>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 购物车抽屉 -->
|
|
|
|
|
|
<el-drawer
|
|
|
|
|
|
v-model="showCart"
|
|
|
|
|
|
title="购物车"
|
|
|
|
|
|
direction="rtl"
|
|
|
|
|
|
size="80%"
|
2025-07-28 12:22:11 +08:00
|
|
|
|
:z-index="10000"
|
|
|
|
|
|
:modal="true"
|
|
|
|
|
|
:append-to-body="true"
|
2025-07-26 15:35:53 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div class="cart-content">
|
|
|
|
|
|
<div v-if="cartItems.length === 0" class="empty-cart">
|
|
|
|
|
|
<el-icon size="60"><ShoppingCart /></el-icon>
|
|
|
|
|
|
<p>购物车是空的</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
|
|
|
|
|
<div v-for="item in cartItems" :key="item.id" class="cart-item">
|
2025-07-28 12:22:11 +08:00
|
|
|
|
<img :src="getImageUrl(item.image)" :alt="item.name" class="item-image" />
|
2025-07-26 15:35:53 +08:00
|
|
|
|
<div class="item-info">
|
|
|
|
|
|
<h4>{{ item.name }}</h4>
|
|
|
|
|
|
<p class="item-price">
|
|
|
|
|
|
<el-icon><Coin /></el-icon>
|
|
|
|
|
|
{{ item.points }}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="item-actions">
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
v-model="item.quantity"
|
|
|
|
|
|
:min="1"
|
|
|
|
|
|
:max="item.stock"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@change="updateCartItem(item)"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="danger"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="removeFromCart(item.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="cart-footer">
|
|
|
|
|
|
<div class="total-points">
|
|
|
|
|
|
总计:<el-icon><Coin /></el-icon>{{ totalPoints }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
@click="checkout"
|
|
|
|
|
|
:disabled="totalPoints > userPoints"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ totalPoints > userPoints ? '积分不足' : '立即兑换' }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-drawer>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref, reactive, computed, onMounted } from 'vue'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
|
import {
|
|
|
|
|
|
ArrowLeft,
|
|
|
|
|
|
Coin,
|
|
|
|
|
|
Search,
|
|
|
|
|
|
ArrowDown,
|
|
|
|
|
|
Box,
|
|
|
|
|
|
ShoppingCart
|
|
|
|
|
|
} from '@element-plus/icons-vue'
|
|
|
|
|
|
import api from '@/utils/api'
|
|
|
|
|
|
import { debounce } from 'lodash-es'
|
2025-07-28 12:22:11 +08:00
|
|
|
|
import { getImageUrl } from '@/config'
|
2025-07-26 15:35:53 +08:00
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
|
|
|
|
// 响应式数据
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const loadingMore = ref(false)
|
|
|
|
|
|
const searchKeyword = ref('')
|
|
|
|
|
|
const selectedCategory = ref('all')
|
|
|
|
|
|
const sortBy = ref('default')
|
|
|
|
|
|
const products = ref([])
|
|
|
|
|
|
const page = ref(1)
|
|
|
|
|
|
const hasMore = ref(true)
|
|
|
|
|
|
const showCart = ref(false)
|
|
|
|
|
|
const cartItems = ref([])
|
|
|
|
|
|
|
|
|
|
|
|
// 用户积分
|
|
|
|
|
|
const userPoints = ref(0)
|
|
|
|
|
|
|
|
|
|
|
|
// 分类数据
|
|
|
|
|
|
const categories = ref([
|
|
|
|
|
|
{ id: 'all', name: '全部', icon: '🛍️' },
|
|
|
|
|
|
{ id: 'electronics', name: '数码', icon: '📱' },
|
|
|
|
|
|
{ id: 'books', name: '图书', icon: '📚' },
|
|
|
|
|
|
{ id: 'lifestyle', name: '生活', icon: '🏠' },
|
|
|
|
|
|
{ id: 'food', name: '美食', icon: '🍔' },
|
|
|
|
|
|
{ id: 'sports', name: '运动', icon: '⚽' },
|
|
|
|
|
|
{ id: 'beauty', name: '美妆', icon: '💄' }
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
// 计算属性
|
|
|
|
|
|
const filteredProducts = computed(() => {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 安全检查:确保products.value是数组
|
|
|
|
|
|
if (!products.value || !Array.isArray(products.value)) {
|
|
|
|
|
|
return []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
let result = products.value
|
|
|
|
|
|
|
|
|
|
|
|
// 分类筛选
|
|
|
|
|
|
if (selectedCategory.value !== 'all') {
|
|
|
|
|
|
result = result.filter(p => p.category === selectedCategory.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 搜索筛选
|
|
|
|
|
|
if (searchKeyword.value) {
|
|
|
|
|
|
result = result.filter(p =>
|
2025-07-28 12:22:11 +08:00
|
|
|
|
p.name && p.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
|
|
|
|
|
|
p.description && p.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
|
2025-07-26 15:35:53 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 排序
|
|
|
|
|
|
switch (sortBy.value) {
|
|
|
|
|
|
case 'price_asc':
|
2025-07-28 12:22:11 +08:00
|
|
|
|
result.sort((a, b) => (a.points || 0) - (b.points || 0))
|
2025-07-26 15:35:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 'price_desc':
|
2025-07-28 12:22:11 +08:00
|
|
|
|
result.sort((a, b) => (b.points || 0) - (a.points || 0))
|
2025-07-26 15:35:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 'sales':
|
2025-07-28 12:22:11 +08:00
|
|
|
|
result.sort((a, b) => (b.sales || 0) - (a.sales || 0))
|
2025-07-26 15:35:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const sortText = computed(() => {
|
|
|
|
|
|
const sortMap = {
|
|
|
|
|
|
default: '默认排序',
|
|
|
|
|
|
price_asc: '价格从低到高',
|
|
|
|
|
|
price_desc: '价格从高到低',
|
|
|
|
|
|
sales: '销量优先'
|
|
|
|
|
|
}
|
|
|
|
|
|
return sortMap[sortBy.value]
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const cartCount = computed(() => {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 安全检查:确保cartItems.value是数组
|
|
|
|
|
|
if (!cartItems.value || !Array.isArray(cartItems.value)) {
|
|
|
|
|
|
return 0
|
|
|
|
|
|
}
|
|
|
|
|
|
return cartItems.value.reduce((sum, item) => sum + (item.quantity || 0), 0)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const totalPoints = computed(() => {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 安全检查:确保cartItems.value是数组
|
|
|
|
|
|
if (!cartItems.value || !Array.isArray(cartItems.value)) {
|
|
|
|
|
|
return 0
|
|
|
|
|
|
}
|
|
|
|
|
|
return cartItems.value.reduce((sum, item) => sum + ((item.points || 0) * (item.quantity || 0)), 0)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 方法
|
|
|
|
|
|
const selectCategory = (categoryId) => {
|
|
|
|
|
|
selectedCategory.value = categoryId
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleSort = (command) => {
|
|
|
|
|
|
sortBy.value = command
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleSearch = debounce(() => {
|
|
|
|
|
|
// 搜索逻辑已在计算属性中处理
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
|
|
|
|
|
|
const goToProduct = (productId) => {
|
|
|
|
|
|
router.push(`/product/${productId}`)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const addToCart = (product) => {
|
|
|
|
|
|
const existingItem = cartItems.value.find(item => item.id === product.id)
|
|
|
|
|
|
|
|
|
|
|
|
if (existingItem) {
|
|
|
|
|
|
if (existingItem.quantity < product.stock) {
|
|
|
|
|
|
existingItem.quantity++
|
|
|
|
|
|
ElMessage.success('已添加到购物车')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.warning('库存不足')
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
cartItems.value.push({
|
|
|
|
|
|
...product,
|
|
|
|
|
|
quantity: 1
|
|
|
|
|
|
})
|
|
|
|
|
|
ElMessage.success('已添加到购物车')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const updateCartItem = (item) => {
|
|
|
|
|
|
// 数量更新逻辑
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const removeFromCart = (productId) => {
|
|
|
|
|
|
const index = cartItems.value.findIndex(item => item.id === productId)
|
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
cartItems.value.splice(index, 1)
|
|
|
|
|
|
ElMessage.success('已从购物车移除')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const checkout = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(
|
|
|
|
|
|
`确定要花费 ${totalPoints.value} 积分兑换这些商品吗?`,
|
|
|
|
|
|
'确认兑换',
|
|
|
|
|
|
{
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const orderData = {
|
|
|
|
|
|
items: cartItems.value.map(item => ({
|
|
|
|
|
|
productId: item.id,
|
|
|
|
|
|
quantity: item.quantity,
|
|
|
|
|
|
points: item.points
|
|
|
|
|
|
})),
|
|
|
|
|
|
totalPoints: totalPoints.value
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await api.post('/orders', orderData)
|
|
|
|
|
|
|
|
|
|
|
|
// 清空购物车
|
|
|
|
|
|
cartItems.value = []
|
|
|
|
|
|
showCart.value = false
|
|
|
|
|
|
|
|
|
|
|
|
// 更新用户积分
|
|
|
|
|
|
userPoints.value -= totalPoints.value
|
|
|
|
|
|
|
|
|
|
|
|
ElMessage.success('兑换成功!')
|
|
|
|
|
|
router.push('/orders')
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
if (error !== 'cancel') {
|
|
|
|
|
|
ElMessage.error('兑换失败,请重试')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getProducts = async (isLoadMore = false) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (!isLoadMore) {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
page.value = 1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
loadingMore.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-28 12:22:11 +08:00
|
|
|
|
const {data} = await api.get('/products', {
|
2025-07-26 15:35:53 +08:00
|
|
|
|
params: {
|
|
|
|
|
|
page: page.value,
|
|
|
|
|
|
limit: 20,
|
|
|
|
|
|
category: selectedCategory.value === 'all' ? '' : selectedCategory.value,
|
|
|
|
|
|
keyword: searchKeyword.value,
|
|
|
|
|
|
sort: sortBy.value
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 确保响应数据是有效的数组
|
|
|
|
|
|
const responseProducts = data.data?.products || []
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
if (isLoadMore) {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 确保products.value是数组
|
|
|
|
|
|
if (!Array.isArray(products.value)) {
|
|
|
|
|
|
products.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
products.value.push(...responseProducts)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
} else {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
products.value = responseProducts
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-28 12:22:11 +08:00
|
|
|
|
hasMore.value = data.data?.hasMore || false
|
2025-07-26 15:35:53 +08:00
|
|
|
|
page.value++
|
|
|
|
|
|
} catch (error) {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
console.error('获取商品列表失败:', error)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
ElMessage.error('获取商品列表失败')
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 确保products.value始终是数组
|
|
|
|
|
|
if (!isLoadMore && (!products.value || !Array.isArray(products.value))) {
|
|
|
|
|
|
products.value = []
|
|
|
|
|
|
}
|
2025-07-26 15:35:53 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
loadingMore.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const loadMore = () => {
|
|
|
|
|
|
getProducts(true)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getUserPoints = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await api.get('/user/points')
|
2025-07-28 12:22:11 +08:00
|
|
|
|
userPoints.value = response.data.points || 0
|
2025-07-26 15:35:53 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取用户积分失败:', error)
|
2025-07-28 12:22:11 +08:00
|
|
|
|
userPoints.value = 0
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const truncateText = (text, maxLength) => {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
// 安全检查:确保text是字符串
|
|
|
|
|
|
if (!text || typeof text !== 'string') {
|
|
|
|
|
|
return ''
|
|
|
|
|
|
}
|
2025-07-26 15:35:53 +08:00
|
|
|
|
if (text.length <= maxLength) return text
|
|
|
|
|
|
return text.substring(0, maxLength) + '...'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 生命周期
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
getProducts()
|
|
|
|
|
|
getUserPoints()
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.shop-page {
|
|
|
|
|
|
min-height: 100vh;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
|
|
background-attachment: fixed;
|
|
|
|
|
|
padding-bottom: 80px;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
/* 移动端优化 */
|
|
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.shop-page::before {
|
|
|
|
|
|
content: '';
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
background:
|
|
|
|
|
|
radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
|
|
|
|
|
|
radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
|
|
|
|
|
|
radial-gradient(circle at 40% 40%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
z-index: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.shop-page > * {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
z-index: 1;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.navbar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
|
height: 56px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: rgba(255, 255, 255, 0.95);
|
|
|
|
|
|
backdrop-filter: blur(20px);
|
|
|
|
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
position: sticky;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
z-index: 100;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-left,
|
|
|
|
|
|
.nav-right {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-right {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-btn,
|
|
|
|
|
|
.points-btn {
|
|
|
|
|
|
color: #409eff;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-title {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 18px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
font-weight: 800;
|
|
|
|
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
|
-webkit-text-fill-color: transparent;
|
|
|
|
|
|
background-clip: text;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-section {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 20px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
|
|
|
|
|
margin: 20px 16px 0 16px;
|
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-section {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
|
|
|
|
|
margin: 0 16px;
|
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
|
margin-top: 16px;
|
|
|
|
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-list {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
gap: 6px;
|
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
|
border-radius: 16px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
cursor: pointer;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
min-width: 70px;
|
|
|
|
|
|
background: rgba(248, 250, 252, 0.8);
|
|
|
|
|
|
border: 2px solid transparent;
|
|
|
|
|
|
/* 移动端触摸优化 */
|
|
|
|
|
|
-webkit-tap-highlight-color: transparent;
|
|
|
|
|
|
touch-action: manipulation;
|
|
|
|
|
|
user-select: none;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item:hover {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: rgba(139, 92, 246, 0.1);
|
|
|
|
|
|
border-color: rgba(139, 92, 246, 0.3);
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item.active {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
color: white;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
border-color: rgba(255, 255, 255, 0.3);
|
|
|
|
|
|
box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
|
|
|
|
|
|
transform: translateY(-3px);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item span {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-section {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 20px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
|
margin: 20px;
|
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-header h3 {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sort-btn {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-grid {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
|
|
|
|
|
|
backdrop-filter: blur(20px);
|
|
|
|
|
|
border-radius: 16px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
overflow: hidden;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
|
|
|
|
|
|
border: 1px solid rgba(139, 92, 246, 0.2);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
cursor: pointer;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
/* 移动端触摸优化 */
|
|
|
|
|
|
-webkit-tap-highlight-color: transparent;
|
|
|
|
|
|
touch-action: manipulation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card::before {
|
|
|
|
|
|
content: '';
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(124, 58, 237, 0.06) 100%);
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transition: opacity 0.3s ease;
|
|
|
|
|
|
pointer-events: none;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
transform: translateY(-8px) scale(1.02);
|
|
|
|
|
|
box-shadow: 0 16px 48px rgba(139, 92, 246, 0.25);
|
|
|
|
|
|
border-color: rgba(139, 92, 246, 0.4);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover::before {
|
|
|
|
|
|
opacity: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:active {
|
|
|
|
|
|
transform: translateY(-4px) scale(1.01);
|
|
|
|
|
|
transition: all 0.1s;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 100%;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
height: 140px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
overflow: hidden;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: linear-gradient(45deg, #f1f5f9 0%, #e2e8f0 100%);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image img {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
object-fit: cover;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover .product-image img {
|
|
|
|
|
|
transform: scale(1.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.discount-badge {
|
|
|
|
|
|
position: absolute;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
top: 12px;
|
|
|
|
|
|
right: 12px;
|
|
|
|
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
color: white;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
|
|
|
|
|
|
backdrop-filter: blur(10px);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 16px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
|
|
|
backdrop-filter: blur(15px);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
margin: 0 0 6px 0;
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #1e293b;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
line-height: 1.4;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-desc {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
margin: 0 0 12px 0;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
font-size: 12px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
color: #64748b;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
margin-bottom: 12px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.current-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
gap: 4px;
|
|
|
|
|
|
color: #f59e0b;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
font-size: 17px;
|
|
|
|
|
|
background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
|
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
|
-webkit-text-fill-color: transparent;
|
|
|
|
|
|
background-clip: text;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.original-price {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
color: #94a3b8;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
text-decoration: line-through;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
font-weight: 500;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-stats {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
color: #64748b;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
margin-bottom: 8px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
background: rgba(139, 92, 246, 0.08);
|
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
backdrop-filter: blur(5px);
|
|
|
|
|
|
border: 1px solid rgba(139, 92, 246, 0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 0 16px 16px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button {
|
|
|
|
|
|
width: 100%;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
height: 40px;
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
|
|
|
|
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button:hover {
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
|
|
|
|
|
|
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button:active {
|
|
|
|
|
|
transform: translateY(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button:disabled {
|
|
|
|
|
|
background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
|
|
|
|
|
|
color: #64748b;
|
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
transform: none;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-state {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 60px 20px;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.load-more {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 80px;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
right: 40px;
|
|
|
|
|
|
width: 64px;
|
|
|
|
|
|
height: 64px;
|
|
|
|
|
|
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
cursor: pointer;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
|
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
|
/* 移动端触摸优化 */
|
|
|
|
|
|
-webkit-tap-highlight-color: transparent;
|
|
|
|
|
|
touch-action: manipulation;
|
|
|
|
|
|
user-select: none;
|
|
|
|
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
|
border: 2px solid rgba(255, 255, 255, 0.2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-badge {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: -6px;
|
|
|
|
|
|
right: -6px;
|
|
|
|
|
|
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
width: 24px;
|
|
|
|
|
|
height: 24px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
|
|
|
|
|
|
border: 2px solid white;
|
|
|
|
|
|
animation: pulse 2s infinite;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes pulse {
|
|
|
|
|
|
0% {
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 0 rgba(239, 68, 68, 0.7);
|
|
|
|
|
|
}
|
|
|
|
|
|
70% {
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 10px rgba(239, 68, 68, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
100% {
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), 0 0 0 0 rgba(239, 68, 68, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab:hover {
|
|
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
|
box-shadow: 0 12px 35px rgba(139, 92, 246, 0.5);
|
|
|
|
|
|
background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab:active {
|
|
|
|
|
|
transform: scale(1.05);
|
|
|
|
|
|
box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-content {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-cart {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
padding: 16px 0;
|
|
|
|
|
|
border-bottom: 1px solid #eee;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-image {
|
|
|
|
|
|
width: 60px;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-info {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-info h4 {
|
|
|
|
|
|
margin: 0 0 4px 0;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 2px;
|
|
|
|
|
|
color: #ff6b35;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-actions {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
align-items: flex-end;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-footer {
|
|
|
|
|
|
margin-top: auto;
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.total-points {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #ff6b35;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 响应式设计 */
|
2025-07-28 12:22:11 +08:00
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
|
.navbar {
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-title {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-btn,
|
|
|
|
|
|
.points-btn {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-section {
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
margin: 16px 12px 0 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-section {
|
|
|
|
|
|
padding: 12px 0;
|
|
|
|
|
|
margin: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-list {
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
overflow-x: auto;
|
|
|
|
|
|
scrollbar-width: none;
|
|
|
|
|
|
-ms-overflow-style: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-list::-webkit-scrollbar {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item {
|
|
|
|
|
|
min-width: 60px;
|
|
|
|
|
|
padding: 8px 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item span {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-section {
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
margin: 16px 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-header {
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-header h3 {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sort-btn {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
.products-grid {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
gap: 12px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover {
|
|
|
|
|
|
transform: none;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
height: 120px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
2025-07-28 12:22:11 +08:00
|
|
|
|
padding: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-desc {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.current-price {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab {
|
|
|
|
|
|
bottom: 70px;
|
|
|
|
|
|
right: 16px;
|
|
|
|
|
|
width: 56px;
|
|
|
|
|
|
height: 56px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 480px) {
|
|
|
|
|
|
.navbar {
|
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
|
height: 48px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-title {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-section {
|
|
|
|
|
|
margin: 12px 8px 0 8px;
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-section {
|
|
|
|
|
|
margin: 8px;
|
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-section {
|
|
|
|
|
|
margin: 12px 8px;
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-grid {
|
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
height: 100px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-desc {
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.current-price {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-stats {
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions {
|
|
|
|
|
|
padding: 0 10px 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab {
|
|
|
|
|
|
bottom: 60px;
|
|
|
|
|
|
right: 12px;
|
|
|
|
|
|
width: 52px;
|
|
|
|
|
|
height: 52px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-item {
|
|
|
|
|
|
padding: 12px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-image {
|
|
|
|
|
|
width: 50px;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-info h4 {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-price {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.total-points {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 360px) {
|
|
|
|
|
|
.navbar {
|
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-section {
|
|
|
|
|
|
margin: 8px 6px 0 6px;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-section {
|
|
|
|
|
|
margin: 6px;
|
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-section {
|
|
|
|
|
|
margin: 8px 6px;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-list {
|
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item {
|
|
|
|
|
|
min-width: 50px;
|
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-grid {
|
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
height: 85px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
|
|
|
|
|
padding: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.current-price {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions {
|
|
|
|
|
|
padding: 0 8px 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-actions .el-button {
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-fab {
|
|
|
|
|
|
right: 8px;
|
|
|
|
|
|
width: 48px;
|
|
|
|
|
|
height: 48px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|