feat: 商品详情的价格的计算处理

This commit is contained in:
2025-09-16 20:39:17 +08:00
parent 8d0c93206b
commit 6443b67d15
5 changed files with 142 additions and 13 deletions

View File

@@ -39,8 +39,18 @@
}}</view>
<view class="goods-price">
<text class="currency">¥</text>
<text class="price">
{{ goodsData.specificationPrice || 399 }}
<template v-if="goodsData.commodityTypeCode === '0'">
<text class="price">
{{ goodsData.calculatedTotalPrice || 0 }}
</text>
<text class="price-desc">
({{ goodsData.startDate }}{{ goodsData.endDate }}) {{
goodsData.totalDays
}}
</text>
</template>
<text v-else class="price">
{{ goodsData.specificationPrice || 0 }}
</text>
</view>
<view
@@ -95,7 +105,11 @@
<!-- 总价区域 -->
<SumCard
:referencePrice="goodsData.specificationPrice"
:referencePrice="
goodsData.commodityTypeCode === '0'
? goodsData.calculatedTotalPrice
: goodsData.specificationPrice
"
:discount="totalPrice"
/>
</view>
@@ -180,7 +194,10 @@ const isDeleting = ref(false); // 标志位防止删除时watch冲突
// 计算属性
const totalPrice = computed(() => {
const price = props.goodsData?.specificationPrice || DEFAULT_PRICE;
const price =
props.goodsData?.commodityTypeCode === "0"
? props.goodsData?.calculatedTotalPrice
: props.goodsData?.specificationPrice || 0;
return (price * quantity.value).toFixed(0);
});

View File

@@ -92,6 +92,13 @@
font-weight: 600;
margin-left: 2px;
}
.price-desc {
font-size: 14px;
color: #999;
font-weight: 400;
margin-left: 12px;
}
}
.goods-service-list {