這個問題很奇怪,所有的簽名數據都正確,通過控制台一模一樣的數據,可能上一次還好好的,下一次可能就jsapi調用錯誤
function wxpageinit(app_id, Timestamp, Nonce_str, sign) { wx.config({ beta: true, debug: false, appId: app_id, timestamp: Timestamp, nonceStr: Nonce_str, signature: sign, jsApiList: ["checkJsApi", "chooseImage", "previewImage", "uploadImage", "downloadImage", "getNetworkType", "onHistoryBack", "selectEnterpriseContact", ] }); wx.ready(function () { try { wx.onHistoryBack(function () { return historyreturn(); }) } catch (e) { } }) } function setwxsign() { $.ajax({ url: "/xxxxxxx.action?v=1",//后台簽名 type: "GET", data: {}, contentType: "text/plain; charset=utf-8", dataType: "json", success: function (p_datas) { if (p_datas == null | p_datas.length == 0) { return; } if (p_datas[0].result != "success") { return; } try { data = p_datas[0]; if (data != undefined) { setTimeout("wxpageinit(data.app_id, data.timestamp, data.nonceStr, data.sign);", 1000 ); } } catch (e) { alert(e.Message); } }, fail: function (p_error) { } }) } try { $(function () { setwxsign();}); } catch (e) { }
注意紅色部分,增加一個延時再出現fail_permission denied的幾率少了很多。請忽略代碼風格,公司的老傳家代碼。
可能原因:
1.本地js未加載前執行了wx.config導致,但是並沒有報wx.config錯誤,而且wx.ready正常
2.可能是企業微信服務器的問題,(自從企業微信上線通訊錄組件替換后才出現該問題),之前的管理員緩存問題至今好像還未解決。