浏览代码

更新优惠券计算问题

lex 2 年之前
父节点
当前提交
3de12a0e4e
共有 1 个文件被更改,包括 9 次插入10 次删除
  1. 9 10
      src/views/cart/cart-confirm/index.tsx

+ 9 - 10
src/views/cart/cart-confirm/index.tsx

@@ -141,14 +141,15 @@ export default defineComponent({
         },
         []
       )
+
+      const payAmount =
+        cartConfirm.calcAmount.payAmount -
+        cartConfirm.calcAmount.promotionAmount
       const body = {
         cartIds: ids,
         memberReceiveAddressId: address.value?.id,
         platformType: state.platformType,
-        orderAmount: (
-          cartConfirm.calcAmount.payAmount -
-          cartConfirm.calcAmount.promotionAmount
-        ).toFixed(2),
+        orderAmount: (payAmount >= 0 ? payAmount : 0).toFixed(2),
         couponId: cartUseAmount.value.couponId,
         useBalance: cartUseAmount.value.useBalance // 是否使用余额
       }
@@ -190,12 +191,10 @@ export default defineComponent({
     //   )
     // }
     const needPayPrice = () => {
-      let price = Number(
-        (
-          cartConfirm.calcAmount.payAmount -
-          cartConfirm.calcAmount.promotionAmount
-        ).toFixed(2)
-      )
+      const payAmount =
+        cartConfirm.calcAmount.payAmount -
+        cartConfirm.calcAmount.promotionAmount
+      let price = Number((payAmount >= 0 ? payAmount : 0).toFixed(2))
       console.log(price)
       if (cartUseAmount.value.useBalance) {
         price =