update sheep/platform/pay.js.

Signed-off-by: huppygo <huppygo@qq.com>
pull/143/head
huppygo 2025-02-12 01:23:31 +00:00 committed by Gitee
parent 0c88f6c2af
commit e02db4339e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 30 additions and 13 deletions

View File

@ -252,22 +252,39 @@ export default class SheepPay {
});
}
// 微信支付App TODO 芋艿:待接入:待接入【暂时没打包 app所以没接入一般人用不到】
// 微信支付App
async wechatAppPay() {
let that = this;
let { error, data } = await this.prepay();
if (error === 0) {
uni.requestPayment({
provider: 'wxpay',
orderInfo: data.pay_data, //微信订单数据(官方说是string。实测为object)
success: (res) => {
that.payResult('success');
},
fail: (err) => {
err.errMsg !== 'requestPayment:fail cancel' && that.payResult('fail');
},
});
// 获取预支付信息
let { code, data } = await this.prepay('wx_app');
if (code !== 0) {
sheep.$helper.toast('获取支付信息失败');
return;
}
// 解析支付参数
const payConfig = JSON.parse(data.displayContent);
// 调用微信支付
uni.requestPayment({
provider: 'wxpay',
timeStamp: payConfig.timeStamp,
nonceStr: payConfig.nonceStr,
package: payConfig.packageValue,
signType: payConfig.signType,
paySign: payConfig.paySign,
success: (res) => {
that.payResult('success');
},
fail: (err) => {
if (err.errMsg === 'requestPayment:fail cancel') {
sheep.$helper.toast('支付已手动取消');
} else {
sheep.$helper.toast('支付失败:' + err.errMsg);
that.payResult('fail');
}
}
});
}
// 支付结果跳转,success:成功fail:失败