How do I bounce the authorization box

wx.authorize({ scope: 'scope.userLocation', success: (res) => { if(res.errMsg == 'authorize:ok') { ............. }}, fail: (res) = > {the console. The log (' failure: 'res)... }})Copy the code

Several cases of querying authorization records

Wx.getsetting ({success: (res) => {if(res.authsetting ["scope.userLocation"] === XXX) {}}}) wx.getSetting({success: (res) => {if(res.authsetting ["scope.userLocation"] === XXX) {}}})Copy the code

1. You have the permission to query records but are not allowed to enable authorization

Res.authsetting ["scope.userLocation"] === false // At this point, if you want to bootstrap to the Settings page to enable or disable location permissions, you can execute the following code: wx.showmodal ({title: 'Info: Location permission is not enabled ', confirmText:' to set ', showCancel: true, Content: "Required location information ", success: Function (res) {if (res.confirm) {wx.openSetting({success(res) {// Perform logical operations after location authorization . }} else if (res.cancel) {wx.showToast({title: 'authorization failed ', icon:' None ', duration: 2000})}} else if (res.cancel) {wx.showToast({title: 'authorization failed ', icon:' None ', duration: 2000})Copy the code

2. You have permission query records and authorization is enabled

Res.authsetting ["scope.userLocation"] === true // Wx.getLocation ({type: "wgs84", success (res) { let lng = res.longitude; let lat = res.latitude; }})Copy the code

3. No authorization record is required for the first authorization

Res.authsetting ["scope.userLocation"] is neither true nor false // The first authorization is the same as in this article wx.authorize({scope: 'scope.userLocation', success: (res) => {if(res.errmsg == 'authorize:ok') {// Authorization succeeded...... } }, fail: (res) => { })Copy the code