企业微信JS-SDK权限注入,相同代码,安卓正常,IOS出现以下报错,大概啥原因?
相关代码:
wx.config({
beta: true,
debug: true,
appId: dataForWeixin.appId,
timestamp: TimeStamp,
nonceStr: NonceStr,
signature: Signature,
jsApiList: ['onMenuShareAppMessage', 'onMenuShareWechat', 'onMenuShareTimeline', 'getContext', 'getCurExternalContact', 'scanQRCode', 'selectEnterpriseContact', 'openEnterpriseChat', 'updateEnterpriseChat', 'getCurExternalChat'],
success: function (res) {
},
fail: function (res) {
},
});
你好,看截图ios config也是成功的,只是有些接口是需要在agentconfig中调用的,像在侧边栏获取外部联系人userid这些接口是需要在agentconfig中调用的
请问一下,在调用扫一扫功能时,返回的jsApiList为空是什么原因引起的(可信域名已添加)
代码如下:
<body>
<h1 id="wxcode" style="text-align: center;">扫一扫</h1>
<script type="text/javascript" src="./jquery-3.3.1.js"></script>
<!--调用jquery.min.js文件-->
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
var appId = '';
var timestamp = '';
var nonceStr = '';
var signature = '';
$.ajax({
type: "post",
url: "index.php",
cache: false,
async: false,
dataType: "json",
success: function(e) {
alert(e)
appId = e.appId;
timestamp = e.timestamp;
nonceStr = e.nonceStr;
signature = e.signature;
}
});
console.log(signature);
wx.config({
beta:true,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
debug: false,
// 必填,公众号的唯一标识
// appId: "wx259ea197bf8b2eab",
appId: appId,
// 必填,生成签名的时间戳
timestamp: timestamp,
// 必填,生成签名的随机串
nonceStr: nonceStr,
// 必填,签名,见附录1
// signature:"805c5e6f956fa5572b5b3ccc65d7581fe6cd37e1",
signature: signature,
// 必填,需要使用的JS接口列表,所有JS接口列表见附录2
jsApiList: ['scanQRCode']
});
wx.error(function(res) {
alert("----------出错了-----------:" + res.errMsg); //这个地方的好处就是wx.config配置错误,会弹出窗口哪里错误,然后根据微信文档查询即可。
});
wx.ready(function() {
wx.checkJsApi({
jsApiList: ['scanQRCode'],
success: function(res) {
// console.log(444);
}
});
//点击按钮扫描二维码
$('#wxcode').click(function() {
// alert(1);
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function(res) {
var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
alert(getQueryString('a'));
}
});
})
});
function getQueryString(name) {
var reg = new RegExp("\\b" + name + "=([^&]*)");
var r = location.href.match(reg);
if (r != null) return unescape(r[1]);
}
</script>
</body>