consumer模块完成度95%,优化安卓端界面和小程序测试2

This commit is contained in:
cyh666666
2026-03-12 15:20:45 +08:00
parent 77f9968d18
commit b2a6e5a142
633 changed files with 4405 additions and 1651 deletions

View File

@@ -1,4 +1,4 @@
<!-- pages/main/cart.uvue -->
<!-- pages/main/cart.uvue -->
<template>
<view class="cart-page">
<!-- 智能顶部导航栏 - 与消息页保持一致 -->
@@ -103,6 +103,7 @@
<view v-if="!isManageMode" class="total-info">
<text class="total-text">合计:</text>
<text class="total-price">¥{{ totalPrice }}</text>
<text v-if="parseFloat(memberSavedAmount) > 0" class="member-saved">会员已省¥{{ memberSavedAmount }}</text>
</view>
<button v-if="!isManageMode" class="checkout-btn" @click="goToCheckout">
去结算({{ selectedCount }})
@@ -188,6 +189,8 @@ type LocalCartItem = {
shopName: string
name: string
price: number
originalPrice: number // 原价
memberPrice: number // 会员价
image: string
spec: string
quantity: number
@@ -284,7 +287,19 @@ const selectedCount = computed(() => {
const totalPrice = computed(() => {
return cartItems.value
.filter((item: LocalCartItem) => item.selected)
.reduce((sum: number, item: LocalCartItem) => sum + item.price * item.quantity, 0)
.reduce((sum: number, item: LocalCartItem) => {
// 优先使用会员价,如果没有会员价则使用原价
const finalPrice = item.memberPrice > 0 && item.memberPrice < item.price ? item.memberPrice : item.price
return sum + finalPrice * item.quantity
}, 0)
.toFixed(2)
})
// 计算会员节省金额
const memberSavedAmount = computed(() => {
return cartItems.value
.filter((item: LocalCartItem) => item.selected && item.memberPrice > 0 && item.memberPrice < item.price)
.reduce((sum: number, item: LocalCartItem) => sum + (item.price - item.memberPrice) * item.quantity, 0)
.toFixed(2)
})
@@ -393,6 +408,18 @@ const loadCartData = async () => {
loading.value = true
try {
// 获取会员折扣信息
let memberDiscount = 1.0
try {
const memberInfo = await supabaseService.getUserMemberInfo()
const discountRaw = memberInfo.get('discount')
if (discountRaw != null) {
memberDiscount = discountRaw as number
}
} catch (e) {
console.log('获取会员信息失败,使用默认折扣:', e)
}
// 从Supabase加载购物车数据
const supabaseCartItems = await supabaseService.getCartItems()
@@ -405,12 +432,21 @@ const loadCartData = async () => {
const shopId = (item.shop_id != null && item.shop_id !== '') ? item.shop_id : 'default_shop'
const shopName = (item.shop_name != null && item.shop_name !== '') ? item.shop_name : '商城优选'
// 计算会员价
const originalPrice = item.product_price != null ? item.product_price : 0
let memberPrice = 0
if (memberDiscount > 0 && memberDiscount < 1 && originalPrice > 0) {
memberPrice = Math.round(originalPrice * memberDiscount * 100) / 100
}
return {
id: item.id,
shopId: shopId,
shopName: shopName,
name: item.product_name ?? '未知商品',
price: item.product_price != null ? item.product_price : 0,
price: originalPrice,
originalPrice: originalPrice,
memberPrice: memberPrice,
image: item.product_image ?? '/static/images/default-product.png',
spec: item.product_specification ?? '标准规格',
quantity: item.quantity ?? 1,
@@ -534,6 +570,8 @@ const toggleShopSelect = async (shopId: string) => {
shopName: item.shopName,
name: item.name,
price: item.price,
originalPrice: item.originalPrice,
memberPrice: item.memberPrice,
image: item.image,
spec: item.spec,
quantity: item.quantity,