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

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

View File

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

View File

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

View File

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

View File

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