fix: 微信支付联调
parent
3a0fd70313
commit
96b8ed637e
|
@ -75,6 +75,35 @@
|
||||||
action: 'payClose'
|
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_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
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) {
|
goPay: function(paytype) {
|
||||||
let that = this;
|
let that = this;
|
||||||
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
|
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
|
||||||
|
@ -99,16 +128,7 @@
|
||||||
switch (paytype) {
|
switch (paytype) {
|
||||||
case 'WXPAY':
|
case 'WXPAY':
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
location.replace(jsConfig.h5Url + '&redirect_url=' + window.location.protocol +
|
that.wxPayJSAPI(jsConfig.jsapiResult)
|
||||||
'//' + window.location.host + goPages + '&status=1');
|
|
||||||
return that.$util.Tips({
|
|
||||||
title: "支付中",
|
|
||||||
icon: 'success'
|
|
||||||
}, () => {
|
|
||||||
that.$emit('onChangeFun', {
|
|
||||||
action: 'pay_complete'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case 'ALIPAY':
|
case 'ALIPAY':
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
|
@ -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' +
|
'<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' : '') + '" />')
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||||
</script>
|
</script>
|
||||||
|
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||||
<title></title>
|
<title></title>
|
||||||
<!--preload-links-->
|
<!--preload-links-->
|
||||||
<!--app-context-->
|
<!--app-context-->
|
||||||
|
|
Loading…
Reference in New Issue