修复好店的支付bug

This commit is contained in:
赵毅 2025-09-22 17:09:04 +08:00
parent ed3a8f6e55
commit cc30b85288

View File

@ -18,7 +18,8 @@
<view class="Msg"> <view class="Msg">
<view class="payMony"> <view class="payMony">
<input type="number" v-model="Money" placeholder="付款金额" placeholder-style="font-size: 50rpx;" @blur="handleMoneyInput" @focus="showKeyboard" step="0.01" min="0.01"> <input type="number" v-model="Money" placeholder="付款金额" placeholder-style="font-size: 50rpx;"
@blur="handleMoneyInput" @focus="showKeyboard" step="0.01" min="0.01">
<cu-keyboard ref="cukeyboard" @change="change" @confirm="keyboardConfirm" @hide="hide"></cu-keyboard> <cu-keyboard ref="cukeyboard" @change="change" @confirm="keyboardConfirm" @hide="hide"></cu-keyboard>
</view> </view>
<view class="payRemark"> <view class="payRemark">
@ -144,26 +145,26 @@ export default {
change(value) { change(value) {
// //
let formattedValue = value.toString().replace(/[^\d.]/g, ''); let formattedValue = value.toString().replace(/[^\d.]/g, '');
// 00 // 00
if (formattedValue.length >= 2 && formattedValue[0] === '0' && formattedValue[1] !== '.') { if (formattedValue.length >= 2 && formattedValue[0] === '0' && formattedValue[1] !== '.') {
formattedValue = formattedValue.substring(1); formattedValue = formattedValue.substring(1);
} }
// //
formattedValue = formattedValue.replace(/\.{2,}/g, '.'); formattedValue = formattedValue.replace(/\.{2,}/g, '.');
// //
const parts = formattedValue.split('.'); const parts = formattedValue.split('.');
if (parts.length > 1) { if (parts.length > 1) {
formattedValue = parts[0] + '.' + parts[1].substring(0, 2); formattedValue = parts[0] + '.' + parts[1].substring(0, 2);
} }
// //
if (formattedValue.startsWith('.')) { if (formattedValue.startsWith('.')) {
formattedValue = '0' + formattedValue; formattedValue = '0' + formattedValue;
} }
this.Money = formattedValue; this.Money = formattedValue;
}, },
// //
@ -297,7 +298,7 @@ export default {
} }
request(apiArr.createPay, "POST", { request(apiArr.createPay, "POST", {
merchant_id: that.info.id, merchant_id: that.info.id,
order_amount: Number((that.Money) * 100), // order_amount: Number((that.Money)), //
refund_property_fee: that.homeMoney, // refund_property_fee: that.homeMoney, //
refund_member_points: that.integral, // refund_member_points: that.integral, //
remark: that.remarks, remark: that.remarks,
@ -331,38 +332,44 @@ export default {
async LakaLaPrePay() { async LakaLaPrePay() {
let that = this let that = this
request(apiPay.pay, "POST", { request(apiArr.getPreOrderInfo, "POST", {
total_amount: that.OrderMsg.order_amount, id: that.payId,
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')
}).then(res => { }).then(res => {
console.log(res, 'res'); if (res && res.timeStamp && res.nonceStr && res.package && res.signType && res.paySign) {
//
const { resp_data, msg } = res uni.requestPayment({
timeStamp: res.timeStamp,
wx.requestPayment({ nonceStr: res.nonceStr,
timeStamp: String(resp_data.acc_resp_fields.time_stamp), package: res.package,
nonceStr: String(resp_data.acc_resp_fields.nonce_str), signType: res.signType,
package: String(resp_data.acc_resp_fields.package), paySign: res.paySign,
signType: String(resp_data.acc_resp_fields.sign_type), success: (payRes) => {
paySign: String(resp_data.acc_resp_fields.pay_sign), const params = {
success(res) { id: this.OrderMsg.id,
that.queryPay(resp_data) }
}, request(apiArr.tradeQuery, "POST", params).then(res => {
fail(fal) { })
if (fal.errMsg == 'requestPayment:fail cancel') { },
// that.payFail(2) fail: (payErr) => {
} else { uni.showToast({
// that.payFail(1) title: payErr.errMsg == 'requestPayment:fail cancel' ? '已取消支付' : '支付失败',
icon: 'none'
})
const params = {
order_ids: orderId,
}
},
complete: () => {
//
} }
} })
}) } else {
console.error("获取支付参数失败,缺少必要参数")
uni.showToast({
title: '获取支付信息失败',
icon: 'none'
})
}
}) })
}, },