博睿 发表于 2022-5-22 00:27:51

微信扫一扫 iOS 不能用

https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=78639&fromuid=51381
根据这个帖子做的,安卓的可以,iOS 程序会死掉,什么操作都做不了!

页面加载程序可以有问题,请哪位高手看一下,红色这句什么意思?

var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
let innerurl = ''
if (isAndroid) {
    innerurl = location.href
}
if (isIOS) {
    innerurl = location.href.split('#')//hash后面的部分如果带上ios中config会不对
}
var url = Forguncy.ForguncyData.ForguncyRoot + 'customapi/wechatapi/getsignature';

var data =
{
    "url": innerurl,
};

$.post(url, data, function (result) {
    console.log(result);
    var valueList = JSON.parse(result);
    wx.config({
      debug: false,
      appId: valueList.appid,
      timestamp: valueList.timestamp,
      nonceStr: valueList.nonceStr,
      signature: valueList.signature,
      jsApiList: ["startRecord", "stopRecord", "translateVoice", "scanQRCode", "playVoice", "pauseVoice", 'translateVoice',"stopVoice", "openLocation", "getLocation"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
    });
    wx.ready(function () {
    });
    wx.error(function (res) {
    });
});

页: [1]
查看完整版本: 微信扫一扫 iOS 不能用