js微信支付实现代码
时间:2020-11-16 11:19:19|栏目:JavaScript代码|点击: 次
本文实例为大家分享了js微信支付的具体代码,供大家参考,具体内容如下
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="format-detection" content="telephone=no" /> <title>微信支付</title> <script type="text/javascript" src="/js/jquery.min.js"></script> <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> </head> <body> <script> //调用微信JS api 支付 function jsApiCall() { WeixinJSBridge.invoke( "getBrandWCPayRequest", {$parms}, //下面是支付完成后的回调,可以直接提示成功 function(res) { if(res.err_msg == "get_brand_wcpay_request:ok") { location.href = "{$success_url}"; }else if(res.err_msg == "get_brand_wcpay_request:cancel"){ // history.back(); location.href = "{$fail_url}"; }else{ alert("weixin return:" + JSON.stringify(res)); // alert(res.err_msg+" 参数有误,请返回!"); // history.back(); location.href = "{$fail_url}"; } } ); } function callpay() { if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', jsApiCall); document.attachEvent('onWeixinJSBridgeReady', jsApiCall); } }else{ jsApiCall(); } } callpay(); </script> </body> </html>
上一篇:nest.js 使用express需要提供多个静态目录的操作方法
栏 目:JavaScript代码
下一篇:css transform 3D幻灯片特效实现步骤解读
本文标题:js微信支付实现代码
本文地址:http://www.codeinn.net/misctech/22968.html