<button bindtap="getLocation" class="btnPhone {{lng !=''?'btnPhoneActive':''}}">获取地理位置</button>
getLocation() {
var that = this
wx.getLocation({
success: function(res) {
console.log("位置信息",res)
app.globalData.lat = res.latitude;
app.globalData.lon = res.longitude;
that.setData({
lng:res.longitude,
lat:res.latitude
})
that.postInfo()
wx.showToast({
title: '获取位置成功!',
icon: 'success',
duration: 1500
})
},
fail() {
wx.showModal({
title: '提醒',
content: '您拒绝了位置授权,将无法使用大部分功能,点击确定重新获取授权',
success(res) {
if (res.confirm) {
wx.openSetting({
success(res) {
if (res.authSetting["scope.userLocation"]) {
}
}
})
}
}
})
}
})
},