From 4d62d1bd04ec664c76fd4436a26e3c0a430d1c24 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Fri, 8 May 2026 10:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=82=A8=E5=80=BC=E5=8D=A1?= =?UTF-8?q?=E6=B6=88=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundle/reserve/confirm.vue | 253 ++++++++++++++++++++++++++++++-- pages/order/cg-order-detail.vue | 213 +++++++++++++++++++++++---- 2 files changed, 426 insertions(+), 40 deletions(-) diff --git a/bundle/reserve/confirm.vue b/bundle/reserve/confirm.vue index a5b48b6..cb0cec8 100644 --- a/bundle/reserve/confirm.vue +++ b/bundle/reserve/confirm.vue @@ -189,6 +189,37 @@ + + + + + + + + 储值卡选择 + + + + + + {{ item.name }} + + + + {{ item.discount }} + + + + + + ¥{{ formatMoney(item.balance) }} + + + + 确定 + + + @@ -296,19 +327,33 @@ - + 平台余额 - + {{ cardType() }} {{ userDiscount }} + + + + + + 储值卡支付 + + + + {{ storedCardName() }} {{ userDiscount }}折 + + + + @@ -377,11 +422,15 @@ loadding: true, _submitting: false, balancePopup: false, + storedCardPopup: false, balance: {}, userBalance: {}, currentType: '', // 选择的会员卡类型 + storedCardList: [], + currentStoredCardId: '', userAccount: 0, - userDiscount: 0 + userDiscount: 0, + storedValueCard: [] }; }, @@ -402,7 +451,7 @@ this.typeId = args.typeId || 1; // 网球场1 篮球场2 // this.basketballDate = args.date || null; // 篮球场预约时间 this.getData(); - this.getRecharge() + this.getRecharge(); }, onUnload() { @@ -604,17 +653,17 @@ payTypeFunc(n) { this.payType = n; if (n == 'balance') { + this.resetPayDiscount(); this.balancePopup = true; - } else { - // 切换到微信支付时还原价格 - this.userAccount = 0; - this.userDiscount = 0; - this.currentType = ''; - if (typeof this.originalTotal === 'number' && !isNaN(this.originalTotal)) { - this.bill.total = this.originalTotal; - this.bill.dis = 0; - } + this.storedCardPopup = false; + } else if (n == 'storedCard') { + this.resetPayDiscount(); this.balancePopup = false; + this.storedCardPopup = true; + } else { + this.resetPayDiscount(); + this.balancePopup = false; + this.storedCardPopup = false; } }, @@ -656,6 +705,19 @@ }; oldBalancePay.call(this); setTimeout(finish, 3000); + } else if (this.payType == 'storedCard') { + if (this.currentStoredCardId === '') { + uni.showToast({title: '请选择储值卡', icon: 'none'}); + setTimeout(finish, 3000); + return; + } + const oldStoredCardPay = this.storedCardPay; + this.storedCardPay = (...args) => { + oldStoredCardPay.apply(this, args); + this.storedCardPay = oldStoredCardPay; + }; + oldStoredCardPay.call(this); + setTimeout(finish, 3000); } else { finish(); } @@ -814,6 +876,7 @@ }, function(res) { self.balance = res.data.lists.balance; + self.storedValueCard = res.data.lists.storedValueCard; } ) @@ -823,11 +886,43 @@ }, function(res) { console.log("🚀 ~ res:", res) self.userBalance = res.data.userInfo; + + self.storedCardList = [ + { id: 1, payType: 1, name: '储值卡一', discount: self.storedValueCard.discount1, balance: self.userBalance.card_balance1 }, + { id: 2, payType: 2, name: '储值卡二', discount: self.storedValueCard.discount2, balance: self.userBalance.card_balance2 }, + { id: 3, payType: 3, name: '储值卡三', discount: self.storedValueCard.discount3, balance: self.userBalance.card_balance3 }, + ]; + self.loadding = false; uni.hideLoading(); }); }, + formatMoney(value) { + const amount = Number(value) || 0; + return amount.toFixed(2); + }, + + getStoredCardInfo() { + return this.storedCardList.find(item => item.id === this.currentStoredCardId); + }, + + storedCardName() { + const currentCard = this.getStoredCardInfo(); + return currentCard ? currentCard.name : ''; + }, + + resetPayDiscount() { + this.userAccount = 0; + this.userDiscount = 0; + this.currentType = ''; + this.currentStoredCardId = ''; + if (typeof this.originalTotal === 'number' && !isNaN(this.originalTotal)) { + this.bill.total = this.originalTotal; + this.bill.dis = 0; + } + }, + cardType() { if (this.currentType == 1) { return '白银会员卡' @@ -878,12 +973,144 @@ this.balancePopup = false; }, + confirmStoredCard() { + if (this.currentStoredCardId === '') { + uni.showToast({ + title: '请选择储值卡', + icon: 'none' + }); + return; + } + + const currentCard = this.getStoredCardInfo(); + if (!currentCard) { + uni.showToast({ + title: '储值卡不存在', + icon: 'none' + }); + return; + } + + this.userAccount = Number(currentCard.balance); + this.userDiscount = Number(currentCard.discount) || 10; + + const baseTotal = Number(this.bill.cdf.total) || 0; + const finalPrice = Number((baseTotal * (this.userDiscount / 10)).toFixed(2)); + const payableTotal = Number((finalPrice + Number(this.bill.dgf.total)).toFixed(2)); + + if (this.userAccount < payableTotal) { + uni.showToast({ + title: '储值卡余额不足,请选择其他储值卡', + icon: 'none' + }); + return; + } + + this.bill.dis = Number((baseTotal - finalPrice).toFixed(2)); + this.bill.total = payableTotal; + this.storedCardPopup = false; + }, + + storedCardPay() { + let self = this + const currentCard = self.getStoredCardInfo(); + if (!currentCard) { + uni.showToast({ + title: '请选择储值卡', + icon: 'none' + }); + return; + } + + if (Number(currentCard.balance) < Number(self.bill.total)) { + uni.showToast({ + title: '储值卡余额不足', + icon: 'none' + }); + return; + } + + uni.showLoading({ + title: '支付中' + }); + + try { + self._post( + 'ground.ground/yuexnPay', + { + app_id: self.getAppId(), + order_id: self.orderId, + pay_type: currentCard.payType // 传储值卡对应的pay_type + }, + function(res) { + if (res.code == 1) { + self.result = 'success' + uni.showToast({ + title: '支付成功', + icon: 'none' + }); + self.loadding = false; + + setTimeout(() => { + uni.navigateBack({delta: 1}) + }, 500); + } else { + self.result = 'fail' + self.loadding = false; + + uni.showToast({ + title: '支付失败', + icon: 'none' + }); + setTimeout(() => { + uni.navigateBack({delta: 1}) + }, 500); + } + } + ) + } catch (error) { + self.result = 'fail' + self.loadding = false; + + uni.showToast({ + title: '支付失败', + icon: 'none' + }); + setTimeout(() => { + uni.navigateBack({delta: 1}) + }, 500); + } + + // setTimeout(() => { + // currentCard.balance = Number((Number(currentCard.balance) - Number(this.bill.total)).toFixed(2)); + // this.userAccount = currentCard.balance; + // this.result = 'success'; + // this.loadding = false; + // uni.hideLoading(); + // uni.showToast({ + // title: '储值卡支付成功', + // icon: 'none' + // }); + + // setTimeout(() => { + // uni.navigateBack({delta: 1}); + // }, 500); + // }, 300); + }, + // 关闭余额支付弹窗 closeBalancePopup() { + this.resetPayDiscount(); this.payType = 'wxpay'; this.balancePopup = false; }, + + closeStoredCardPopup() { + this.resetPayDiscount(); + this.payType = 'wxpay'; + this.storedCardPopup = false; + }, }, }; diff --git a/pages/order/cg-order-detail.vue b/pages/order/cg-order-detail.vue index 9251c9c..369e060 100644 --- a/pages/order/cg-order-detail.vue +++ b/pages/order/cg-order-detail.vue @@ -138,19 +138,32 @@ - + 平台余额 - - - {{ cardType() }} + + {{ cardType() }} + + + + + + 储值卡支付 + + + + {{ storedCardName() }} + + + + 确定并支付 @@ -200,12 +213,12 @@ 复制 - 交易方式: - 余额支付-{{ cardType(detail.pay_way) }} + 余额支付-{{ cardType(detail.pay_type) }} 微信支付 + 储值卡支付-{{ storedCardType(detail.pay_xntype) }} @@ -396,6 +409,30 @@ + + + + + + + + 储值卡选择 + + + + + + {{ item.name }} + + + ¥{{ formatMoney(item.balance) }} + + + + 确定 + + + @@ -448,6 +485,10 @@ currentType: '', // 选择的会员卡类型 userAccount: 0, userDiscount: 0, + storedCardPopup: false, + storedCardList: [], + currentStoredCardId: '', + storedValueCard: [], lightDateTime: '', lightPrice: 0, }; @@ -670,19 +711,31 @@ // 会员卡类型 cardType(type) { - if (type == 1) { + const t = type || this.currentType; + if (t == 1) { return '白银会员卡' - } else if (type == 2) { + } else if (t == 2) { return '黄金会员卡' - } else if (type == 3) { + } else if (t == 3) { return '铂金会员卡' - } else if (type == 4) { + } else if (t == 4) { return '钻石会员卡' - } else if (type == 5) { + } else if (t == 5) { return '至尊会员卡' } }, + // 储值卡类型 + storedCardType(type) { + if (type == 1) { + return '储值卡一' + } else if (type == 2) { + return '储值卡二' + } else if (type == 3) { + return '储值卡三' + } + }, + /** * 购买灯光前置条件 */ @@ -708,13 +761,25 @@ payTypeFunc(n) { this.payType = n; if (n == 'balance') { + this.userAccount = 0; + this.userDiscount = 0; + this.currentStoredCardId = ''; this.balancePopup = true; + this.storedCardPopup = false; + } else if (n == 'storedCard') { + this.userAccount = 0; + this.userDiscount = 0; + this.currentType = ''; + this.balancePopup = false; + this.storedCardPopup = true; } else { // 切换到微信支付时还原价格 this.userAccount = 0; this.userDiscount = 0; this.currentType = ''; + this.currentStoredCardId = ''; this.balancePopup = false; + this.storedCardPopup = false; } }, @@ -724,6 +789,49 @@ this.balancePopup = false; }, + closeStoredCardPopup() { + this.payType = 'wxpay'; + this.storedCardPopup = false; + }, + + formatMoney(value) { + const amount = Number(value) || 0; + return amount.toFixed(2); + }, + + getStoredCardInfo() { + return this.storedCardList.find(item => item.id === this.currentStoredCardId); + }, + + storedCardName() { + const currentCard = this.getStoredCardInfo(); + return currentCard ? currentCard.name : ''; + }, + + confirmStoredCard() { + if (this.currentStoredCardId === '') { + uni.showToast({ + title: '请选择储值卡', + icon: 'none' + }); + return; + } + + const currentCard = this.getStoredCardInfo(); + if (!currentCard) { + uni.showToast({ + title: '储值卡不存在', + icon: 'none' + }); + return; + } + + this.userAccount = Number(currentCard.balance); + this.userDiscount = 0; + + this.storedCardPopup = false; + }, + getRecharge() { let self = this; uni.showLoading({ @@ -737,6 +845,7 @@ }, function(res) { self.balance = res.data.lists.balance; + self.storedValueCard = res.data.lists.storedValueCard; } ) @@ -746,6 +855,13 @@ }, function(res) { console.log("🚀 ~ res:", res) self.userBalance = res.data.userInfo; + + self.storedCardList = [ + { id: 1, payType: 1, name: '储值卡一', discount: self.storedValueCard.discount1, balance: self.userBalance.card_balance1 }, + { id: 2, payType: 2, name: '储值卡二', discount: self.storedValueCard.discount2, balance: self.userBalance.card_balance2 }, + { id: 3, payType: 3, name: '储值卡三', discount: self.storedValueCard.discount3, balance: self.userBalance.card_balance3 }, + ]; + self.loadding = false; uni.hideLoading(); }); @@ -771,27 +887,13 @@ this.userAccount = this.userBalance['balance' + this.currentType]; - this.userDiscount = this.balance['discount' + this.currentType]; + this.userDiscount = 0; // this.payType = this.currentType; // this.countPrice(); this.balancePopup = false; }, - cardType() { - if (this.currentType == 1) { - return '白银会员卡' - } else if (this.currentType == 2) { - return '黄金会员卡' - } else if (this.currentType == 3) { - return '铂金会员卡' - } else if (this.currentType == 4) { - return '钻石会员卡' - } else if (this.currentType == 5) { - return '至尊会员卡' - } - }, - isSelected(groupIdx, idx) { return this.selectedTimes.some(sel => sel.group === groupIdx && sel.idx === idx); }, @@ -932,9 +1034,18 @@ return; } + if (self.payType == 'storedCard' && self.currentStoredCardId === '') { + uni.showToast({ + title: '请选择储值卡', + icon: 'none' + }); + return; + } + uni.showLoading({ title: '正在处理' - }); + }); + console.log('self.payType=', self.payType) console.log(123123) self._post( 'order.GroundOrder/addLightStoreOrder', { @@ -1034,6 +1145,54 @@ self.getRecharge(); }, 1500); + } else { + self.openLightPopup = false; + + console.log("🚀 ~ pay error res:", res) + self.result = 'fail' + uni.hideLoading(); + setTimeout(() => { + uni.showToast({ + title: '支付失败', + icon: 'none' + }); + }, 200); + + setTimeout(() => { + self.getData(); + self.getRecharge(); + }, 1500); + } + } + ) + } else if (self.payType == 'storedCard') { + const currentCard = self.getStoredCardInfo(); + console.log("🚀 ~ getStoredCardInfo:", 12312312321) + self._post( + 'ground.ground/yuexnLightPay', { + order_id: payId, + pay_type: currentCard.payType + }, + function(pay) { + if (pay.code == 1) { + self.openLightPopup = false; + self.selectedTimes = [] + self.content = [] + + self.result = 'success' + uni.hideLoading(); + setTimeout(() => { + uni.showToast({ + title: '支付成功', + icon: 'none' + }); + }, 200); + + setTimeout(() => { + self.getData(); + self.getRecharge(); + }, 1500); + } else { self.openLightPopup = false;