小程序
小游戏
企业微信
微信支付
扫描小程序码分享
使用wx.authorize获取用户位置信息,用户拒绝授权后使用wx.openSetting引导用户打开设置,但是设置里面没有位置信息授权。这种要怎么处理?
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
请提供能复现问题的原生简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
就试了好多种方法,有的是打开设置,没有位置信息,有的是打开设置有位置信息,但是用户明显二次拒绝了,但是位置信息里面显示的是允许,manifest.json有按要求配置permission,微信开发工具基础库版本是3.12.0,手机微信小程序是8.0.66,
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
请提供能复现问题的原生简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
return new Promise((resolve,reject)=>{
uni.authorize({
scope: 'scope.userLocation',
success: (result)=>{
resolve(result)
},
fail: ()=>{
reject('授权失败')
},
});
})
}
const getLocalFail = ()=>{
uni.showModal({
title: '提示',
content: '需要获取您的地理位置,请前往设置打开位置权限',
success: (res)=>{
if(res.confirm){
uni.openSetting({
success: (res)=>{
console.log('打开设置成功',res)
},
fail: (err)=>{
console.log('打开设置失败',err)
},
});
}
},
});
}
// 进入页面调用
const theFirstGet = ()=>{
uni.getSetting({
success:async (result)=>{
if(result.authSetting['scope.userLocation']){
console.log('已经授权')
try {
await getAuthRize()
} catch (error) {
getLocalFail();
}
}else{
getCurrentLocation();
}
},
});
}
// 直接点击按钮打开设置调用
const sssss = ()=>{
uni.getLocation({
type: 'gcj02',
});
uni.openSetting({
success: (res)=>{
console.log('打开设置成功2',res)
},
fail: (err)=>{
console.log('打开设置失败2',err)
},
})
}
const theSecondGet = async ()=>{
uni.authorize({
scope: 'scope.userLocation',
});
}
就试了好多种方法,有的是打开设置,没有位置信息,有的是打开设置有位置信息,但是用户明显二次拒绝了,但是位置信息里面显示的是允许,manifest.json有按要求配置permission,微信开发工具基础库版本是3.12.0,手机微信小程序是8.0.66,