wx.getLocation({
success: res => {
console.log(res);
},
fail: e => {
console.log(e);
// 判断用户是否拒绝了授权
wx.getSetting({
success: res => {
if (typeof(res.authSetting['scope.userLocation']) != 'undefined' && !res.authSetting['scope.userLocation']) {
// 用户拒绝了授权
wx.showModal({
title: '提示',
content: '您拒绝了定位权限,将无法使用XX功能',
success: res => {
if (res.confirm) {
// 跳转设置页面
wx.openSetting({
success: res => {
if (res.authSetting['scope.userLocation']) {
// 授权成功,重新定位
wx.getLocation({
success: res => {}
});
} else {
// 没有允许定位权限
wx.showToast({
title: '您拒绝了定位权限,将无法使用XX功能',
icon: 'none'
});
}
}
});
}
}
});
}
}
});
});
微信小程序拒绝获取定位后如何再次获取
最新推荐文章于 2023-06-12 16:49:01 发布