小程序授权
export function isAuthLocation() {
return new Promise((resolve, reject) => {
wx.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
scope: 'scope.userLocation',
success() {
console.log('这里是点击确认按钮授权成功后操作???');
wx.getLocation({
isHighAccuracy: true,
success(res) {
resolve(res)
},
});
},
fail() {
console.log('这里是拒绝的操作');
resolve('1')
}
})
}else {
console.log('授权过了');
wx.getLocation({
isHighAccuracy: true,
success(res) {
resolve(res)
},
fail() {
resolve('2')
}
});
}
}
})
})
}
版权声明:本文由Web学习之路发布,如需转载请注明出处。