js⽀付实现代码本⽂实例为⼤家分享了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="res.wx.qq/open/js/jweixin-1.0.0.js"></script>
</head>
<body>
<script>
//调⽤JS api ⽀付
function jsApiCall()
{
WeixinJSBridge.invoke(
"getBrandWCPayRequest",
{$parms},
//下⾯是⽀付完成后的回调,可以直接提⽰成功
function(res) {
_msg == "get_brand_wcpay_request:ok") {
location.href = "{$success_url}";
}else _msg == "get_brand_wcpay_request:cancel"){
//      history.back();
location.href = "{$fail_url}";
}else{
alert("weixin return:" + JSON.stringify(res));
//      _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>
代码转换以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。