去除部分打印,显示价格组件修改

This commit is contained in:
2025-12-22 16:09:45 +08:00
parent 8b3228e359
commit 8bd5956340
5 changed files with 80 additions and 73 deletions

View File

@@ -1,75 +1,76 @@
<template>
<block v-if="limitDiscount && limitDiscount.id" class="limit-price">
<text>
{{ returnPrice() }}
</text>
</block>
<block v-if="limitDiscount && limitDiscount.id" class="limit-price">
<text>
{{ returnPrice() }}
</text>
</block>
<text v-else>
<block
v-if="
<text v-else>
<block v-if="
shopUserInfo.isMemberPrice == 1 &&
shopUserInfo.isVip == 1 &&
cart.memberPrice * 1 > 0
"
class="memberPrice"
>
<text>
{{ cart.memberPrice }}
</text>
</block>
">
<text class="memberPrice">
{{ cart.memberPrice }}
</text>
</block>
<text v-else class="salePrice">{{ cart.salePrice }}</text>
</text>
<text v-else class="salePrice">{{ cart.salePrice }}</text>
</text>
</template>
<script setup>
import BigNumber from "bignumber.js";
import * as orderUtils from "@/utils/order-utils.js";
import BigNumber from "bignumber.js";
import {
limitUtils
} from 'ysk-utils';
function returnPrice() {
return orderUtils.returnPrice({
goods: props.cart,
shopInfo: props.shopInfo,
limitTimeDiscountRes: props.limitDiscount,
shopUserInfo: props.shopUserInfo,
idKey: props.idKey,
});
}
const props = defineProps({
//购物车
cart: {
type: Object,
default: () => {},
},
idKey: {
type: String,
default: "id",
},
//限时折扣
limitDiscount: {
type: Object,
default: () => {},
},
//店铺用户信息
shopUserInfo: {
type: Object,
default: () => {},
},
//店铺信息
shopInfo: {
type: Object,
default: () => {},
},
});
const props = defineProps({
//购物车
cart: {
type: Object,
default: () => {},
},
idKey: {
type: String,
default: "id",
},
//限时折扣
limitDiscount: {
type: Object,
default: () => {},
},
//店铺用户信息
shopUserInfo: {
type: Object,
default: () => {},
},
//店铺信息
shopInfo: {
type: Object,
default: () => {},
},
});
function returnPrice() {
return limitUtils.returnPrice({
goods: props.cart,
shopInfo: props.shopInfo,
limitTimeDiscountRes: props.limitDiscount,
shopUserInfo: props.shopUserInfo,
idKey: props.idKey,
});
}
</script>
<style lang="scss">
.old-price {
color: #999;
font-size: 24rpx;
text-decoration: line-through;
margin-left: 8rpx;
}
<style lang="scss">
.old-price {
color: #999;
font-size: 24rpx;
text-decoration: line-through;
margin-left: 8rpx;
}
</style>

View File

@@ -145,7 +145,6 @@ onMounted(() => {
watch(
() => props.disablePayType,
(newval) => {
console.log('props.disablePayType', newval);
// 加兜底radiovalue 未初始化时不处理
if (Object.keys(radiovalue.value).length === 0) return;

View File

@@ -599,17 +599,18 @@ export function calcSingleGoodsRealPrice(
calcMemberPrice(goods, isMember, memberDiscountRate)
);
console.log('is_time_discount',goods)
if(goods.is_time_discount||goods.isTimeDiscount){
console.log('限时折扣',activity)
console.log('goods',goods)
//限时折扣优先
return truncateToTwoDecimals(
const limitPrice= truncateToTwoDecimals(
new BigNumber(goods.salePrice)
.times((activity?activity.discountRate:100) / 100)
.decimalPlaces(2, BigNumber.ROUND_UP)
.toNumber()
);
console.log('limitPrice',limitPrice)
return limitPrice;
}
// 3. 优先级3营销活动折扣如限时折扣需按商品ID匹配活动
let isActivityApplicable = false;
@@ -623,8 +624,7 @@ export function calcSingleGoodsRealPrice(
}
}
}
console.log('isActivityApplicable',isActivityApplicable)
console.log('activity',activity)
if (!activity || !isActivityApplicable) {
return memberPrice.toNumber();
}
@@ -644,12 +644,12 @@ export function calcSingleGoodsRealPrice(
// );
// }
if (activity&&activity.discountPriority == "vip-price" && isMember) {
if (activity.discountPriority == "vip-price" && isMember) {
return memberPrice.toNumber();
}
// 处理活动与会员的同享/不同享逻辑
if (activity&&activity.vipPriceShare) {
if (activity.vipPriceShare) {
// 同享:会员价基础上叠加工活动折扣
return truncateToTwoDecimals(
memberPrice.multipliedBy(activity.discountRate).toNumber()
@@ -716,6 +716,7 @@ export function calcGoodsRealAmount(
const availableNum = Math.max(0, goods.number - (goods.returnNum || 0));
if (availableNum <= 0) continue;
const realPrice = new BigNumber(calcSingleGoodsRealPrice(goods, config));
console.log('goods',goods);
console.log('realPrice',realPrice.toNumber());
total = total.plus(realPrice.multipliedBy(availableNum));
}

View File

@@ -41,6 +41,8 @@
:limitDiscount="cartStore.limitTimeDiscount"
></orderItemVue> -->
<orderItemVue :useVipPrice="useVipPrice" v-if="cartStore.allGoods.length" :nowCarts="cartStore.allGoods"
:shopInfo="cartStore.shopInfo"
:shopUserInfo="cartStore.shopUserInfo"
:limitDiscount="cartStore.limitTimeDiscount"></orderItemVue>

View File

@@ -2,6 +2,7 @@ import {
defineStore
} from "pinia";
// import yskUtils from 'ysk-utils'
import yskUtils from '@/lib/index'
// const {
// OrderPriceCalculator,
// BaseCartItem,
@@ -12,8 +13,6 @@ import {
// MerchantReductionType,
// GoodsType
// } = yskUtils
// import yskUtils from '@/lib/index'
import yskUtils from 'ysk-utils'
const {
OrderPriceCalculator
} = yskUtils
@@ -327,10 +326,15 @@ export const useCartsStore = defineStore("cart", () => {
if (!item) {
return null
}
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(v, limitTimeDiscount
console.log('v',v);
console.log('limitTimeDiscount',limitTimeDiscount.value);
console.log('shopInfo',shopInfo.value);
console.log('shopUserInfo',shopUserInfo.value);
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({...v,memberPrice:item.memberPrice}, limitTimeDiscount
.value,
shopInfo.value,
shopUserInfo.value, 'product_id');
console.log('is_time_discount',is_time_discount);
return {
...item,
is_time_discount: is_time_discount ? 1 : 0