wx.getLocation({//弹出授权用户确认后获取其地理位置
type: ‘gcj02’,
success: function (res) {
},
fail:function(){
//判断是否获得了用户地理位置授权
wx.getSetting({
success: (res) => {
if (!res.authSetting[‘scope.userLocation’])
that.openConfirm()
}
})
}
})
openConfirm: function () {
var that=this;
wx.showModal({
content: ‘检测到您没打开定位权限,是否去设置打开?’,
confirmText: “确认”,
cancelText: “取消”,
success: function (res) {
console.log(res);
//点击“确认”时打开设置页面
if (res.confirm) {
console.log(‘用户点击确认’)
wx.openSetting({
success: (res) => {
wx.getLocation({//弹出授权用户确认后获取其地理位置
type: ‘gcj02’,
success: function (res) {
console.log(‘603S’,res)
}
})
}
})
} else {
console.log(‘用户点击取消’)
}
}
});
},