授权

// 授权
wx.getLocation({
success: function (res) {
console.log(res)
lat = res.latitude,
lon = res.longitude,
wx.chooseLocation({
latitude: res.latitude,
longitude: res.longitude,
scale: 28,
success: function (res) {
console.log(res)
lat = res.latitude,
lon = res.longitude,
that.setData({
position: res.address + res.name
})
}
})
},
fail:function(res){
console.log("地址获取失败");
wx.showModal({
title: '提示',
content: '若不微信授权登录,将无法创建名片,点击取消可重新获取授权',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
wx.openSetting({
success: function (res) {
if (!res.authSetting["scope.userLocation"]) {
//这里是授权成功之后 填写你重新获取数据的js
that().chooseMapViewTap();
}
}
})
}
}
})
},
})

posted on 2018-01-18 18:25  再胖十斤就好  阅读(183)  评论(0编辑  收藏  举报

导航