2025-07-26 15:35:53 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="shop-page">
|
|
|
|
|
|
<!-- 导航栏 -->
|
|
|
|
|
|
<nav class="navbar">
|
2025-08-12 10:13:51 +08:00
|
|
|
|
<!-- 移除 nav-left 部分 -->
|
2025-07-26 15:35:53 +08:00
|
|
|
|
<div class="nav-center">
|
|
|
|
|
|
<h1 class="nav-title">积分商城</h1>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="nav-right">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="text"
|
2025-08-12 10:13:51 +08:00
|
|
|
|
@click="$router.push('#')"
|
2025-07-26 15:35:53 +08:00
|
|
|
|
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>
|
2025-08-12 10:56:05 +08:00
|
|
|
|
<div class="category-name">{{ category.name }}</div>
|
2025-07-26 15:35:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-08-21 10:56:15 +08:00
|
|
|
|
<!-- 推荐 -->
|
|
|
|
|
|
<div class="recommend">
|
|
|
|
|
|
<!-- 热销推荐 -->
|
|
|
|
|
|
<div class="recommend-grid">
|
|
|
|
|
|
<div class="recommend-title">热销推荐</div>
|
|
|
|
|
|
<div v-for="(product, index) in hotProducts" :key="index" class="recommend-product" @click="goToProduct(product.id)">
|
|
|
|
|
|
<div class="recommend-image">
|
|
|
|
|
|
<img :src="product.image" :alt="product.name" />
|
|
|
|
|
|
<div v-if="product.discount" class="recommend-discount">
|
|
|
|
|
|
{{ product.discount }}折
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="recommend-content">
|
|
|
|
|
|
<h4 class="recommend-name">{{ product.name }}</h4>
|
|
|
|
|
|
<div class="recommend-price-container">
|
|
|
|
|
|
<div class="recommend-price">
|
|
|
|
|
|
<el-icon><Coin /></el-icon>
|
|
|
|
|
|
{{ product.points }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="product.originalPoints" class="recommend-original-price">
|
|
|
|
|
|
{{ product.originalPoints }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 秒杀推荐 -->
|
|
|
|
|
|
<div class="recommend-grid">
|
|
|
|
|
|
<div class="recommend-title">秒杀推荐</div>
|
|
|
|
|
|
<div v-for="(product, index) in cheapProducts" :key="index" class="recommend-product" @click="goToProduct(product.id)">
|
|
|
|
|
|
<div class="recommend-image">
|
|
|
|
|
|
<img :src="product.image" :alt="product.name" />
|
|
|
|
|
|
<div v-if="product.discount" class="recommend-discount">
|
|
|
|
|
|
{{ product.discount }}折
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="recommend-content">
|
|
|
|
|
|
<h4 class="recommend-name">{{ product.name }}</h4>
|
|
|
|
|
|
<div class="recommend-price-container">
|
|
|
|
|
|
<div class="recommend-price">
|
|
|
|
|
|
<el-icon><Coin /></el-icon>
|
|
|
|
|
|
{{ product.points }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="product.originalPoints" class="recommend-original-price">
|
|
|
|
|
|
{{ product.originalPoints }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
<!-- 商品列表 -->
|
|
|
|
|
|
<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-31 13:54:37 +08:00
|
|
|
|
<img :src="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>
|
2025-08-12 09:38:34 +08:00
|
|
|
|
<h4 class="product-name">{{ product.name }}</h4>
|
|
|
|
|
|
<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>
|
2025-07-26 15:35:53 +08:00
|
|
|
|
</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%"
|
|
|
|
|
|
>
|
|
|
|
|
|
<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-31 13:54:37 +08:00
|
|
|
|
<img :src="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'
|
2025-08-01 09:33:46 +08:00
|
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
2025-07-26 15:35:53 +08:00
|
|
|
|
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'
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
2025-08-01 09:33:46 +08:00
|
|
|
|
const route = useRoute()
|
2025-07-26 15:35:53 +08:00
|
|
|
|
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: '🛍️' },
|
2025-08-12 10:56:05 +08:00
|
|
|
|
{ id: '数码产品', name: '电子数码', icon: '📱' },
|
2025-08-01 09:33:46 +08:00
|
|
|
|
{ id: '图书文具', name: '图书文具', icon: '📚' },
|
2025-08-12 10:56:05 +08:00
|
|
|
|
{ id: '生活用品', name: '日用百货', icon: '🏠' },
|
2025-08-01 09:33:46 +08:00
|
|
|
|
{ id: '食品饮料', name: '食品饮料', icon: '🍔' },
|
2025-08-12 10:56:05 +08:00
|
|
|
|
{ id: '服装配饰', name: '精美服饰', icon: '👕' },
|
2025-08-01 09:33:46 +08:00
|
|
|
|
{ id: '其他', name: '其他', icon: '📦' }
|
2025-07-26 15:35:53 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
2025-08-21 10:56:15 +08:00
|
|
|
|
//热销商品数据
|
|
|
|
|
|
const hotProducts = ref([
|
|
|
|
|
|
{ id: '6', name: '1', discount: '100', points: '9999', originalPoints:'999999' },
|
2025-08-22 09:14:07 +08:00
|
|
|
|
{ id: '6', name: '2', discount: '100', points: '9999', originalPoints:'999999' }
|
2025-08-21 10:56:15 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
//秒杀推荐数据
|
|
|
|
|
|
const cheapProducts = ref([
|
2025-08-22 09:14:07 +08:00
|
|
|
|
{ id: '6', name: '1', discount: '100', points: '9999', originalPoints:'999999' },
|
|
|
|
|
|
{ id: '6', name: '2', discount: '100', points: '9999', originalPoints:'999999' }
|
2025-08-21 10:56:15 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
// 计算属性
|
|
|
|
|
|
const filteredProducts = computed(() => {
|
|
|
|
|
|
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-31 13:54:37 +08:00
|
|
|
|
p.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
|
|
|
|
|
|
p.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
|
2025-07-26 15:35:53 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 排序
|
|
|
|
|
|
switch (sortBy.value) {
|
|
|
|
|
|
case 'price_asc':
|
2025-07-31 13:54:37 +08:00
|
|
|
|
result.sort((a, b) => a.points - b.points)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 'price_desc':
|
2025-07-31 13:54:37 +08:00
|
|
|
|
result.sort((a, b) => b.points - a.points)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
case 'sales':
|
2025-07-31 13:54:37 +08:00
|
|
|
|
result.sort((a, b) => b.sales - a.sales)
|
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-31 13:54:37 +08:00
|
|
|
|
return cartItems.value.reduce((sum, item) => sum + item.quantity, 0)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const totalPoints = computed(() => {
|
2025-07-31 13:54:37 +08:00
|
|
|
|
return cartItems.value.reduce((sum, item) => sum + (item.points * item.quantity), 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-08-01 09:33:46 +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-08-01 09:33:46 +08:00
|
|
|
|
console.log(data,'response');
|
2025-07-26 15:35:53 +08:00
|
|
|
|
|
|
|
|
|
|
if (isLoadMore) {
|
2025-08-01 09:33:46 +08:00
|
|
|
|
products.value.push(...data.data.products)
|
2025-07-26 15:35:53 +08:00
|
|
|
|
} else {
|
2025-08-01 09:33:46 +08:00
|
|
|
|
products.value = data.data.products
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-01 09:33:46 +08:00
|
|
|
|
hasMore.value = data.data.hasMore
|
2025-07-26 15:35:53 +08:00
|
|
|
|
page.value++
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
ElMessage.error('获取商品列表失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
loadingMore.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const loadMore = () => {
|
|
|
|
|
|
getProducts(true)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getUserPoints = async () => {
|
|
|
|
|
|
try {
|
2025-08-01 09:33:46 +08:00
|
|
|
|
const {data} = await api.get('/user/points')
|
2025-08-04 12:32:53 +08:00
|
|
|
|
console.log(data,'points');
|
|
|
|
|
|
|
|
|
|
|
|
userPoints.value = data.points
|
2025-07-26 15:35:53 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取用户积分失败:', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const truncateText = (text, maxLength) => {
|
|
|
|
|
|
if (text.length <= maxLength) return text
|
|
|
|
|
|
return text.substring(0, maxLength) + '...'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-21 10:56:15 +08:00
|
|
|
|
//获取热销推荐商品
|
|
|
|
|
|
const getHotProducts = async () => {
|
|
|
|
|
|
try {
|
2025-08-22 09:14:07 +08:00
|
|
|
|
const {data} = await api.get('')
|
|
|
|
|
|
hotProducts.value = data.data.products
|
2025-08-21 10:56:15 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log(error)
|
2025-08-22 09:14:07 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
console.log('热销:',hotProducts)
|
2025-08-21 10:56:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取秒杀推荐商品
|
|
|
|
|
|
const getCheapProducts = async () => {
|
|
|
|
|
|
try {
|
2025-08-22 09:14:07 +08:00
|
|
|
|
const {data} = await api.get('')
|
|
|
|
|
|
cheapProducts.value = data.data.products
|
2025-08-21 10:56:15 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log(error)
|
2025-08-22 09:14:07 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
console.log('秒杀:',cheapProducts)
|
2025-08-21 10:56:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
// 生命周期
|
|
|
|
|
|
onMounted(() => {
|
2025-08-01 09:33:46 +08:00
|
|
|
|
// 检查URL参数中是否有分类
|
|
|
|
|
|
const categoryFromQuery = route.query.category
|
|
|
|
|
|
if (categoryFromQuery && categories.value.some(cat => cat.id === categoryFromQuery)) {
|
|
|
|
|
|
selectedCategory.value = categoryFromQuery
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
getProducts()
|
|
|
|
|
|
getUserPoints()
|
2025-08-21 10:56:15 +08:00
|
|
|
|
getHotProducts()
|
|
|
|
|
|
getCheapProducts()
|
2025-07-26 15:35:53 +08:00
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.shop-page {
|
|
|
|
|
|
min-height: 100vh;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: linear-gradient(to bottom, #ffae00, #f3f3f3);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:13:51 +08:00
|
|
|
|
/* 导航栏保持白色背景 */
|
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-31 13:54:37 +08:00
|
|
|
|
background: white;
|
|
|
|
|
|
border-bottom: 1px solid #eee;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
position: sticky;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
z-index: 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:13:51 +08:00
|
|
|
|
.nav-center {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
pointer-events: none; /* 允许点击穿透到下方元素 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-title {
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
display: inline-block; /* 使文本能够真正居中 */
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-right {
|
2025-08-12 10:13:51 +08:00
|
|
|
|
margin-left: auto; /* 将积分按钮推到最右侧 */
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-btn,
|
|
|
|
|
|
.points-btn {
|
|
|
|
|
|
color: #409eff;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:13:51 +08:00
|
|
|
|
/* 搜索栏参与渐变 */
|
2025-07-26 15:35:53 +08:00
|
|
|
|
.search-section {
|
2025-07-31 13:54:37 +08:00
|
|
|
|
padding: 16px;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: transparent;
|
|
|
|
|
|
border-bottom: none;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:13:51 +08:00
|
|
|
|
.search-input :deep(.el-input__wrapper) {
|
|
|
|
|
|
border-radius: 1000px;
|
|
|
|
|
|
background-color: rgba(255,255,255,0.8);
|
|
|
|
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 分类筛选参与渐变 */
|
2025-07-26 15:35:53 +08:00
|
|
|
|
.category-section {
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: transparent;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
padding: 16px 0;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
border-bottom: none;
|
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;
|
2025-08-12 10:56:05 +08:00
|
|
|
|
align-items: center; /* 使子元素水平居中 */
|
|
|
|
|
|
justify-content: center; /* 使子元素垂直居中 */
|
2025-07-31 13:54:37 +08:00
|
|
|
|
gap: 4px;
|
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
|
border-radius: 8px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
cursor: pointer;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
min-width: 60px;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: rgba(255,255,255,0.8);
|
|
|
|
|
|
backdrop-filter: blur(5px);
|
|
|
|
|
|
-webkit-backdrop-filter: blur(5px);
|
|
|
|
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:56:05 +08:00
|
|
|
|
.category-name {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
/* 移除以下三个属性,取消文本省略效果 */
|
|
|
|
|
|
/* white-space: nowrap; */
|
|
|
|
|
|
/* overflow: hidden; */
|
|
|
|
|
|
/* text-overflow: ellipsis; */
|
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
.category-item:hover {
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: rgba(240,249,255,0.9);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item.active {
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: rgba(64,158,255,0.9);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
color: white;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item span {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:13:51 +08:00
|
|
|
|
/* 商品列表参与渐变 */
|
2025-07-26 15:35:53 +08:00
|
|
|
|
.products-section {
|
2025-07-31 13:54:37 +08:00
|
|
|
|
padding: 16px;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: transparent;
|
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;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sort-btn {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
cursor: pointer;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-grid {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
2025-08-12 09:38:34 +08:00
|
|
|
|
width: 163px;
|
|
|
|
|
|
height: 217px;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: rgba(255,255,255,0.9);
|
2025-07-31 13:54:37 +08:00
|
|
|
|
border-radius: 12px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
overflow: hidden;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
cursor: pointer;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
transition: all 0.3s;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
backdrop-filter: blur(2px);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover {
|
2025-07-31 13:54:37 +08:00
|
|
|
|
transform: translateY(-4px);
|
2025-08-12 10:13:51 +08:00
|
|
|
|
box-shadow: 0 8px 16px rgba(0,0,0,0.15);
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 100%;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
height: 163px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
overflow: hidden;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
flex-shrink: 0;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image img {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.discount-badge {
|
|
|
|
|
|
position: absolute;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
top: 8px;
|
|
|
|
|
|
right: 8px;
|
|
|
|
|
|
background: #ff4757;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
color: white;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
font-size: 12px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
2025-08-12 09:38:34 +08:00
|
|
|
|
margin: 8px 8px 4px;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #333;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
line-height: 1.4;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
margin: 0 8px;
|
|
|
|
|
|
padding-bottom: 8px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.current-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-07-31 13:54:37 +08:00
|
|
|
|
gap: 2px;
|
|
|
|
|
|
color: #ff6b35;
|
|
|
|
|
|
font-weight: 600;
|
2025-08-12 09:38:34 +08:00
|
|
|
|
font-size: 14px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.original-price {
|
2025-07-31 13:54:37 +08:00
|
|
|
|
color: #999;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
text-decoration: line-through;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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-31 13:54:37 +08:00
|
|
|
|
right: 20px;
|
|
|
|
|
|
width: 56px;
|
|
|
|
|
|
height: 56px;
|
|
|
|
|
|
background: #409eff;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
cursor: pointer;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
box-shadow: 0 4px 12px rgba(64,158,255,0.4);
|
2025-07-31 13:54:37 +08:00
|
|
|
|
z-index: 1000;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-content {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-08-12 10:13:51 +08:00
|
|
|
|
background: white;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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: 480px) {
|
|
|
|
|
|
.products-grid {
|
2025-08-12 09:38:34 +08:00
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
justify-items: center;
|
2025-07-28 12:22:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
2025-08-12 09:38:34 +08:00
|
|
|
|
width: calc(50vw - 24px);
|
|
|
|
|
|
max-width: 163px;
|
2025-07-26 15:35:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-21 10:56:15 +08:00
|
|
|
|
|
|
|
|
|
|
/* 推荐 */
|
|
|
|
|
|
.recommend {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
margin: 16px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
backdrop-filter: blur(5px);
|
|
|
|
|
|
-webkit-backdrop-filter: blur(5px);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-grid {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
margin: 0 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-product {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
width: 144px;
|
|
|
|
|
|
height: 54px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.95);
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
padding: 6px;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-product:hover {
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-image {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 42px;
|
|
|
|
|
|
height: 42px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-image img {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-discount {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 2px;
|
|
|
|
|
|
right: 2px;
|
|
|
|
|
|
background: #ff4757;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 1px 4px;
|
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-name {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
line-height: 1.3;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
margin-bottom: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-price-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 1px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 2px;
|
|
|
|
|
|
color: #ff6b35;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.recommend-original-price {
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
text-decoration: line-through;
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-26 15:35:53 +08:00
|
|
|
|
</style>
|