小程序获取地理位置第二次授权

小程序的获取地理位置的授权,先做配置处理(app.json)
“permission”: {
“scope.userLocation”: {
“desc”: “你的位置信息将用于接口的效果展示”
}
},
如果第一次拒绝获取位置后,短时间内不能再弹出授权弹框需要做特殊处理(模拟弹框 其实是showToast)
在这里插入图片描述
在这里插入图片描述
上图点击确定后做授权判断 ,跳到设置那里打开使用地理位置权限
againGet: function() {
var _this = this;
wx.getSetting({
success: function(res) {
if (res.authSetting[‘scope.userLocation’] != undefined && res.authSetting[‘scope.userLocation’] != true) {
wx.showModal({
title: ‘请求授权当前位置’,
content: ‘需要获取您的地理位置,确认授权?’,
success: function(res) {
if (res.confirm) {
wx.openSetting({
success: function(res) {
if (res.authSetting[“scope.userLocation”] == true) {
}
}
})
}
}
})
}
},
fail: function(res) {}
})
},
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/smlljet/article/details/89839848
今日推荐