js微信支付實現代碼
更新時間:2016年12月22日 16:30:20 作者:奇葩葩葩
這篇文章主要為大家詳細介紹了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>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
原生JavaScript實現頁面滾動監(jiān)聽的方法步驟
滾動監(jiān)聽事件一般網頁中的返回頂部按鈕都是通過滾動監(jiān)聽事件來實現的,本文給大家介紹了原生JavaScript實現頁面滾動監(jiān)聽的方法步驟,文中通過代碼示例講解的非常詳細,對大家的學習或工作有一定的幫助,需要的朋友可以參考下2025-03-03