用户第一次如果拒绝位置,但位置又是必须要授权的,为此在提交时会再次调用原先的获取位置方法,此时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
使用授权按钮操作后,点击后出现以下错误,请问是怎么回事。
VM3154:1 appServiceSDKScriptError
Cannot read property 'mode' of undefined;at api onAppEnterBackground callback function
TypeError: Cannot read property 'mode' of undefined
at Bt.<anonymous> (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:525987)
at Bt.emit (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:305615)
at Object.emit (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:324480)
at Bt.<anonymous> (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:330528)
at Bt.emit (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:305657)
at Object.emit (http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:324480)
at http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:325658
at http://127.0.0.1:49560/appservice/__dev__/WAService.js:1:262652
at e (http://127.0.0.1:49560/appservice/appservice?t=1547536492677:1205:2640)
at n.registerCallback.t (http://127.0.0.1:49560/appservice/appservice?t=1547536492677:1205:2903)