ios版本15.5,微信版本8.0.25,已经开启了微信定位,但是在调用wx.getLocation一直返回失败
代码片段
获取位置
authPowerSetting是wx.getSetting返回的结果
fetchLocation: async function () {
const sysInfo = await wx.getSystemInfoSync();
const locationEnabled = sysInfo['locationEnabled'];
wx.getLocation({
type: 'wgs84',
success (res) {
wx.hideLoading();
if (res.errMsg == "getLocation:ok") {
console.log(res)
} else {
try {
if (!locationEnabled) {
wx.showToast({
title: '请手动开启手机系统定位功能',
icon: 'none',
duration: 2000,
});
return;
}
} catch (error) {};
try {
let authPowerSetting = _this.data.authPowerSetting;
if (!authPowerSetting || !authPowerSetting.getUserLocation) {
wx.showToast({
title: '请在小程序右上角“...”-“设置”开起定位功能',
icon: 'none',
duration: 2000,
});
return;
}
} catch (error) {};
}
console.log(res)
},
fail(err) {
wx.hideLoading();
try {
if (!locationEnabled) {
wx.showToast({
title: '请手动开启手机系统定位功能',
icon: 'none',
duration: 2000,
});
return;
}
} catch (error) {};
try {
let authPowerSetting = _this.data.authPowerSetting;
if (!authPowerSetting || !authPowerSetting.getUserLocation) {
wx.showToast({
title: '请在小程序右上角“...”-“设置”开起定位功能',
icon: 'none',
duration: 2000,
});
return;
}
} catch (error) {};
console.log(err)
},
});
}
你可知失败的原因?