From cc30b85288aff1e738e2337817ede80c37c361aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Mon, 22 Sep 2025 17:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A5=BD=E5=BA=97=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E4=BB=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/localLife/pay/index.vue | 81 +++++++++++++++++--------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/packages/localLife/pay/index.vue b/packages/localLife/pay/index.vue index ee40d85e..8fb57257 100644 --- a/packages/localLife/pay/index.vue +++ b/packages/localLife/pay/index.vue @@ -18,7 +18,8 @@ - ¥ + ¥ @@ -144,26 +145,26 @@ export default { change(value) { // 先进行基本的输入格式化 let formattedValue = value.toString().replace(/[^\d.]/g, ''); - + // 如果第一个数字是0且后面还有其他数字,则删除这个0 if (formattedValue.length >= 2 && formattedValue[0] === '0' && formattedValue[1] !== '.') { formattedValue = formattedValue.substring(1); } - + // 限制只能有一个小数点 formattedValue = formattedValue.replace(/\.{2,}/g, '.'); - + // 确保小数点后最多两位 const parts = formattedValue.split('.'); if (parts.length > 1) { formattedValue = parts[0] + '.' + parts[1].substring(0, 2); } - + // 处理开头是小数点的情况 if (formattedValue.startsWith('.')) { formattedValue = '0' + formattedValue; } - + this.Money = formattedValue; }, // 点击键盘确认按钮时触发 @@ -297,7 +298,7 @@ export default { } request(apiArr.createPay, "POST", { merchant_id: that.info.id, - order_amount: Number((that.Money) * 100), //金额 + order_amount: Number((that.Money)), //金额 refund_property_fee: that.homeMoney, //物业费 refund_member_points: that.integral, //积分 remark: that.remarks, @@ -331,38 +332,44 @@ export default { async LakaLaPrePay() { let that = this - request(apiPay.pay, "POST", { - total_amount: that.OrderMsg.order_amount, - subject: '快捷支付订单', - goods_id: that.payId, - address: "", - out_trade_no: that.OrderMsg.order_no, - remark: that.OrderMsg.remark, - quantity: '1', - user: uni.getStorageSync('userId'), - user_id: uni.getStorageSync('openId') + request(apiArr.getPreOrderInfo, "POST", { + id: that.payId, }).then(res => { - console.log(res, 'res'); - - const { resp_data, msg } = res - - wx.requestPayment({ - timeStamp: String(resp_data.acc_resp_fields.time_stamp), - nonceStr: String(resp_data.acc_resp_fields.nonce_str), - package: String(resp_data.acc_resp_fields.package), - signType: String(resp_data.acc_resp_fields.sign_type), - paySign: String(resp_data.acc_resp_fields.pay_sign), - success(res) { - that.queryPay(resp_data) - }, - fail(fal) { - if (fal.errMsg == 'requestPayment:fail cancel') { - // that.payFail(2) - } else { - // that.payFail(1) + if (res && res.timeStamp && res.nonceStr && res.package && res.signType && res.paySign) { + // 调用微信支付 + uni.requestPayment({ + timeStamp: res.timeStamp, + nonceStr: res.nonceStr, + package: res.package, + signType: res.signType, + paySign: res.paySign, + success: (payRes) => { + const params = { + id: this.OrderMsg.id, + } + request(apiArr.tradeQuery, "POST", params).then(res => { + }) + }, + fail: (payErr) => { + uni.showToast({ + title: payErr.errMsg == 'requestPayment:fail cancel' ? '已取消支付' : '支付失败', + icon: 'none' + }) + const params = { + order_ids: orderId, + } + }, + complete: () => { + // 支付完成后的回调,无论成功失败都会执行 } - } - }) + }) + } else { + console.error("获取支付参数失败,缺少必要参数") + uni.showToast({ + title: '获取支付信息失败', + icon: 'none' + }) + } }) },