1.修改H5 定位问题

yj-dev
杨杰 3 years ago
parent 3f48b10e59
commit f7e0dfa745
  1. 4
      pages/goods/refuel-details/refuel-details.vue
  2. 25
      pages/tabBar/home/home.vue

@ -264,7 +264,7 @@
latitude: app.globalData.latitude, latitude: app.globalData.latitude,
longitude: app.globalData.longitude, longitude: app.globalData.longitude,
isTyAgent: this.isTyAgent isTyAgent: this.isTyAgent
} }
recentGasStation(params).then(res => { recentGasStation(params).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
@ -304,7 +304,7 @@
latitude: app.globalData.latitude, latitude: app.globalData.latitude,
longitude: app.globalData.longitude, longitude: app.globalData.longitude,
isTyAgent: this.isTyAgent isTyAgent: this.isTyAgent
} }
getGasDetailByStoreKey(params).then(res => { getGasDetailByStoreKey(params).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {

@ -249,7 +249,12 @@
}) })
// #endif // #endif
// //
// #ifdef MP
this.postionIng(); this.postionIng();
// #endif
// #ifdef H5
this.getCoordinates();
// #endif
uni.getStorage({ uni.getStorage({
key: "user", key: "user",
success(e) { 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) { findByLatAndLng(item, item1) {
let that = this; let that = this;

Loading…
Cancel
Save