wx.getSystemInfo获取系统定位信息locationAuthorized不正确?
在真机调试下,wx.getSystemInfo 获取系统定位locationAuthorized有错误,我已经关闭了系统的定位,但还是返回的是true
3 回复
完整代码 必须开启手机定位和微信定位
return new Promise(async (resolve, reject) => {
wx.getLocation({
fail: () => {
wx.getSetting({
success: (res) => {
let statu = res.authSetting
if(!statu['scope.userLocation']) {
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则用车功能将无法使用',
success: (tip) => {
if(tip.confirm) {
wx.openSetting({
success: (data) => {
if (data.authSetting["scope.userLocation"] === true) {
wx.showToast({
title: '授权成功',
icon: 'success',
duration: 1000,
complete() {
resolve()
}
})
} else {
wx.showToast({
title: '授权失败',
icon: 'success',
duration: 1000,
complete() {
reject()
}
})
}
}
})
} else {
reject()
}
}
})
} else {
wx.showModal({
title: '获取位置信息失败',
content: '请先开启手机定位,否则用车功能将无法使用'
})
reject()
}
},
fail: () => {
reject()
}
})
},
success: () => {
const system = wx.getSystemInfoSync()
if(!system.locationEnabled) {
wx.showModal({
title: '获取位置信息失败',
content: '请先开启手机定位,否则用车功能将无法使用'
})
reject()
}
resolve()
}
})
})