From 8149784686a4860eaaa9e4def6264d2cabbdace7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UHC5L7D\\Jaxc" Date: Wed, 13 Sep 2023 19:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E7=94=9F=E6=B4=BB?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=88=90=E5=8A=9F=E5=90=8E=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/cashier/index.vue | 7 +++++-- src/views/cashier/result.vue | 21 +++++++++++++++++++-- src/views/index/index.vue | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/views/cashier/index.vue b/src/views/cashier/index.vue index b1fc3bd..e5cb813 100644 --- a/src/views/cashier/index.vue +++ b/src/views/cashier/index.vue @@ -213,8 +213,11 @@ } }, goToApp() { - - window.location.href =decodeURIComponent(this.fromAppurl1); + AlipayJSBridge.call('openInBrowser', { + url: decodeURIComponent(this.fromAppurl1) + }); + AlipayJSBridge.call('closeWebview'); + // window.location.href=decodeURIComponent(this.fromAppurl1); }, }, diff --git a/src/views/cashier/result.vue b/src/views/cashier/result.vue index f14d411..3c8fe02 100644 --- a/src/views/cashier/result.vue +++ b/src/views/cashier/result.vue @@ -35,15 +35,32 @@ 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() { - window.location.href=decodeURIComponent(this.fromAppurl); + AlipayJSBridge.call('openInBrowser', { + url: decodeURIComponent(this.fromAppurl) + }); + AlipayJSBridge.call('closeWebview'); }, }, created() { - + // 注入支付宝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 3e5df7b..750ba67 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=65aee95e818f4571b2480bdafba4cd4a&token=amlhcGVpMTY5NDE1MjM0MzU5NTM0OTQ2&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=65aee95e818f4571b2480bdafba4cd4a&token=amlhcGVpMTY5NDE1MjM0MzU5NTM0OTQ2&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')//另一种拉起支付宝扫一扫 } },