Quellcode durchsuchen

Merge branch 'iteration-20241126'

lex-xin vor 8 Monaten
Ursprung
Commit
c75f57dc75
2 geänderte Dateien mit 40 neuen und 36 gelöschten Zeilen
  1. 14 11
      src/views/order-detail/index.tsx
  2. 26 25
      src/views/trade/trade-detail.tsx

+ 14 - 11
src/views/order-detail/index.tsx

@@ -175,7 +175,6 @@ export default defineComponent({
 
     this.orderAmount = orderStatus.orderObject.actualPrice || 0
     this.orderPrice = orderStatus.orderObject.actualPrice || 0
-    console.log(this.orderAmount, this.orderPrice, 'orderPrice')
 
     this.disabledCoupon = orderStatus.orderObject.orderNo ? true : false
     this.dataLoading = false
@@ -443,7 +442,6 @@ export default defineComponent({
       resestState()
     },
     onCouponSelect(item: any) {
-      console.log('onCouponSelect', item)
       let discountCount = 0
       ;(item || []).forEach((item: any) => {
         discountCount += Number(item.discountPrice)
@@ -631,12 +629,17 @@ export default defineComponent({
                     item.discountPrice
                   )
 
-                  this.orderGoodsType.forEach((item: any)=> {
-                    if(item.orderType !== 'DISCOUNT') {
-                      item.price = numberToTwoUp(item.price - Number(item.discountPrice))
+                  this.orderGoodsType.forEach((child: any)=> {
+                    if(child.orderType !== 'DISCOUNT') {
+                      child.price = numberToTwoUp(child.price - Number(item.discountPrice))
                     }
                   })
 
+                  // 更新优惠券列表
+                  const useCouponRef: any =  this.$refs.useCouponRef
+                  if(useCouponRef) {
+                    useCouponRef.resetCouponList()
+                  }
                   this.orderPrice = Number(
                     numberToTwoUp(
                       Number(this.orderAmount) -
@@ -666,9 +669,9 @@ export default defineComponent({
                     orderStatus.orderObject.discountCardPrice = Number(
                       item.discountPrice
                     )
-                    this.orderGoodsType.forEach((item: any)=> {
-                      if(item.orderType !== 'DISCOUNT') {
-                        item.price = numberToTwoUp(item.price - Number(item.discountPrice))
+                    this.orderGoodsType.forEach((child: any)=> {
+                      if(child.orderType !== 'DISCOUNT') {
+                        child.price = numberToTwoUp(child.price - Number(item.discountPrice))
                       }
                     })
                     if (index === -1) {
@@ -692,9 +695,9 @@ export default defineComponent({
                     if (index !== -1) {
                       this.selectGoods.splice(index, 1)
                       this.orderAmount = this.orderAmount - item.salePrice
-                      this.orderGoodsType.forEach((item: any)=> {
-                        if(item.orderType !== 'DISCOUNT') {
-                          item.price = item.basePrice
+                      this.orderGoodsType.forEach((child: any)=> {
+                        if(child.orderType !== 'DISCOUNT') {
+                          child.price = child.basePrice
                         }
                       })
                       const typeIndex = tempType.findIndex((child: any) => child.orderType === item.vipType)

+ 26 - 25
src/views/trade/trade-detail.tsx

@@ -59,22 +59,14 @@ export default defineComponent({
   },
   computed: {
     orderDetailList() {
-
       const result: any = this.result
       const orderDetailList = result.orderDetailList || []
-
       orderDetailList.forEach((item: any) => {
         let tempPrice = item?.expectPrice || item.actualPrice
         if (item?.couponAmount) {
-            tempPrice = Number(
-              (
-                (tempPrice - result.couponAmount) / item.goodNum
-              ).toFixed(2)
-            )
+          tempPrice = Number((tempPrice / item.goodNum).toFixed(2))
         } else {
-          tempPrice = Number(
-            tempPrice / item.goodNum
-            ).toFixed(2)
+          tempPrice = Number(tempPrice / item.goodNum).toFixed(2)
         }
 
         item.showPrice = tempPrice || 0
@@ -225,13 +217,15 @@ export default defineComponent({
                     ),
                     default: () => (
                       <div class={styles.content}>
-                        {item.giftFlag ? <span class={styles.price}>
-                          赠送
-                        </span>: <span class={styles.price}>
-                          ¥
-                          {(this as any).$filters.moneyFormat(item.showPrice)}
-                        </span>}
-                        
+                        {item.giftFlag ? (
+                          <span class={styles.price}>赠送</span>
+                        ) : (
+                          <span class={styles.price}>
+                            ¥
+                            {(this as any).$filters.moneyFormat(item.showPrice)}
+                          </span>
+                        )}
+
                         <span class={styles.num}>x{item.goodNum}</span>
                       </div>
                     )
@@ -239,14 +233,21 @@ export default defineComponent({
                 />
               ))}
 
-              {this.result.couponAmount > 0 && <Row class={styles.optionRow}>
-                <Col span="8" offset={1}>
-                  优惠金额:
-                </Col>
-                <Col span="14">¥{(this as any).$filters.moneyFormat(this.result.couponAmount)}</Col>
-                <Col span="1"> </Col>
-              </Row>}
-              
+              {this.result.couponAmount > 0 && (
+                <Row class={styles.optionRow}>
+                  <Col span="8" offset={1}>
+                    优惠金额:
+                  </Col>
+                  <Col span="14">
+                    ¥
+                    {(this as any).$filters.moneyFormat(
+                      this.result.couponAmount
+                    )}
+                  </Col>
+                  <Col span="1"> </Col>
+                </Row>
+              )}
+
               <Row class={styles.optionRow}>
                 <Col span="8" offset={1}>
                   订单号: