ios iPhone 6,系统版本是11.1.2,微信版本是:7.0.15。在getWifiList 进入后台wifi列表后,再次返回到小程序界面,wx.onGetWifiList没有进行
回调,在iPhoneX手机中试的wx.onGetWifiList可以正常回调
wx.getWifiList({
success: (res) => {
console.log("487:" + JSON.stringify(res));
log.info("wifiList:"+JSON.stringify(res));
},
fail(err) {
console.error(err);
log.error("获取wifi列表失败:"+err.errCode);
}
})
wx.onGetWifiList((res) => {
console.log("监听到的wifi列表aaaaa:");
that.data.apWifi = [];
const wifiList = res.wifiList;
log.info("监听到的wifi数量:"+wifiList.length);
log.info("监听wifi列表:"+res.wifiList);
for (var i = 0; i < wifiList.length; i++) {
var ssid = wifiList[i].SSID;
if (ssid.indexOf("zcy_"+app.globalData.wifiModeId) > -1) {
that.data.apWifi.push(wifiList[i]);
}
}
if (that.data.apWifi.length>0) {
var apList=that.data.apWifi;
that.data.apWifi = apList.sort(that.compare('signalStrength',false));
that.data.apConnectSuc = true;
console.log("热点列表"+JSON.stringify(that.data.apWifi));
clearTimeout(that.data.apTimeout);
log.info("监听到ap列表:"+JSON.stringify(that.data.apWifi));
that.setData({
orderAp:that.data.apWifi[0].SSID
})
if(that.data.isIos) {
console.log("热点:"+that.data.orderAp);
log.info("ios连接ap:"+that.data.orderAp);
wx.setWifiList({
wifiList: [{
SSID: that.data.orderAp,
password: ''
}],
success:function(res){
that.data.iosHide = true;
console.log("ios-setWifiList:"+JSON.stringify(res));
log.info("ios-setWifiList1:"+JSON.stringify(res.errMsg))
that.sendFun();
}
})
} else {
if(!that.data.isApSuc){
that.data.isApSuc = true;
log.info("Android-conct-Ap:"+that.data.orderAp);
wx.connectWifi({
SSID: that.data.orderAp,
password: '',
success: function (res) {
console.log("ap已连接至" + that.data.orderAp);
log.info("Androdi-connect-ap-fir"+JSON.stringify(res.wifi.SSID));
setTimeout(function(){
that.sendFun();
},2000)
},
fail: function (err) {
console.log("第一次连接热点失败"+err.errCode);
log.error("第一次安卓连接热点失败"+err.errCode);
}
})
}
}
} else {
clearTimeout(that.data.apTimeout);
log.info("未监听到ap重新获取wifi列表");
if(that.data.isIos){
wx.setWifiList({
wifiList: []
})
}
if(!that.data.isIos){
that.data.apTimeout=setInterval(function () {
wx.getWifiList({
success: (res) => {
},
fail(err) {
console.error(err);
}
})
}, 2000)
}
}
})
已解决 https://juejin.cn/post/7132345416879702052
你好,麻烦提供下复现的流程,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)