diff --git a/package1/buyFood/buyFood.vue b/package1/buyFood/buyFood.vue index d902ee9..94bd53c 100644 --- a/package1/buyFood/buyFood.vue +++ b/package1/buyFood/buyFood.vue @@ -230,7 +230,7 @@ 支付剩余时间 59:09 - ¥449.96 + ¥{{totalAmountCalc.toFixed(2)}} 若拼团失败,将会为您自动退款 @@ -362,10 +362,14 @@ onShow() { this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.initAddress() - const now = new Date(); - now.setMinutes(now.getMinutes() + 30); - this.immediateTimeStr = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`; + const startTime = new Date(now); + const endTime = new Date(now); + startTime.setMinutes(startTime.getMinutes() + 20); + endTime.setMinutes(endTime.getMinutes() + 35); + const startStr = `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}`; + const endStr = `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}`; + this.immediateTimeStr = `${startStr}-${endStr}`; // Listen for selected delivery person event uni.$on('updateDeliveryWorker', (worker) => { @@ -411,7 +415,6 @@ return arr.join(','); }, submitPay(){ - this.$refs.payPopup.open('bottom'); if(this.isPaotui && !this.formData.address) { this.warnPopup = 'shdz'; this.$refs.warnPopup.open(); @@ -433,6 +436,79 @@ return; } + // Validation successful, open the payment popup + this.$refs.payPopup.open('bottom'); + }, + goDetail(){ + // Pass match conditions to worker list + let shopArea = this.shopItem.shopArea || ''; + let putArea = this.formData.address ? this.formData.address.areaId : ''; + uni.navigateTo({ + url:`/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}` + }) + }, + openAddressBook(){ + this.$refs.bookPopup.open('bottom') + + }, + checkTime(type){ + if (type === this.formData.isImmediately) { + if (type === false) { + this.$refs.model.open() + this.generateDeliveryTimes() + } + return; + } + this.formData.isImmediately = type; + if (this.formData.isImmediately === false) { + this.$refs.model.open() + this.generateDeliveryTimes() + } + }, + checkVoucher(type) { + if (type == this.selected) return; + this.selected = type; + if(this.selected == 'buzhiding'){ + this.formData.peisongyuan = ""; + this.assignedWorker = null; + } + }, + //微信支付测试 + wxPayment() { + let that = this; + let amountInCents = Math.round(this.totalAmountCalc * 100); + let payDesc = this.isGroupBuy ? '拼团订单' : '商城订单'; + + this.tui.request("/api/wechat/pay/unified-order", "POST", { + openid: uni.getStorageSync('miniProgramOpenid'), + amount: amountInCents, // 支付金额(分) + description: payDesc, + outTradeNo: 'ORDER_' + Date.now() + }, false, false).then((res) => { + if (res.code == 200) { + uni.requestPayment({ + provider: 'wxpay', + timeStamp: res.timeStamp, + nonceStr: res.nonceStr, + package: res.package, + signType: res.signType, + paySign: res.paySign, + success: function(res2) { + console.log('success:' + JSON.stringify(res2)); + that.$refs.payPopup.close(); + that.submitOrderToBackend(); + }, + fail: function(err) { + console.log('fail:' + JSON.stringify(err)); + that.tui.toast("支付失败或取消"); + } + }); + } else { + this.tui.toast(res.message) + } + }) + }, + submitOrderToBackend() { let items = []; if(this.isGroupBuy && this.groupItem) { items.push({ @@ -485,7 +561,7 @@ } uni.showLoading({ title: '提交中' }); - this.tui.request("/hiver/order/submitMallOrder", "POST", payload, false, false).then(res => { + this.tui.request("/order/submitMallOrder", "POST", payload, false, false).then(res => { uni.hideLoading(); if(res.code == 200) { let orderId = res.result; @@ -501,65 +577,6 @@ } }); }, - goDetail(){ - // Pass match conditions to worker list - let shopArea = this.shopItem.shopArea || ''; - let putArea = this.formData.address ? this.formData.address.areaId : ''; - uni.navigateTo({ - url:`/package1/index/deliveryPersonList?shopAreaId=${shopArea}&putAreaId=${putArea}` - }) - }, - openAddressBook(){ - this.$refs.bookPopup.open('bottom') - - }, - checkTime(type){ - if(type == this.formData.isImmediately){ - - } - this.formData.isImmediately = !this.formData.isImmediately - if(this.formData.isImmediately == false){ - this.$refs.model.open() - this.generateDeliveryTimes() - } - }, - checkVoucher(type) { - if (type == this.selected) return; - this.selected = type; - if(this.selected == 'buzhiding'){ - this.formData.peisongyuan = ""; - this.assignedWorker = null; - } - }, - //微信支付测试 - wxPayment() { - let that = this; - this.tui.request("/api/wechat/pay/unified-order", "POST", { - openid: uni.getStorageSync('miniProgramOpenid'), - amount: 1, // 支付金额(分) - description: '拼团订单', - outTradeNo: 'ORDER_' + Date.now() - }, false, false).then((res) => { - if (res.code == 200) { - uni.requestPayment({ - provider: 'wxpay', - timeStamp: res.timeStamp, - nonceStr: res.nonceStr, - package: res.package, - signType: res.signType, - paySign: res.paySign, - success: function(res2) { - console.log('success:' + JSON.stringify(res2)); - }, - fail: function(err) { - console.log('fail:' + JSON.stringify(err)); - } - }); - } else { - this.tui.toast(res.message) - } - }) - }, //时间选择器获取时间数据 generateDeliveryTimes() { const now = new Date();