用户第一次如果拒绝位置,但位置又是必须要授权的,为此在提交时会再次调用原先的获取位置方法,此时wx.authorize返回为fail,所以在fail中增加了 wx.openSetting的方法,但是没有用,请问是不是写错了,还是微信强制不允许。
if (res.authSetting['scope.userLocation'] != true) {
wx.authorize({
scope: 'scope.userLocation',
success() {
console.log('调用授权success')
that.getWxLocation();
},
fail: function (res) {
console.log('调用授权fail')
wx.openSetting({
success: (res) => {
if (res.authSetting['scope.userLocation'] = true) {
that.getWxLocation();
}
}
})
}
})
}
微信小程序开发问题解答
微信小程序开发者回答:
记录一下用户关于地址授权状态:未弹起授权,授权弹起未允许,授权弹起允许,再判断处理;
微信小程序开发者回答:
wx.openSetting那个接口已经改了,看文档吧:https://developers.weixin.qq.com/community/develop/doc/000cea2305cc5047af5733de751008?highLine=wx.openSetting
本文网址:http://www.91bianli.com/weixinxiaochengxu/19252.html