js微信支付實現(xiàn)代碼
更新時間:2016年12月22日 16:30:20 作者:奇葩葩葩
這篇文章主要為大家詳細介紹了javascript微信支付的相關(guān)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了js微信支付的具體代碼,供大家參考,具體內(nèi)容如下
<!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>
//調(diào)用微信JS api 支付
function jsApiCall()
{
WeixinJSBridge.invoke(
"getBrandWCPayRequest",
{$parms},
//下面是支付完成后的回調(diào),可以直接提示成功
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+" 參數(shù)有誤,請返回!");
// 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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
靜態(tài)頁面html中跳轉(zhuǎn)傳值的JS處理技巧
這篇文章主要介紹了靜態(tài)頁面html中跳轉(zhuǎn)傳值的JS處理技巧,結(jié)合實例形式分析了HTML頁面跳轉(zhuǎn)通過URL傳遞參數(shù)的方法與javascript處理技巧,具有一定參考借鑒價值,需要的朋友可以參考下2016-06-06
原生JavaScript實現(xiàn)頁面滾動監(jiān)聽的方法步驟
滾動監(jiān)聽事件一般網(wǎng)頁中的返回頂部按鈕都是通過滾動監(jiān)聽事件來實現(xiàn)的,本文給大家介紹了原生JavaScript實現(xiàn)頁面滾動監(jiān)聽的方法步驟,文中通過代碼示例講解的非常詳細,對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下2025-03-03
JavaScript如何實現(xiàn)數(shù)組內(nèi)的值累加
我們會經(jīng)常在開發(fā)過程中,需要獲取數(shù)組中的值累加,所以下面這篇文章主要給大家介紹了關(guān)于JavaScript如何實現(xiàn)數(shù)組內(nèi)的值累加的相關(guān)資料,文中給出了詳細的代碼示例,需要的朋友可以參考下2023-11-11

