This commit is contained in:
@@ -225,7 +225,36 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// H5 和小程序都使用 uni.requestPayment
|
// #ifdef H5
|
||||||
|
if (typeof WeixinJSBridge === 'undefined') {
|
||||||
|
uni.showToast({ title: '请在微信中打开', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
||||||
|
appId: payConfig.app_id,
|
||||||
|
timeStamp: payConfig.timestamp,
|
||||||
|
nonceStr: payConfig.nonce_str,
|
||||||
|
package: payConfig.package,
|
||||||
|
signType: payConfig.sign_type,
|
||||||
|
paySign: payConfig.pay_sign
|
||||||
|
}, function(res) {
|
||||||
|
if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
||||||
|
console.log('支付成功', res);
|
||||||
|
uni.showToast({ title: '支付成功', icon: 'success' });
|
||||||
|
setTimeout(() => {
|
||||||
|
loadWalletBalance();
|
||||||
|
}, 1500);
|
||||||
|
} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
|
||||||
|
uni.showToast({ title: '已取消支付', icon: 'none' });
|
||||||
|
} else {
|
||||||
|
console.error('支付失败', res);
|
||||||
|
uni.showToast({ title: '支付失败', icon: 'none' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef H5
|
||||||
uni.requestPayment({
|
uni.requestPayment({
|
||||||
timeStamp: payConfig.timestamp,
|
timeStamp: payConfig.timestamp,
|
||||||
nonceStr: payConfig.nonce_str,
|
nonceStr: payConfig.nonce_str,
|
||||||
@@ -241,7 +270,6 @@
|
|||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('支付失败', err);
|
console.error('支付失败', err);
|
||||||
// 判断是否用户取消
|
|
||||||
if (err.errMsg && (err.errMsg.includes('cancel') || err.errMsg.includes('用户取消'))) {
|
if (err.errMsg && (err.errMsg.includes('cancel') || err.errMsg.includes('用户取消'))) {
|
||||||
uni.showToast({ title: '已取消支付', icon: 'none' });
|
uni.showToast({ title: '已取消支付', icon: 'none' });
|
||||||
} else {
|
} else {
|
||||||
@@ -249,6 +277,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user