|
|
|
@ -249,7 +249,12 @@ |
|
|
|
|
}) |
|
|
|
|
// #endif |
|
|
|
|
//定位 |
|
|
|
|
// #ifdef MP |
|
|
|
|
this.postionIng(); |
|
|
|
|
// #endif |
|
|
|
|
// #ifdef H5 |
|
|
|
|
this.getCoordinates(); |
|
|
|
|
// #endif |
|
|
|
|
uni.getStorage({ |
|
|
|
|
key: "user", |
|
|
|
|
success(e) { |
|
|
|
@ -428,6 +433,26 @@ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//H5 获取定位 |
|
|
|
|
getCoordinates() { |
|
|
|
|
let that = this; |
|
|
|
|
// 获取当前地理位置信息 |
|
|
|
|
let data = { |
|
|
|
|
key: "7UMBZ-HFEHX-HSD4Q-Z3QY6-OQKN7-2QBDB" //密钥,需要在腾讯位置服务官网(https://lbs.qq.com/)申请自己的密钥。 |
|
|
|
|
}; |
|
|
|
|
let url = "https://apis.map.qq.com/ws/location/v1/ip"; //地理位置信息接口(根据IP自动获取当前城市位置信息) |
|
|
|
|
data.output = "jsonp"; |
|
|
|
|
//判断用户是否输入了搜索关键字,若没有输入搜索关键字则调用根据IP自动获取当前城市位置信息的接口。 |
|
|
|
|
this.$jsonp(url, data) |
|
|
|
|
.then(res => { |
|
|
|
|
app.globalData.latitude = res.result.location.lat; |
|
|
|
|
app.globalData.longitude = res.result.location.lng; |
|
|
|
|
that.getUserLocation(res.result.location.lng, res.result.location.lat); |
|
|
|
|
}) |
|
|
|
|
.catch(error => { |
|
|
|
|
console.log(error); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//经纬度转换 |
|
|
|
|
findByLatAndLng(item, item1) { |
|
|
|
|
let that = this; |
|
|
|
|