小程序的获取地理位置的授权,先做配置处理(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) {}
})
},
小程序获取地理位置第二次授权

相关文章:

  • 2021-12-15
  • 2022-01-16
  • 2021-12-23
  • 2021-12-04
  • 2021-11-21
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2021-11-21
  • 2021-12-08
  • 2021-11-21
  • 2022-12-23
  • 2021-11-21
相关资源
相似解决方案