2025-08-25 16:56:14 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<!-- 头部 -->
|
|
|
|
|
|
<div class="header">
|
|
|
|
|
|
<span @click="$router.go(-1)"><返回</span>
|
2025-10-23 17:26:14 +08:00
|
|
|
|
<el-icon @click="$router.push(`/cart`)" style="color: #ffffff;"><ShoppingCart /></el-icon>
|
2025-08-25 16:56:14 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="products-container">
|
|
|
|
|
|
<div class="product-card">
|
|
|
|
|
|
<div class="product-image">
|
2025-08-26 16:15:46 +08:00
|
|
|
|
<div v-if="loading || !firstProduct.images" class="carousel-skeleton">
|
|
|
|
|
|
<div class="skeleton-image"></div>
|
|
|
|
|
|
<div class="skeleton-indicators">
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-08-25 16:56:14 +08:00
|
|
|
|
<el-carousel
|
2025-08-26 16:15:46 +08:00
|
|
|
|
v-else
|
2025-08-25 16:56:14 +08:00
|
|
|
|
:interval="4000"
|
|
|
|
|
|
indicator-position="outside"
|
|
|
|
|
|
style="min-height: 300px;"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-carousel-item v-for="(image, index) in firstProduct.images" :key="index">
|
2025-09-02 17:05:49 +08:00
|
|
|
|
<img :src="getImageUrl(image)" :alt="firstProduct.name" class="carousel-image" />
|
2025-08-25 16:56:14 +08:00
|
|
|
|
</el-carousel-item>
|
|
|
|
|
|
</el-carousel>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="product-details">
|
2025-09-02 17:05:49 +08:00
|
|
|
|
<img :src="getImageUrl(firstProduct.image)" :alt="firstProduct.name" class="small-image" />
|
2025-08-25 16:56:14 +08:00
|
|
|
|
<div class="product-info">
|
|
|
|
|
|
<span class="product-name">{{ firstProduct.name }}</span>
|
2025-09-02 11:41:20 +08:00
|
|
|
|
<div class="product-price">
|
|
|
|
|
|
<div class="main-price">
|
2025-09-03 11:00:08 +08:00
|
|
|
|
<img src='/imgs/profile/rongdou.png' alt="融豆" class="rongdou-icon" />
|
2025-09-02 11:41:20 +08:00
|
|
|
|
<span class="rongdou-price">{{ firstProduct.rongdou_price }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="sub-price">
|
|
|
|
|
|
<el-icon class="points-icon"><Coin /></el-icon>
|
|
|
|
|
|
<span class="points-price">{{ firstProduct.points_price }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-08-25 16:56:14 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<span @click="$router.push(`/product/${firstProduct.id}`)" class="link">详情></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="action">
|
|
|
|
|
|
<button class="button" @click="$router.push(`/product/${firstProduct.id}`)">立即购买</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-10-15 17:25:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-26 11:57:02 +08:00
|
|
|
|
<div v-for="product in products.filter(p => p.id !== firstProduct.id)" :key="product.id" class="product-card">
|
2025-08-25 16:56:14 +08:00
|
|
|
|
<!-- 轮播图部分 -->
|
|
|
|
|
|
<div class="product-image">
|
2025-10-15 17:25:43 +08:00
|
|
|
|
<div v-if="!product.images || product.images.length === 0" class="carousel-skeleton">
|
2025-08-26 16:15:46 +08:00
|
|
|
|
<div class="skeleton-image"></div>
|
|
|
|
|
|
<div class="skeleton-indicators">
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
<div class="skeleton-dot"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-08-25 16:56:14 +08:00
|
|
|
|
<el-carousel
|
2025-08-26 16:15:46 +08:00
|
|
|
|
v-else
|
2025-08-25 16:56:14 +08:00
|
|
|
|
:interval="4000"
|
|
|
|
|
|
indicator-position="outside"
|
2025-10-15 17:25:43 +08:00
|
|
|
|
height="300px"
|
2025-08-25 16:56:14 +08:00
|
|
|
|
>
|
2025-10-15 17:25:43 +08:00
|
|
|
|
<el-carousel-item v-for="(image, index) in product.images" :key="index">
|
2025-09-02 17:05:49 +08:00
|
|
|
|
<img :src="getImageUrl(image)" :alt="product.name" class="carousel-image" />
|
2025-08-25 16:56:14 +08:00
|
|
|
|
</el-carousel-item>
|
|
|
|
|
|
</el-carousel>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="product-details">
|
2025-09-02 17:05:49 +08:00
|
|
|
|
<img :src="getImageUrl(product.image)" :alt="product.name" class="small-image" />
|
2025-08-25 16:56:14 +08:00
|
|
|
|
<div class="product-info">
|
|
|
|
|
|
<span class="product-name">{{ product.name }}</span>
|
2025-09-02 11:41:20 +08:00
|
|
|
|
<div class="product-price">
|
|
|
|
|
|
<div class="main-price">
|
2025-09-03 11:00:08 +08:00
|
|
|
|
<img src='/imgs/profile/rongdou.png' alt="融豆" class="rongdou-icon" />
|
2025-09-02 11:41:20 +08:00
|
|
|
|
<span class="rongdou-price">{{ product.rongdou_price }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="sub-price">
|
|
|
|
|
|
<el-icon class="points-icon"><Coin /></el-icon>
|
|
|
|
|
|
<span class="points-price">{{ product.points_price }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-08-25 16:56:14 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<span @click="$router.push(`/product/${product.id}`)" class="link">详情></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="action">
|
|
|
|
|
|
<button class="button" @click="$router.push(`/product/${product.id}`)">立即购买</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
|
|
import api from '@/utils/api'
|
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
|
import {ElMessage} from "element-plus";
|
2025-09-02 11:41:20 +08:00
|
|
|
|
import {Bottom, ShoppingCart, Coin} from "@element-plus/icons-vue";
|
2025-08-25 16:56:14 +08:00
|
|
|
|
|
2025-08-29 16:58:00 +08:00
|
|
|
|
import { getImageUrl } from '@/config'
|
|
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
const products = ref([])
|
|
|
|
|
|
const firstProduct = ref([])
|
2025-08-26 14:41:48 +08:00
|
|
|
|
const productDetailsCache = ref({}) // 缓存所有商品详情
|
2025-08-26 16:15:46 +08:00
|
|
|
|
const loading = ref(true) // 添加加载状态
|
|
|
|
|
|
const detailsLoaded = ref(false) // 商品详情是否加载完成
|
2025-08-25 16:56:14 +08:00
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
const productId = ref(null)
|
|
|
|
|
|
|
|
|
|
|
|
const getProducts = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const { data } = await api.get('/products', {
|
|
|
|
|
|
params: {
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
limit: 20,
|
|
|
|
|
|
category: '',
|
|
|
|
|
|
keyword: '',
|
|
|
|
|
|
sort: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
console.log('API 响应数据:', data)
|
|
|
|
|
|
|
|
|
|
|
|
// 根据你的 API 响应结构调整这里
|
|
|
|
|
|
if (data.data && data.data.products) {
|
|
|
|
|
|
products.value = data.data.products
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Array.isArray(data.products)) {
|
|
|
|
|
|
products.value = data.products
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Array.isArray(data)) {
|
|
|
|
|
|
products.value = data
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
console.error('无法解析的商品数据格式:', data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-02 17:05:49 +08:00
|
|
|
|
// 不需要预处理图片路径,在模板中使用getImageUrl处理
|
2025-08-29 16:58:00 +08:00
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
console.log('解析后的商品数据:', products.value)
|
|
|
|
|
|
|
2025-08-26 14:41:48 +08:00
|
|
|
|
// 预加载所有商品详情
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// await loadAllProductDetails()
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取商品失败:', error)
|
|
|
|
|
|
console.error('错误详情:', error.response?.data)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getFirstProduct = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const productId = route.params.id
|
|
|
|
|
|
|
|
|
|
|
|
const [productRes] = await Promise.all([
|
|
|
|
|
|
api.get(`/products/${productId}`)
|
|
|
|
|
|
])
|
|
|
|
|
|
console.log(productRes,'productRes');
|
|
|
|
|
|
|
|
|
|
|
|
firstProduct.value = productRes.data.data.product
|
2025-08-29 16:58:00 +08:00
|
|
|
|
|
2025-09-02 17:05:49 +08:00
|
|
|
|
// 不需要预处理图片路径,在模板中使用getImageUrl处理
|
2025-08-25 16:56:14 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
ElMessage.error('获取商品详情失败')
|
|
|
|
|
|
console.log(error)
|
2025-08-26 16:15:46 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-02 11:41:20 +08:00
|
|
|
|
// const getProductDetail = async (productId) => {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// const response = await api.get(`/products/${productId}`)
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
2025-09-02 11:41:20 +08:00
|
|
|
|
// if (response.data && response.data.data && response.data.data.product) {
|
|
|
|
|
|
// productDetail.value = response.data.data.product
|
2025-08-29 16:58:00 +08:00
|
|
|
|
|
2025-09-02 11:41:20 +08:00
|
|
|
|
// // 处理商品详情的图片路径
|
|
|
|
|
|
// if (productDetail.value.image) {
|
|
|
|
|
|
// productDetail.value.image = getImageUrl(productDetail.value.image)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (productDetail.value.images && Array.isArray(productDetail.value.images)) {
|
|
|
|
|
|
// productDetail.value.images = productDetail.value.images.map(img => getImageUrl(img))
|
|
|
|
|
|
// }
|
2025-08-29 16:58:00 +08:00
|
|
|
|
|
2025-09-02 11:41:20 +08:00
|
|
|
|
// // 缓存商品详情
|
|
|
|
|
|
// productDetailsCache.value[productId] = productDetail.value
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// console.error('无法解析商品详情数据:', response.data)
|
|
|
|
|
|
// ElMessage.error('获取商品详情失败')
|
|
|
|
|
|
// }
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
2025-09-02 11:41:20 +08:00
|
|
|
|
// return productDetail.value
|
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
|
// console.error('获取商品详情失败:', error)
|
|
|
|
|
|
// console.error('错误详情:', error.response?.data)
|
|
|
|
|
|
// ElMessage.error('获取商品详情失败')
|
|
|
|
|
|
// throw error
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
|
|
|
|
|
// 预加载所有商品详情的函数
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// const loadAllProductDetails = async () => {
|
|
|
|
|
|
// const uniqueProductIds = [...new Set(products.value.map(p => p.id))]
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// // 并行加载所有商品详情,避免逐个加载时的多次渲染
|
|
|
|
|
|
// const loadPromises = uniqueProductIds.map(async (id) => {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// const response = await api.get(`/products/${id}`)
|
|
|
|
|
|
// if (response.data && response.data.data && response.data.data.product) {
|
|
|
|
|
|
// return { id, product: response.data.data.product }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
|
// console.warn(`Failed to load details for product ${id}:`, error)
|
|
|
|
|
|
// return null
|
|
|
|
|
|
// }
|
|
|
|
|
|
// })
|
2025-08-26 16:15:46 +08:00
|
|
|
|
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// // 等待所有请求完成
|
|
|
|
|
|
// const results = await Promise.all(loadPromises)
|
2025-08-26 16:15:46 +08:00
|
|
|
|
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// // 一次性更新缓存,避免多次触发响应式更新
|
|
|
|
|
|
// const newCache = { ...productDetailsCache.value }
|
|
|
|
|
|
// results.forEach(result => {
|
|
|
|
|
|
// if (result) {
|
|
|
|
|
|
// // 不需要预处理图片路径,在模板中使用getImageUrl处理
|
|
|
|
|
|
// newCache[result.id] = result.product
|
|
|
|
|
|
// }
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('123:', newCache,results)
|
2025-08-26 16:15:46 +08:00
|
|
|
|
|
2025-10-15 17:25:43 +08:00
|
|
|
|
// // 一次性更新缓存和加载状态
|
|
|
|
|
|
// productDetailsCache.value = newCache
|
|
|
|
|
|
// detailsLoaded.value = true
|
|
|
|
|
|
// }
|
2025-08-26 14:41:48 +08:00
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
// 添加生命周期钩子来调用函数
|
2025-08-26 16:15:46 +08:00
|
|
|
|
onMounted(async () => {
|
2025-08-25 16:56:14 +08:00
|
|
|
|
productId.value = route.params.id
|
|
|
|
|
|
console.log('Product ID:', productId.value)
|
2025-08-26 16:15:46 +08:00
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
|
|
|
|
// 先加载第一个商品,再加载商品列表,确保数据同步
|
|
|
|
|
|
await getFirstProduct()
|
|
|
|
|
|
await getProducts()
|
2025-08-25 16:56:14 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.header {
|
|
|
|
|
|
/* 基础布局 */
|
|
|
|
|
|
padding: 16px 20px;
|
2025-09-28 11:53:37 +08:00
|
|
|
|
background: #72c9ffae;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
|
|
|
|
|
|
/* 内容居中 */
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between; /* 添加此项使内容分布在两端 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.button {
|
2025-09-04 16:11:03 +08:00
|
|
|
|
background: #3ab3ff;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
color: white;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
padding: 12px 24px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
box-shadow: 0 4px 6px rgba(50, 142, 240, 0.2);
|
|
|
|
|
|
width: 50%;
|
|
|
|
|
|
margin: 12px auto 0; /* 修改这里:上下12px,左右自动居中 */
|
|
|
|
|
|
display: block; /* 添加此项使margin: auto生效 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.button:hover {
|
|
|
|
|
|
background: linear-gradient(135deg, #337ecc, #2a6db3);
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
box-shadow: 0 6px 12px rgba(50, 142, 240, 0.3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.button:active {
|
|
|
|
|
|
transform: translateY(0);
|
|
|
|
|
|
box-shadow: 0 2px 4px rgba(50, 142, 240, 0.2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header span {
|
|
|
|
|
|
/* 返回按钮样式 */
|
2025-09-28 11:53:37 +08:00
|
|
|
|
color: #ffffff;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
|
2025-09-28 11:53:37 +08:00
|
|
|
|
margin-left: -15px;
|
|
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
/* 添加返回图标占位 */
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.products-container {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
|
|
|
|
gap: 20px;
|
|
|
|
|
|
padding: 20px;
|
2025-09-04 16:11:03 +08:00
|
|
|
|
background: linear-gradient(to bottom, #72c9ffae, #f3f3f3);
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
|
|
|
|
|
border: 1px solid #e0e0e0;
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
background: white;
|
|
|
|
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
overflow: hidden;
|
2025-09-28 11:53:37 +08:00
|
|
|
|
width: 100%;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
min-height: 526px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column; /* 改为垂直布局 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card:hover {
|
|
|
|
|
|
transform: translateY(-4px);
|
|
|
|
|
|
box-shadow: 0 8px 16px rgba(0,0,0,0.15);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
/* 关键:添加底部内边距,容纳指示器 */
|
|
|
|
|
|
padding-bottom: 30px;
|
|
|
|
|
|
min-height: 300px; /* 保留轮播图最小高度 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.carousel-image {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
object-fit: contain; /* 完整显示图片,不裁剪 */
|
|
|
|
|
|
background-color: #f5f5f5; /* 空白处用浅灰色填充,避免白屏 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 修改部分开始 */
|
|
|
|
|
|
.product-details {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
margin-top: auto; /* 推到卡片底部 */
|
|
|
|
|
|
padding-top: 12px; /* 添加顶部间距 */
|
|
|
|
|
|
border-top: 1px solid #f0f0f0; /* 可选:添加分隔线 */
|
2025-08-26 11:57:02 +08:00
|
|
|
|
min-height: 70px; /* 确保有足够高度 */
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.small-image {
|
|
|
|
|
|
width: 60px;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
border: 2px solid #f0f0f0;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: space-between;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
flex: 1;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
min-width: 0;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
padding-right: 8px; /* 为详情链接留出空间 */
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
line-height: 1.4;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
display: -webkit-box;
|
2025-08-26 14:02:20 +08:00
|
|
|
|
line-clamp: 2;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
word-break: break-word; /* 允许长单词换行 */
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-price {
|
2025-09-02 11:41:20 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
margin-top: auto; /* 推到底部 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.main-price {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
color: #e53935;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
font-size: 18px;
|
2025-09-02 11:41:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.rongdou-icon {
|
|
|
|
|
|
width: 16px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.rongdou-price {
|
|
|
|
|
|
color: #e53935;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sub-price {
|
2025-08-25 16:56:14 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-09-02 11:41:20 +08:00
|
|
|
|
gap: 2px;
|
2025-09-02 13:56:09 +08:00
|
|
|
|
margin-left: 0;
|
2025-09-02 11:41:20 +08:00
|
|
|
|
margin-top: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.points-icon {
|
|
|
|
|
|
width: 12px;
|
|
|
|
|
|
height: 12px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.points-price {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
font-weight: normal;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.link {
|
|
|
|
|
|
color: #409eff;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
align-self: flex-start;
|
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
|
white-space: nowrap;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
/* 修改部分结束 */
|
|
|
|
|
|
|
2025-08-26 16:15:46 +08:00
|
|
|
|
/* 骨架屏样式 */
|
|
|
|
|
|
.carousel-skeleton {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 300px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
background: #f5f5f5;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.skeleton-image {
|
|
|
|
|
|
width: 80%;
|
|
|
|
|
|
height: 80%;
|
|
|
|
|
|
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
|
|
|
|
background-size: 200% 100%;
|
|
|
|
|
|
animation: skeleton-loading 1.5s infinite;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.skeleton-indicators {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 15px;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.skeleton-dot {
|
|
|
|
|
|
width: 8px;
|
|
|
|
|
|
height: 8px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background: #d0d0d0;
|
|
|
|
|
|
animation: skeleton-pulse 1.5s infinite;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.skeleton-dot:nth-child(2) {
|
|
|
|
|
|
animation-delay: 0.2s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.skeleton-dot:nth-child(3) {
|
|
|
|
|
|
animation-delay: 0.4s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes skeleton-loading {
|
|
|
|
|
|
0% {
|
|
|
|
|
|
background-position: -200% 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
100% {
|
|
|
|
|
|
background-position: 200% 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes skeleton-pulse {
|
|
|
|
|
|
0%, 100% {
|
|
|
|
|
|
opacity: 0.4;
|
|
|
|
|
|
}
|
|
|
|
|
|
50% {
|
|
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 16:56:14 +08:00
|
|
|
|
/* 轮播图样式调整 */
|
|
|
|
|
|
:deep(.el-carousel) {
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-carousel__container) {
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-carousel__indicators) {
|
|
|
|
|
|
bottom: 10px; /* 从 -25px 改为 10px,放在轮播图底部内侧 */
|
|
|
|
|
|
z-index: 10; /* 确保指示器在图片上方显示 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-carousel__button) {
|
|
|
|
|
|
width: 8px;
|
|
|
|
|
|
height: 8px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background-color: #ccc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-carousel__indicator.is-active .el-carousel__button) {
|
|
|
|
|
|
background-color: #409eff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 响应式设计 */
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
|
.products-container {
|
|
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
min-height: 450px; /* 移动端最小高度适配 */
|
|
|
|
|
|
width: 100%; /* 移动端卡片宽度占满父容器,避免超出屏幕 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
padding-bottom: 75%;
|
|
|
|
|
|
min-height: 200px; /* 移动端轮播图最小高度 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 响应式调整 */
|
|
|
|
|
|
.product-details {
|
|
|
|
|
|
gap: 10px;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
min-height: 60px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.small-image {
|
|
|
|
|
|
width: 50px;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
2025-08-26 11:57:02 +08:00
|
|
|
|
padding-right: 6px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 14px;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
margin-bottom: 6px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-price {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
2025-08-26 11:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
.link {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 480px) {
|
|
|
|
|
|
.products-container {
|
|
|
|
|
|
grid-template-columns: repeat(1, 1fr);
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-card {
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
|
height: 200px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 响应式调整 */
|
|
|
|
|
|
.product-details {
|
|
|
|
|
|
gap: 8px;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
min-height: 55px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.small-image {
|
|
|
|
|
|
width: 45px;
|
|
|
|
|
|
height: 45px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-info {
|
2025-08-26 11:57:02 +08:00
|
|
|
|
padding-right: 4px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-name {
|
|
|
|
|
|
font-size: 13px;
|
2025-08-26 11:57:02 +08:00
|
|
|
|
margin-bottom: 4px;
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.product-price {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
}
|
2025-08-26 11:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
.link {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
}
|
2025-08-25 16:56:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|