https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#63
是需要等到http://res.wx.qq.com/open/js/jweixin-1.6.0.js里面的代码执行完吗?执行完的时候会有回调通知吗?比如注册一个全局的wxLoaded函数,可以使用wx的时候就调用wxLoaded。、
在微信支付的时候,WeixinJSBridgeReady就能告诉我什么时候可以调起支付了,不知道wx怎么处理最好。是否有wxReady事件呢?
https://pay.weixin.qq.com/docs/merchant/apis/jsapi-payment/jsapi-transfer-payment.html
function onBridgeReady() {
2 WeixinJSBridge.invoke('getBrandWCPayRequest', {
3 "appId": "wx2421b1c4370ec43b", //公众号ID,由商户传入
4 "timeStamp": "1395712654", //时间戳,自1970年以来的秒数
5 "nonceStr": "e61463f8efa94090b1f366cccfbbb444", //随机串
6 "package": "prepay_id=up_wx21201855730335ac86f8c43d1889123400",
7 "signType": "RSA", //微信签名方式:
8 "paySign": "oR9d8PuhnIc+YZ8cBHFCwfgpaK9gd7vaRvkYD7rthRAZ\/X+QBhcCYL21N7cHCTUxbQ+EAt6Uy+lwSN22f5YZvI45MLko8Pfso0jm46v5hqcVwrk6uddkGuT+Cdvu4WBqDzaDjnNa5UK3GfE1Wfl2gHxIIY5lLdUgWFts17D4WuolLLkiFZV+JSHMvH7eaLdT9N5GBovBwu5yYKUR7skR8Fu+LozcSqQixnlEZUfyE55feLOQTUYzLmR9pNtPbPsu6WVhbNHMS3Ss2+AehHvz+n64GDmXxbX++IOBvm2olHu3PsOUGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==" //微信签名
9 },
10 function(res) {
11 if (res.err_msg == "get_brand_wcpay_request:ok") {
12 // 使用以上方式判断前端返回,微信团队郑重提示:
13 //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
14 }
15 });
16}
17if (typeof WeixinJSBridge == "undefined") {
18 if (document.addEventListener) {
19 document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
20 } else if (document.attachEvent) {
21 document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
22 document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
23 }
24} else {
25 onBridgeReady();
26}