微信的demo如下,但是
function (res)里面的程序就是不执行,经过千辛万苦终于查到原因,支付按钮的OnClientClick="callpay()" 改为OnClientClick="javascript:callpay();return false;"
//调用微信JS api 支付
function jsApiCall()
{
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
<%=wxJsApiParam%>,//josn串
function (res)
{
//WeixinJSBridge.log(res.err_msg);
//alert(res.err_code + res.err_desc + res.err_msg);
//window.location.href="https://www.baidu.com";
alert("ok");
}
);
}
function callpay()
{
if (typeof WeixinJSBridge == "undefined")
{
//alert("undefined");
if (document.addEventListener)
{
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
}
else if (document.attachEvent)
{
document.attachEvent('WeixinJSBridgeReady', jsApiCall);
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
}
}
else
{
//alert("pay");
jsApiCall();
}
}