微信小程序获取用户位置信息用户未进行授权时引导用户进行授权
// 获取用户授权情况,用户未进行授权时引导用户进行授权
checkUserSetting(){
wx.getSetting({
withSubscriptions: true,
success:res=>{
if(res.authSetting['scope.userLocation'] == false){
this.openSetting = 'openSetting'
wx.openSetting({
complete:res=>{
if(res.authSetting['scope.userLocation']){
this.chooseLocation()
this.openSetting = null
}
}
})
}else{
this.openSetting = null
this.chooseLocation()
}
}
})
},
//选择位置
chooseLocation() {
wx.chooseLocation({
success: res => {
this.shopobj.address = res.address;
this.openSetting = null
},
fail:res=>{
console.log('获取位置失败!')
}
});
},