小程序获取位置权限设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
bindLocationTap: function() {
var that = this;
wx.getLocation({
success: function(res) {
console.log('success', res);
},
fail: function(res) {
if (res.errMsg == "getLocation:fail auth deny") {
wx.showModal({
title: '授权失败',
content: '请打开设置,开启获取位置权限',
complete: function(res) {
if (res.confirm) {
wx.openSetting({
complete: function (res1) {
if (res1.authSetting['scope.userLocation']) {
// do something
wx.getLocation({
success: function (res2) {
console.log('res2', res2)
},
})
}
}
})
}
}
})
}
}
})
}