From 18aecb9f6c2551fc88372e063c62bed1c611e828 Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Mon, 25 Nov 2024 17:08:21 +0800 Subject: [PATCH] =?UTF-8?q?2.0.0=E4=BF=AE=E6=94=B9=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/coupon.vue | 31 +++++++++++++++++++++++- pagesOrder/components/orderInfoAfter.vue | 22 ++++++++++++++++- pagesOrder/order_detail/index.vue | 1 - 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/pages/user/coupon.vue b/pages/user/coupon.vue index 360c27f..9c8db2a 100644 --- a/pages/user/coupon.vue +++ b/pages/user/coupon.vue @@ -98,6 +98,8 @@ type: "", payAmount: 0, shopId: null, + orderId: null, + couopnInfo: null, shoppingCart: [], productList: [], @@ -108,6 +110,8 @@ if (options.type) { this.type = options.type } if (options.payAmount) { this.payAmount = options.payAmount } if (options.shopId) { this.shopId = options.shopId } + if (options.orderId) { this.orderId = options.orderId } + if (options.couopnInfo) { this.couopnInfo = JSON.parse(decodeURIComponent(options.couopnInfo)) } if (options.shoppingCart) { this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart)) } if (options.productList) { this.productList = JSON.parse(decodeURIComponent(options.productList)) } }, @@ -316,21 +320,46 @@ /** * 取消使用优惠券/商品券 */ - cancelCoupon () { + async cancelCoupon () { let selectCouponData = uni.cache.get('selectCouponData') if ( this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon' ) { let couponList = selectCouponData.filter(v => v.type == 1); let productList = selectCouponData.filter(v => v.type == 2); if ( couponList.length > 0 ) { uni.cache.set('selectCouponData',productList) + if ( this.couopnInfo ) { + let params = { + shopId: this.shopId, + orderId: this.orderId, + } + if ( this.couopnInfo.userCouponInfos.filter(v => v.type == 2).length > 0 ) { + params.userCouponInfos = this.couopnInfo.userCouponInfos.filter(v => v.type == 2) + } + if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) { + params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum; + } + let res = await this.api.useCoupon(params) + } } } else if ( this.type == 'confirm_order_product' || this.type == 'orderInfo_product' ) { let couponList = selectCouponData.filter(v => v.type == 1); let productList = selectCouponData.filter(v => v.type == 2); if ( productList.length > 0 ) { uni.cache.set('selectCouponData',couponList) + let params = { + shopId: this.shopId, + orderId: this.orderId, + } + if ( this.couopnInfo.userCouponInfos.filter(v => v.type == 1).length > 0 ) { + params.userCouponInfos = this.couopnInfo.userCouponInfos.filter(v => v.type == 1) + } + if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) { + params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum; + } + let res = await this.api.useCoupon(params) } } + uni.navigateBack(); }, } diff --git a/pagesOrder/components/orderInfoAfter.vue b/pagesOrder/components/orderInfoAfter.vue index ded971b..db975ff 100644 --- a/pagesOrder/components/orderInfoAfter.vue +++ b/pagesOrder/components/orderInfoAfter.vue @@ -462,6 +462,7 @@ }, goUrl(item){ if ( this.listinfo.status == 'unpaid' || this.listinfo.status == 'paying') { + let couopnInfo; switch (item.type){ case 'coupon': let payAmount = this.listinfo.payAmount; @@ -469,10 +470,19 @@ if ( couponList.length > 0 ) { payAmount = payAmount + couponList.discountAmount; } - + couopnInfo = { + payAmount: this.listinfo.payAmount, + userCouponInfos: this.userCouponInfos, + freeDisabled: this.freeDisabled, + freeCheck: this.freeCheck, + calcUsablePointsData: this.calcUsablePointsData, + isPointsChecked: this.isPointsChecked, + } uni.pro.navigateTo('/pages/user/coupon', { type: "orderInfo_coupon", shopId: this.listinfo.shopId, + orderId: this.listinfo.orderInfo.id, + couopnInfo: JSON.stringify(couopnInfo), payAmount: payAmount, shoppingCart: JSON.stringify(this.listinfo.details), productList: JSON.stringify(couponList) @@ -480,9 +490,19 @@ break; case 'product': let productList = this.userCouponInfos.filter(v => v.type == 2); + couopnInfo = { + payAmount: this.listinfo.payAmount, + userCouponInfos: this.userCouponInfos, + freeDisabled: this.freeDisabled, + freeCheck: this.freeCheck, + calcUsablePointsData: this.calcUsablePointsData, + isPointsChecked: this.isPointsChecked, + } uni.pro.navigateTo('/pages/user/coupon', { type: "orderInfo_product", shopId: this.listinfo.shopId, + orderId: this.listinfo.orderInfo.id, + couopnInfo: JSON.stringify(couopnInfo), payAmount: this.listinfo.payAmount, shoppingCart: JSON.stringify(this.listinfo.details), productList: JSON.stringify(productList) diff --git a/pagesOrder/order_detail/index.vue b/pagesOrder/order_detail/index.vue index 4451274..5dbd98b 100644 --- a/pagesOrder/order_detail/index.vue +++ b/pagesOrder/order_detail/index.vue @@ -303,7 +303,6 @@ orderId: this.listinfo.orderId, userCouponInfos: this.couopnInfo.userCouponInfos, } - console.log( this.couopnInfo ) if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) { params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum; }