Browse Source

更新优惠券用超出问题

lex 2 years ago
parent
commit
b47832a662
1 changed files with 22 additions and 7 deletions
  1. 22 7
      src/views/cart/cart-confirm/index.tsx

+ 22 - 7
src/views/cart/cart-confirm/index.tsx

@@ -124,11 +124,14 @@ 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: orderInfo.couponId
       }
       try {
@@ -200,11 +203,15 @@ export default defineComponent({
                     <UseCoupons
                       orderType="GOODS"
                       orderAmount={cartConfirm.calcAmount.totalAmount}
-                      onCouponSelect={(coupon) => {
-                        const discountPrice = coupon.map(n => n.discountPrice).reduce((total,n) => {
-                          return total + n
-                        },0)
-                        const couponId = coupon.map(n => n.couponIssueId).join(',')
+                      onCouponSelect={coupon => {
+                        const discountPrice = coupon
+                          .map(n => n.discountPrice)
+                          .reduce((total, n) => {
+                            return total + n
+                          }, 0)
+                        const couponId = coupon
+                          .map(n => n.couponIssueId)
+                          .join(',')
                         cartConfirm.calcAmount.promotionAmount = discountPrice
                         orderInfo.couponId = couponId
                       }}
@@ -239,7 +246,15 @@ export default defineComponent({
                     <div class={styles.confirmBottom}>
                       合计{' '}
                       <span class={styles['price-des']}>
-                        ¥{moneyFormat(cartConfirm.calcAmount.payAmount - cartConfirm.calcAmount.promotionAmount)}
+                        ¥
+                        {moneyFormat(
+                          cartConfirm.calcAmount.payAmount -
+                            cartConfirm.calcAmount.promotionAmount >=
+                            0
+                            ? cartConfirm.calcAmount.payAmount -
+                                cartConfirm.calcAmount.promotionAmount
+                            : 0
+                        )}
                       </span>
                     </div>
                   </SubmitBar>