diff --git a/src/store/modules/carts.ts b/src/store/modules/carts.ts index c0f0109..3ad23d7 100644 --- a/src/store/modules/carts.ts +++ b/src/store/modules/carts.ts @@ -231,9 +231,13 @@ export const useCartsStore = defineStore("carts", () => { return []; }); + const coupons = ref([]); + function setCoupons(cps: BackendCoupon[]) { + coupons.value = cps; + } // 优惠券列表 const backendCoupons = computed(() => { - return []; + return coupons.value; }); // 商品加入购物车顺序 @@ -759,7 +763,8 @@ export const useCartsStore = defineStore("carts", () => { clearMerchantReduction, seatFeeConfig, pointDeductionRule, - userPoints + userPoints, + setCoupons }; }); diff --git a/src/utils/goods-utils.js b/src/utils/goods-utils.js new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/goods.ts b/src/utils/goods.ts index 7170b42..72c0668 100644 --- a/src/utils/goods.ts +++ b/src/utils/goods.ts @@ -1164,6 +1164,7 @@ function getCouponStrategy(couponType: CouponType): CouponCalculationStrategy { } } + /** * 计算优惠券抵扣金额(处理互斥逻辑,选择最优优惠券,按商品ID排除,新增细分统计) * @param backendCoupons 后端优惠券列表 diff --git a/src/views/tool/Instead/components/order.vue b/src/views/tool/Instead/components/order.vue index 20e0505..99c64fe 100644 --- a/src/views/tool/Instead/components/order.vue +++ b/src/views/tool/Instead/components/order.vue @@ -110,12 +110,7 @@ @@ -274,34 +269,28 @@ let $goodsPayPriceMap = {}; const refCoupon = ref(); let quansSelArr = ref([]); function openCoupon() { - refCoupon.value.open(carts.goodsTotal, props.orderInfo); + //商品订单金额 + const price = new BigNumber(carts.orderCostSummary.goodsOriginalAmount) + .minus(carts.orderCostSummary.goodsDiscountAmount) + .toFixed(2); + refCoupon.value.open(price, props.orderInfo); } -//返回商品券抵扣金额 -function returnProDiscount(row) { - //相同商品抵扣券数组 - const arr = quansSelArr.value.filter((v) => v.type == 2 && v.proId == row.proId); - console.log(arr); - const index = arr.findIndex((v) => v.id == row.id); - const item = goodsArr.find((v) => v.productId == row.proId); - if (index != -1) { - const n = quanUtil.returnProductCoupAllPrice( - $goodsPayPriceMap[row.proId], - index, - row.num, - props.user.id && props.user.isVip - ); - return n.toFixed(2); - } else { - return 0; - } -} -function refCouponConfirm(e, goodsPayPriceMap, goodsList) { + +function refCouponConfirm(e, goodsList) { + e = e.map((v) => { + return { + ...v, + couponType: v.type, + title: v.name, + }; + }); goodsArr = goodsList; usePointsNumber.value = 0; pointsDiscountAmount.value = 0; score.sel = -1; + console.log("refCouponConfirm", e); quansSelArr.value = e; - $goodsPayPriceMap = goodsPayPriceMap; + carts.setCoupons(e); checkOrderPay.discountAmount = 0; checkOrderPay.discount = 0; score.sel = -1; diff --git a/src/views/tool/Instead/components/popup-coupon.vue b/src/views/tool/Instead/components/popup-coupon.vue index bb1b7f6..28f42d4 100644 --- a/src/views/tool/Instead/components/popup-coupon.vue +++ b/src/views/tool/Instead/components/popup-coupon.vue @@ -4,27 +4,22 @@
- + - +