lex 2 年之前
父节点
当前提交
eb37dc1170

+ 20 - 6
src/student/trade/tradeOrder.ts

@@ -11,7 +11,11 @@ const apiSuffix =
 // VIDEO: '视频课',
 // VIP: '开通会员',
 // MUSIC: '单曲点播'
-export const formatOrderDetail = async (item: any, couponAmount?: number) => {
+interface IAmount {
+  couponAmount: number
+  discountPrice: number
+}
+export const formatOrderDetail = async (item: any, amount?: IAmount) => {
   const type = item.goodType
   let tempList: any = {}
 
@@ -89,8 +93,14 @@ export const formatOrderDetail = async (item: any, couponAmount?: number) => {
             id: item.id,
             title: memberType[res.period] || '',
             // 判断是否有优惠金额
-            price: couponAmount
-              ? Number((res.salePrice - couponAmount).toFixed(2))
+            price: amount?.couponAmount
+              ? Number(
+                  (
+                    res.salePrice -
+                    amount.couponAmount +
+                    amount.discountPrice
+                  ).toFixed(2)
+                )
               : res.salePrice || item.actualPrice,
             startTime: dayjs(res.startTime).format('YYYY-MM-DD'),
             endTime: dayjs(res.endTime).format('YYYY-MM-DD')
@@ -208,18 +218,22 @@ export const tradeOrder = (result: any, callBack?: any) => {
     orderName,
     orderType,
     orderDetailList,
-    couponAmount // 优惠金额
+    couponAmount, // 优惠金额
+    discountPrice
   } = result
   orderStatus.orderObject.orderType = orderType
   orderStatus.orderObject.orderName = orderName
   orderStatus.orderObject.orderDesc = orderDesc
   orderStatus.orderObject.actualPrice = actualPrice
   orderStatus.orderObject.orderNo = orderNo
-  // orderStatus.orderObject.actualPrice = actualPrice
+  orderStatus.orderObject.discountPrice = discountPrice
   orderStatus.orderObject.orderList = []
   try {
     orderDetailList.forEach(async (item: any) => {
-      await formatOrderDetail(item, couponAmount)
+      await formatOrderDetail(item, {
+        couponAmount,
+        discountPrice
+      })
     })
     callBack && callBack()
   } catch {

+ 1 - 0
src/views/order-detail/index.tsx

@@ -224,6 +224,7 @@ export default defineComponent({
 
             {/* 优惠券使用 */}
             <UseCoupon
+              discountPrice={orderStatus.orderObject.discountPrice}
               orderType={this.orderType}
               orderAmount={this.orderAmount}
               onCouponSelect={this.onCouponSelect}

+ 2 - 1
src/views/order-detail/orderStatus.ts

@@ -33,7 +33,8 @@ const original = () => {
       recomUserId: null as any, // 推荐人编号
       orderList: [] as Array<any>, // 商品信息
       activityId: '' as any, // 活动编号
-      couponId: '' as string // 优惠券编号
+      couponId: '' as string, // 优惠券编号
+      discountPrice: 0 as number // 优惠
     }
     // orderObject: {
     //   orderNo: '',

+ 17 - 5
src/views/order-detail/use-coupons/index.tsx

@@ -33,6 +33,11 @@ export default defineComponent({
     orderType: {
       type: String,
       default: ''
+    },
+    discountPrice: {
+      // 优惠券使用金额
+      type: Number,
+      default: 0
     }
   },
   emits: ['couponSelect'],
@@ -50,11 +55,18 @@ export default defineComponent({
       const limitCount = this.useCouponList.map((list: any) => {
         return Number(list.discountPrice || 0)
       })
-      return limitCount.length > 0
-        ? limitCount.reduce((sum: any, list: any) => {
-            return sum + list
-          })
-        : 0
+      let count = 0
+      if (this.disabled) {
+        count = this.discountPrice
+      } else {
+        count =
+          limitCount.length > 0
+            ? limitCount.reduce((sum: any, list: any) => {
+                return sum + list
+              })
+            : 0
+      }
+      return count
     },
     couponCategory() {
       // 如果订单类型不在优惠券类型里面,则默认查询通用券