From a87dd26fc0059fa830a6b7f4e0ddb95706e4d7c7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UHC5L7D\\Jaxc" Date: Wed, 13 Sep 2023 20:30:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E7=94=9F=E6=B4=BB=E5=8F=B7=E7=9A=84=E6=98=AF=E5=90=A6sbridge?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/cashier/index.vue | 20 +++++++++++++------- src/views/cashier/result.vue | 17 +++++++---------- src/views/index/index.vue | 4 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/views/cashier/index.vue b/src/views/cashier/index.vue index e5cb813..d000339 100644 --- a/src/views/cashier/index.vue +++ b/src/views/cashier/index.vue @@ -75,9 +75,10 @@ this.fromAppurl1 =fromAppurl; this.token = token; this.rechargeAmount = rechargeAmount; - this.ready(); - this.getCurrentLocation(); - this.detail(trainingOrderId,token,type); + this.ready( this.getCurrentLocation()); + this.ready(this.detail(trainingOrderId,token,type)); + //this.getCurrentLocation(); + //this.detail(trainingOrderId,token,type); } @@ -213,10 +214,15 @@ } }, goToApp() { - AlipayJSBridge.call('openInBrowser', { - url: decodeURIComponent(this.fromAppurl1) - }); - AlipayJSBridge.call('closeWebview'); + if (window.AlipayJSBridge) { + AlipayJSBridge.call('openInBrowser', { + url: decodeURIComponent(this.fromAppurl1) + }); + AlipayJSBridge.call('closeWebview'); + }else{ + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', this.goToApp(), false); + } // window.location.href=decodeURIComponent(this.fromAppurl1); }, diff --git a/src/views/cashier/result.vue b/src/views/cashier/result.vue index 3c8fe02..7478d52 100644 --- a/src/views/cashier/result.vue +++ b/src/views/cashier/result.vue @@ -35,32 +35,29 @@ export default { } this.price=price; this.fromAppurl=fromAppurl; - this.ready(); }, methods: { - ready(callback) { - // 如果jsbridge已经注入则直接调用 - if (window.AlipayJSBridge) { - callback && callback(); - } else { - // 如果没有注入则监听注入的事件 - document.addEventListener('AlipayJSBridgeReady', callback, false); - } - }, goToApp() { + if (window.AlipayJSBridge) { AlipayJSBridge.call('openInBrowser', { url: decodeURIComponent(this.fromAppurl) }); AlipayJSBridge.call('closeWebview'); + }else{ + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', this.goToApp(), false); + } }, }, created() { + if (!window.AlipayJSBridge) { // 注入支付宝jsapi const s = document.createElement("script"); s.type = "text/javascript"; s.src ="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"; document.body.appendChild(s); + } }, }; diff --git a/src/views/index/index.vue b/src/views/index/index.vue index 750ba67..6fbd9a3 100644 --- a/src/views/index/index.vue +++ b/src/views/index/index.vue @@ -21,8 +21,8 @@ export default { }, methods: { pay(){ - //window.location.href = 'alipays://platformapi/startapp?saId=10000007&qrcode='+encodeURIComponent('http://192.168.1.39:9103/alipay/auth?trainingOrderId=506e9ae34e544f89abb220f0cec0c442&token=amlhcGVpMTY5NDU5MTE3NjIyMzA1NDc1&fromAppurl=paymoney://car:8888/carstep')//拉起支付宝扫一扫 - window.location.href="alipays://platformapi/startapp?appId=20000042&publicBizType=LIFE_APP&publicId=2021004116616163&url="+encodeURIComponent('http://192.168.1.39:9103/alipay/auth?trainingOrderId=506e9ae34e544f89abb220f0cec0c442&token=amlhcGVpMTY5NDU5MTE3NjIyMzA1NDc1&fromAppurl=paymoney://car:8888/carstep')//拉起生活号 + window.location.href = 'alipays://platformapi/startapp?saId=10000007&qrcode='+encodeURIComponent('http://192.168.1.39:9103/alipay/auth?trainingOrderId=506e9ae34e544f89abb220f0cec0c442&token=amlhcGVpMTY5NDU5MTE3NjIyMzA1NDc1&fromAppurl=paymoney://car:8888/carstep')//拉起支付宝扫一扫 + // window.location.href="alipays://platformapi/startapp?appId=20000042&publicBizType=LIFE_APP&publicId=2021004116616163&url="+encodeURIComponent('http://192.168.1.39:9103/alipay/auth?trainingOrderId=506e9ae34e544f89abb220f0cec0c442&token=amlhcGVpMTY5NDU5MTE3NjIyMzA1NDc1&fromAppurl=paymoney://car:8888/carstep')//拉起生活号 //window.location.href ='alipayqr://platformapi/startapp?saId=10000007&qrcode='+encodeURI('http://192.168.1.39:9103/alipay/auth?type=111&trainingOrderId=111&fromAppurl=111&token=111')//另一种拉起支付宝扫一扫 } },