From 28950f0ad140ae2eed86bf00c7e17a8a8b057858 Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Sat, 23 Nov 2024 10:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=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 | 11 ++- pagesOrder/components/orderInfoAfter.vue | 84 +++++++++++++++++++---- pagesOrder/components/orderInfoBefore.vue | 6 +- pagesOrder/confirm_order/index.vue | 19 ++--- pagesOrder/order_detail/index.vue | 68 ++++++++++++++---- 5 files changed, 146 insertions(+), 42 deletions(-) diff --git a/pages/user/coupon.vue b/pages/user/coupon.vue index eb69234..b7c4ccb 100644 --- a/pages/user/coupon.vue +++ b/pages/user/coupon.vue @@ -235,6 +235,7 @@ } let isNum = 0; let isProductItem; + // 确认订单 if ( this.type == 'confirm_order_product' ) { product.forEach(item => { @@ -245,6 +246,7 @@ } } }) + if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.salePrice)) { uni.showToast({ title: `当前金额不足商品抵扣`, @@ -264,6 +266,7 @@ } } }) + if ( this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem.price)) { uni.showToast({ title: `当前金额不足商品抵扣`, @@ -273,7 +276,13 @@ } } - + if ( !isProductItem ) { + uni.showToast({ + title: `当前订单无可抵扣商品`, + icon: "none", + }) + return; + } // let productNum = 0; // product.map(item => { // productNum += item.number diff --git a/pagesOrder/components/orderInfoAfter.vue b/pagesOrder/components/orderInfoAfter.vue index e04d87d..2210777 100644 --- a/pagesOrder/components/orderInfoAfter.vue +++ b/pagesOrder/components/orderInfoAfter.vue @@ -234,6 +234,57 @@ this.payAmount = this.listinfo.payAmount; uni.cache.set('selectCouponData',[]) this.isShow = true; + console.log(this.listinfo.orderInfo.couponInfoList) + if ( this.listinfo.orderInfo.couponInfoList ) { + if ( this.listinfo.orderInfo.couponInfoList.fullReductionCoupon.length > 0) { + let couponData = this.listinfo.orderInfo.couponInfoList.fullReductionCoupon[0] + this.favorable[0].value = '-¥'+couponData.discountAmount + this.payAmount = this.payAmount + couponData.discountAmount + this.userCouponInfos.push({ + userCouponId: couponData.id, + type: couponData.type, + discountAmount: couponData.discountAmount, + num: couponData.num, + }) + let selectCouponData = uni.cache.get('selectCouponData') || []; + selectCouponData.push(couponData) + uni.cache.set('selectCouponData',selectCouponData) + } + if ( this.listinfo.orderInfo.couponInfoList.productCoupon.length > 0) { + this.listinfo.orderInfo.couponInfoList.productCoupon.map(item=>{ + this.userCouponInfos.push({ + userCouponId: item.id, + type: item.type, + productId: item.proId, + discountAmount: item.finalDiscountAmount, + num: item.finalUseNum, + }) + this.favorable[1].value.push({ + userCouponId: item.id, + name: item.name, + type: item.type, + productId: item.proId, + discountAmount: item.finalDiscountAmount, + num: item.finalUseNum, + }) + this.payAmount = this.payAmount + item.finalDiscountAmount + let selectCouponData = uni.cache.get('selectCouponData') || []; + selectCouponData.push(item) + uni.cache.set('selectCouponData',selectCouponData) + }) + + } + } + if ( this.listinfo.orderInfo.pointsDiscountAmount ) { + this.payAmount = this.payAmount + this.listinfo.orderInfo.pointsDiscountAmount + this.isPointsChecked = true; + } + this.$emit("setPayAmount",{ + payAmount: this.listinfo.payAmount, + userCouponInfos: this.userCouponInfos, + freeCheck: this.freeCheck, + isPointsChecked: this.isPointsChecked, + }) }, methods: { childOnShow() { @@ -248,6 +299,8 @@ this.listinfo.payAmount = this.payAmount this.selectCouponData = uni.cache.get('selectCouponData') || [] this.changeCoupon(); + + }, /** * 监听优惠券/商品券选择 @@ -259,7 +312,6 @@ let couponList = this.selectCouponData.filter(v => v.type == 1); // 商品券列表 let productList = this.selectCouponData.filter(v => v.type == 2); - // 优惠券处理 if ( couponList.length > 0 ) { let couponData = couponList[0] @@ -302,22 +354,24 @@ if ( productList.length > 0 ) { //商品券使用数量 - // 商品数量 - let productAllNum = 0; productList.map((item,index)=>{ // 筛选选中商品券商品列表 let productDetails = this.listinfo.details.filter(v => v.productId == item.proId); //金额从小到大排序 let minCouponList = productDetails.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice)) - let productNum = 0; - let productPayAmount = 0; - let productDetailsNum = 0; - productDetails.map((v,indexs) => { - productDetailsNum += v.num; - }) - + // 商品数量 + let productAllNum = 0; + let productNum = 0 + let productPayAmount = 0 minCouponList.map((v,indexs) => { + productNum = 0; + productPayAmount = 0; + let productDetailsNum = 0; + productDetails.map((v,indexs) => { + productDetailsNum += v.num; + }) + console.log(minCouponList) for (let i = 0; i < v.num; i++){ if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.price) <= (this.listinfo.payAmount - productPayAmount) )) { productNum++ @@ -357,7 +411,6 @@ let tableFee; // this.storeInfo.registerType == 'munchies' - if ( this.userCouponInfos.length > 0 ) { console.log(this.userCouponInfos) this.userCouponInfos.forEach(item => { @@ -368,8 +421,6 @@ } }) } - - this.isPointsChecked = false; this.getCalcUsablePoints() this.$emit("setPayAmount",{ @@ -393,7 +444,6 @@ } else { this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); } - console.log(this.listinfo.payAmount) this.$emit("setPayAmount",{ payAmount: this.listinfo.payAmount, userCouponInfos: this.userCouponInfos, @@ -444,7 +494,11 @@ async getCalcUsablePoints() { let params = { memberId: this.listinfo.orderInfo.memberId, - orderAmount: this.listinfo.payAmount, + } + if ( this.listinfo.orderInfo.pointsDiscountAmount ) { + params.orderAmount = this.listinfo.payAmount + this.listinfo.orderInfo.pointsDiscountAmount + } else { + params.orderAmount = this.listinfo.payAmount } let res = await this.api.calcUsablePoints(params) this.calcUsablePointsData = res.data; diff --git a/pagesOrder/components/orderInfoBefore.vue b/pagesOrder/components/orderInfoBefore.vue index b456ddc..7f09836 100644 --- a/pagesOrder/components/orderInfoBefore.vue +++ b/pagesOrder/components/orderInfoBefore.vue @@ -91,8 +91,8 @@ {{listinfo.orderInfo.seatAmount}} - - + + 优惠券 @@ -101,7 +101,7 @@ - + 商品券 diff --git a/pagesOrder/confirm_order/index.vue b/pagesOrder/confirm_order/index.vue index a5438ee..5db2307 100644 --- a/pagesOrder/confirm_order/index.vue +++ b/pagesOrder/confirm_order/index.vue @@ -362,26 +362,27 @@ if ( productList.length > 0 ) { //商品券使用数量 - // 商品数量 - let productAllNum = 0; + productList.map((item,index)=>{ // 筛选选中商品券商品列表 let productDetails = this.listinfo.details.filter(v => v.productId == item.proId); //金额从小到大排序 let minCouponList = productDetails.sort((a, b) => (a.memberPrice > 0 ? a.memberPrice : a.salePrice) - (b.memberPrice > 0 ? b.memberPrice : b.salePrice)) + // 商品数量 + let productAllNum = 0; let productNum = 0; let productPayAmount = 0; - let productDetailsNum = 0; - productDetails.map((v,indexs) => { - productDetailsNum += v.number; - }) + minCouponList.map((v,indexs) => { + productNum = 0; + productPayAmount = 0; + let productDetailsNum = 0; + productDetails.map((v,indexs) => { + productDetailsNum += v.number; + }) for (let i = 0; i < v.number; i++){ - if ( ((v.memberPrice > 0 ? v.memberPrice : v.salePrice) < (this.listinfo.payAmount - productPayAmount) ) ){ - - } if ( productAllNum < productDetailsNum && productNum < item.num && ((v.memberPrice > 0 ? v.memberPrice : v.salePrice) <= (this.listinfo.payAmount - productPayAmount) )) { productNum++ productAllNum++ diff --git a/pagesOrder/order_detail/index.vue b/pagesOrder/order_detail/index.vue index ae47926..93960e0 100644 --- a/pagesOrder/order_detail/index.vue +++ b/pagesOrder/order_detail/index.vue @@ -31,13 +31,25 @@ - + + + + + + + @@ -55,10 +67,10 @@ - + - + 请输入支付密码 @@ -102,7 +114,8 @@ freeDisabled: false, freeCheck: false, rechargeFreeChecked: false, - srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg' + srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg', + }; }, onLoad(e) { @@ -114,8 +127,8 @@ this.$nextTick(()=>{ this.$refs.orderInfoAfterRef.childOnShow(); }) + } - }, onUnload() { this.ispws = false @@ -132,7 +145,7 @@ methods: { setPayAmount(data) { - // this.changeFree(this.freeDisabled) + console.log(data) this.listinfo.payAmount = data.payAmount this.couopnInfo = data; this.freeDisabled = data.freeDisabled @@ -142,6 +155,7 @@ } else { this.freeDisabled = false } + }, /** * 免单状态监听 @@ -251,7 +265,17 @@ this.getAount(); } - + let params = { + userId: uni.cache.get('userInfo').id, + status: 1, + orderId: -1, + shopId: this.shopId + } + console.log("params",params) + let ress = await this.api.conponList(params) + if (ress.code == 0) { + let list = ress.data; + } }, /** @@ -310,13 +334,29 @@ } }, + /** + * 取消支付 + */ + payClose () { + this.ispws = false; + console.log(2) + uni.showToast({ + icon: 'none', + title: '取消支付' + }) + setTimeout(res => { + uni.switchTab({ + url: '/pages/order/order' + }); + }, 500) + }, + /** * 余额支付 * @param {Object} pwd */ async accountPayevent(pwd) { this.ispws = false; - console.log(pwd) let res = await this.api.accountPay({ orderId: this.listinfoid, memberId: this.amountVIP.id,