1.修改H5 定位问题

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

@ -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