fix: 微信支付联调

pull/2/head
TianYu 2023-05-18 18:30:21 +08:00
parent 3a0fd70313
commit 96b8ed637e
2 changed files with 31 additions and 10 deletions

View File

@ -75,6 +75,35 @@
action: 'payClose'
});
},
// JSAPI
wxPayJSAPI(payData) {
function onBridgeReady() {
WeixinJSBridge.invoke('getBrandWCPayRequest', {
"appId": payData.appId, //ID
"timeStamp": payData.timeStamp, //1970
"nonceStr": payData.nonceStr, //
"package": payData.packageValue,
"signType": payData.signType, //
"paySign": payData.paySign //
},
function(res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
// 使,
//res.err_msgok
}
})
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady()
}
},
goPay: function(paytype) {
let that = this;
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
@ -99,16 +128,7 @@
switch (paytype) {
case 'WXPAY':
uni.hideLoading();
location.replace(jsConfig.h5Url + '&redirect_url=' + window.location.protocol +
'//' + window.location.host + goPages + '&status=1');
return that.$util.Tips({
title: "支付中",
icon: 'success'
}, () => {
that.$emit('onChangeFun', {
action: 'pay_complete'
});
});
that.wxPayJSAPI(jsConfig.jsapiResult)
break;
case 'ALIPAY':
uni.hideLoading();

View File

@ -9,6 +9,7 @@
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<title></title>
<!--preload-links-->
<!--app-context-->