Browse Source

删除多余代码

feature/3.1.0-小区合伙人
lfs3 6 years ago
parent
commit
df20ce9e2d
1 changed files with 84 additions and 49 deletions
  1. 133
      src/view/home.vue

133
src/view/home.vue

@ -425,7 +425,6 @@ export default {
this.chooseCommunity();
},
getLocation() {
// let get = async () => {
//
var ua = window.navigator.userAgent.toLowerCase();
//uaMicroMessenger
@ -436,21 +435,10 @@ export default {
this.getId();
this.getAddressInfo();
});
// this.getData().then(result => {
// this.wxLocation({})
// });
} else {
// TODO api
this.getCity();
}
// };
// return get();
},
getWXLocation() {
let get = async () => {
await this.wxLocation({});
};
return get();
},
getCity() {
let _this = this;
@ -458,47 +446,94 @@ export default {
geolocation.getCurrentPosition(function(r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
// if(r.accuracy==null){
var lat = r.point.lat;
var lng = r.point.lng;
const pointBak = new BMap.Point(lng, lat);
const convertor = new BMap.Convertor();
convertor.translate([pointBak], 1, 5, function(resPoint) {
if (resPoint && resPoint.points && resPoint.points.length > 0) {
console.log("resPoint:"+resPoint.points[0]);
lng = resPoint.points[0].lng;
lat = resPoint.points[0].lat;
}
const point = new BMap.Point(lng, lat);
const geo = new BMap.Geocoder();
geo.getLocation(point, res => {
if (res.addressComponents) {
const result = res.addressComponents;
const location = {
creditLongitude: point.lng, //
creditLatitude: point.lat, //
creditProvince: result.province || "", //
creditCity: result.city || "", //
creditArea: result.district || "", //
creditStreet:
(result.street || "") + (result.streetNumber || "") //
};
_this.location = location;
localStorage.setItem("latitude", location.creditLatitude);
localStorage.setItem("longitude", location.creditLongitude);
_this.lat = location.creditLatitude;
_this.lng = location.creditLongitude;
alert(
"省-" +
location.creditProvince +
";市-" +
location.creditCity +
";区-" +
location.creditArea +
";街道-" +
location.creditStreet +
";lat-" +
location.creditLatitude +
";lng-" +
location.creditLongitude
);
_this.getId();
_this.getAddressInfo();
}
});
});
// alert('');
// //
// return;
// }else{
const myGeo = new BMap.Geocoder();
myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), data => {
if (data.addressComponents) {
const result = data.addressComponents;
const location = {
creditLongitude: r.point.lng, //
creditLatitude: r.point.lat, //
creditProvince: result.province || "", //
creditCity: result.city || "", //
creditArea: result.district || "", //
creditStreet:
(result.street || "") + (result.streetNumber || "") //
};
_this.location = location;
localStorage.setItem("latitude", location.creditLatitude);
localStorage.setItem("longitude", location.creditLongitude);
_this.lat = location.creditLatitude;
_this.lng = location.creditLongitude;
alert(
"省-" +
location.creditProvince +
";市-" +
location.creditCity +
";区-" +
location.creditArea +
";街道-" +
location.creditStreet +
";lat-" +
location.creditLatitude +
";lng-" +
location.creditLongitude
);
_this.getId();
_this.getAddressInfo();
}
});
// const myGeo = new BMap.Geocoder();
// myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), data => {
// if (data.addressComponents) {
// const result = data.addressComponents;
// const location = {
// creditLongitude: r.point.lng, //
// creditLatitude: r.point.lat, //
// creditProvince: result.province || "", //
// creditCity: result.city || "", //
// creditArea: result.district || "", //
// creditStreet:
// (result.street || "") + (result.streetNumber || "") //
// };
// _this.location = location;
// localStorage.setItem("latitude", location.creditLatitude);
// localStorage.setItem("longitude", location.creditLongitude);
// _this.lat = location.creditLatitude;
// _this.lng = location.creditLongitude;
// alert(
// "-" +
// location.creditProvince +
// ";-" +
// location.creditCity +
// ";-" +
// location.creditArea +
// ";-" +
// location.creditStreet +
// ";lat-" +
// location.creditLatitude +
// ";lng-" +
// location.creditLongitude
// );
// _this.getId();
// _this.getAddressInfo();
// }
// });
// }
}
});

Loading…
Cancel
Save