|
@ -34,7 +34,8 @@ export default { |
|
|
address: null, |
|
|
address: null, |
|
|
district: null, |
|
|
district: null, |
|
|
show:true, |
|
|
show:true, |
|
|
autoFlag:true |
|
|
autoFlag:true, |
|
|
|
|
|
latLng:null |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
@ -42,6 +43,9 @@ export default { |
|
|
mounted() { |
|
|
mounted() { |
|
|
setConfig(['checkJsApi', 'openLocation', 'getLocation', 'updateAppMessageShareData', 'updateTimelineShareData']) |
|
|
setConfig(['checkJsApi', 'openLocation', 'getLocation', 'updateAppMessageShareData', 'updateTimelineShareData']) |
|
|
this.signWX() |
|
|
this.signWX() |
|
|
|
|
|
if(this.latLng){ |
|
|
|
|
|
this.getAgency() |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
restAddress() { |
|
|
restAddress() { |
|
@ -66,8 +70,8 @@ export default { |
|
|
wx.getLocation({ |
|
|
wx.getLocation({ |
|
|
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' |
|
|
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' |
|
|
success: function (res) { |
|
|
success: function (res) { |
|
|
var latLng = new qq.maps.LatLng(res.latitude, res.longitude) |
|
|
_this.latLng = new qq.maps.LatLng(res.latitude, res.longitude) |
|
|
getAddr.getAddress(latLng) |
|
|
_this.getAddress() |
|
|
}, |
|
|
}, |
|
|
cancel: function (res) { |
|
|
cancel: function (res) { |
|
|
alert('用户拒绝授权获取地理位置') |
|
|
alert('用户拒绝授权获取地理位置') |
|
@ -77,18 +81,19 @@ export default { |
|
|
wx.error(function (res) { |
|
|
wx.error(function (res) { |
|
|
console.log('微信js-sdk 配置失败000' + res.errMsg) |
|
|
console.log('微信js-sdk 配置失败000' + res.errMsg) |
|
|
}) |
|
|
}) |
|
|
// 调取腾讯地图 |
|
|
}, |
|
|
var getAddr = new qq.maps.Geocoder({ |
|
|
// 地址逆解析 |
|
|
complete: function (res) { |
|
|
getAddress() { |
|
|
_this.address = res.detail |
|
|
this.$http.get(`https://restapi.amap.com/v3/geocode/regeo?location=${this.latLng.lng},${this.latLng.lat}&key=2af5c38e8d31470a87b4671829e01d1a&radius=1000&extensions=all`).then((res) => { |
|
|
var allAddress = res.detail.addressComponents |
|
|
if (res.status == 200) { |
|
|
var address = res.detail.address |
|
|
this.district = res.data.regeocode.addressComponent.district; |
|
|
console.log('地址:', address, allAddress.province, allAddress.city, allAddress.district) |
|
|
this.getAgency(true) |
|
|
_this.district = allAddress.district; |
|
|
} else{ |
|
|
_this.getAgency(true) |
|
|
console.log(res); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
backAuto(){ |
|
|
backAuto(){ |
|
|
if(this.autoFlag) return |
|
|
if(this.autoFlag) return |
|
|
this.autoFlag = true; |
|
|
this.autoFlag = true; |
|
|