lex 2 years ago
parent
commit
d3f700747c

+ 10 - 2
src/views/order-detail/index.tsx

@@ -35,7 +35,7 @@ export default defineComponent({
     const query = this.$route.query
     return {
       loading: false, // 是否加载中,为了处理0元订单()
-      orderType: query.orderType,
+      orderType: query.orderType as string,
       recomUserId: query.recomUserId, // 推荐人id
       activityId: query.activityId, // 活动编号
       id: query.id,
@@ -139,9 +139,10 @@ export default defineComponent({
             orderName: orderObject.orderName,
             orderDesc: orderObject.orderDesc,
             orderType: orderObject.orderType,
-            actualPrice: orderObject.actualPrice || 0,
+            actualPrice: this.orderPrice || 0,
             recomUserId: orderObject.recomUserId,
             activityId: orderObject.activityId,
+            couponId: orderObject.couponId,
             orderInfos: [...orderInfos()]
           }
         })
@@ -188,6 +189,12 @@ export default defineComponent({
         (Number(this.orderAmount) - Number(discountCount)).toFixed(2)
       )
       this.orderPrice = lastAmount >= 0 ? lastAmount : 0
+
+      // 设置优惠券编号
+      const couponIds = (item || []).map((item: any) => {
+        return item.couponIssueId
+      })
+      orderStatus.orderObject.couponId = couponIds.join(',') || ''
     }
   },
   render() {
@@ -217,6 +224,7 @@ export default defineComponent({
 
             {/* 优惠券使用 */}
             <UseCoupon
+              orderType={this.orderType}
               orderAmount={this.orderAmount}
               onCouponSelect={this.onCouponSelect}
               disabled={orderStatus.orderObject.orderNo ? true : false}

+ 4 - 3
src/views/order-detail/orderStatus.ts

@@ -30,9 +30,10 @@ const original = () => {
       orderName: '',
       orderDesc: '',
       orderType: '' as orderType,
-      recomUserId: null as any,
-      orderList: [] as Array<any>,
-      activityId: '' as any
+      recomUserId: null as any, // 推荐人编号
+      orderList: [] as Array<any>, // 商品信息
+      activityId: '' as any, // 活动编号
+      couponId: '' as string // 优惠券编号
     }
     // orderObject: {
     //   orderNo: '',

+ 6 - 0
src/views/order-detail/use-coupons/choice-coupon.tsx

@@ -16,6 +16,10 @@ export default defineComponent({
     useCoupon: {
       type: Array,
       default: () => []
+    },
+    couponCategory: {
+      type: String,
+      default: 'UNIVERSAL'
     }
   },
   emits: ['close', 'submit'],
@@ -42,6 +46,8 @@ export default defineComponent({
       try {
         const res = await request.post(`${state.platformApi}/couponInfo/page`, {
           data: {
+            couponCategory: this.couponCategory,
+            couponType: 'FULL_DISCOUNT',
             useState: 'USABLE',
             page: 1,
             rows: 100

+ 23 - 0
src/views/order-detail/use-coupons/index.tsx

@@ -5,6 +5,20 @@ import { defineComponent } from 'vue'
 import ChoiceCoupon from './choice-coupon'
 import styles from './index.module.less'
 
+/*
+ * 订单类型对应优惠券类型
+ */
+export const couponEnum = {
+  UNIVERSAL: 'UNIVERSAL',
+  VIP: 'VIP',
+  PIANO: 'PIANO',
+  GOODS: 'MALL',
+  MUSIC: 'MUSIC',
+  PRACTICE: 'SPARRING',
+  LIVE: 'LIVE',
+  VIDEO: 'VIDEO'
+}
+
 export default defineComponent({
   name: 'use-conpon',
   props: {
@@ -15,6 +29,10 @@ export default defineComponent({
     orderAmount: {
       type: Number,
       default: 0
+    },
+    orderType: {
+      type: String,
+      default: ''
     }
   },
   emits: ['couponSelect'],
@@ -37,6 +55,10 @@ export default defineComponent({
             return sum + list
           })
         : 0
+    },
+    couponCategory() {
+      // 如果订单类型不在优惠券类型里面,则默认查询通用券
+      return couponEnum[this.orderType] || 'UNIVERSAL'
     }
   },
   mounted() {
@@ -117,6 +139,7 @@ export default defineComponent({
           {/* 优化体验 */}
           {this.popupLoading && (
             <ChoiceCoupon
+              couponCategory={this.couponCategory}
               useCoupon={this.useCouponList}
               orderAmount={this.orderAmount}
               onClose={() => (this.popupStatus = false)}