修复好店的支付bug
This commit is contained in:
parent
ed3a8f6e55
commit
cc30b85288
@ -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, '');
|
||||||
|
|
||||||
// 如果第一个数字是0且后面还有其他数字,则删除这个0
|
// 如果第一个数字是0且后面还有其他数字,则删除这个0
|
||||||
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'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user