consumer模块完成度95%,准备部署消费者端测试
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!-- pages/mall/consumer/cart.uvue -->
|
||||
<!-- pages/mall/consumer/cart.uvue -->
|
||||
<template>
|
||||
<view class="cart-page">
|
||||
<!-- 智能顶部导航栏 - 与消息页保持一致 -->
|
||||
@@ -118,6 +118,10 @@
|
||||
<view v-if="recommendProducts.length > 0" class="recommend-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">猜你喜欢</text>
|
||||
<view class="refresh-btn" @click="refreshRecommend">
|
||||
<text class="refresh-icon">🔄</text>
|
||||
<text class="refresh-text">换一批</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="recommend-list">
|
||||
<view
|
||||
@@ -281,6 +285,35 @@ onMounted(() => {
|
||||
initPage()
|
||||
})
|
||||
|
||||
const refreshRecommend = async () => {
|
||||
try {
|
||||
// 使用 searchProducts 获取销售额排序的 6 个产品
|
||||
const hotResp = await supabaseService.searchProducts('', 1, 6, 'sales')
|
||||
const recommends = hotResp.data
|
||||
|
||||
if (recommends.length > 0) {
|
||||
recommendProducts.value = recommends.map((p: Product): RecommendProduct => {
|
||||
return {
|
||||
id: p.id,
|
||||
shopId: p.merchant_id ?? 'unknown',
|
||||
shopName: p.shop_name ?? '商城推荐',
|
||||
name: p.name,
|
||||
price: p.base_price ?? p.market_price ?? 0,
|
||||
image: p.main_image_url ?? p.image_url ?? '/static/images/default-product.png',
|
||||
skuId: '',
|
||||
merchant_id: p.merchant_id ?? ''
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '已更新推荐',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('刷新推荐失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
const loadCartData = async () => {
|
||||
loading.value = true
|
||||
@@ -746,9 +779,9 @@ const goToCheckout = () => {
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #4CAF50;
|
||||
background-color: #ff5000;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 2px 12px rgba(76, 175, 80, 0.15);
|
||||
box-shadow: 0 2px 12px rgba(255, 80, 0, 0.15);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
@@ -943,10 +976,9 @@ const goToCheckout = () => {
|
||||
background-color: #ff5000;
|
||||
color: white;
|
||||
border-radius: 9px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
line-height: 18px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.unselected-icon {
|
||||
@@ -1012,29 +1044,30 @@ const goToCheckout = () => {
|
||||
|
||||
.quantity-control {
|
||||
display: flex;
|
||||
flex-direction: row; /* 显式设置横向排列 */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
height: 24px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.quantity-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
text-align: center;
|
||||
line-height: 28px;
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.quantity-value {
|
||||
width: 30px;
|
||||
min-width: 36px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
line-height: 24px;
|
||||
font-size: 14px;
|
||||
line-height: 28px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 推荐商品 */
|
||||
@@ -1047,6 +1080,27 @@ const goToCheckout = () => {
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 15px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.refresh-icon {
|
||||
font-size: 14px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.refresh-text {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@@ -1504,3 +1558,4 @@ const goToCheckout = () => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user