|
|
@ -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); |
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|