123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
- <title>Document</title>
- </head>
- <body>
- <div id="div">123</div>
- <button onclick="pay()">支付</button>
- </body>
- <script>
- const pay = async () => {
- WeixinJSBridge.invoke(
- 'getBrandWCPayRequest', {
- "appId":"wxb558057b16b95dd5",
- "timeStamp":"1525749068",
- "nonceStr":"LWm32hoWaAZ0zBZh",
- "package":"prepay_id=wx08111107238333432f16f39e3492244899",
- "signType":"MD5",
- "paySign":"347C9BB74842B310FFA6B5EE0B0E0AA1",
- "timestamp":"1525749068"
- },
- 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();
- }
- }
- </script>
- </html>
|