|
|
@@ -36,6 +36,7 @@
|
|
|
import { Row, Col, Icon, Cell, CellGroup,Toast } from 'vant';
|
|
|
import {getAction} from '@/api/manage'
|
|
|
import wx from 'weixin-jsapi'
|
|
|
+import BMap from 'vue-baidu-map'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -47,6 +48,9 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ province:'',
|
|
|
+ city:'',
|
|
|
+ district:'',
|
|
|
url: {
|
|
|
getJsapiConfig: '/f/api/wechat/getJsapiConfig',
|
|
|
}
|
|
|
@@ -89,17 +93,39 @@ export default {
|
|
|
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
|
|
success: function(res) {
|
|
|
console.log(JSON.stringify(res))
|
|
|
- // var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
|
|
|
- // var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
|
|
|
- // var speed = res.speed; // 速度,以米/每秒计
|
|
|
- // var accuracy = res.accuracy; // 位置精度
|
|
|
+ var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
|
|
|
+ var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
|
|
|
+ this.changeLocation(latitude,longitude);
|
|
|
},
|
|
|
cancel: function() {
|
|
|
console.log("获取位置失败,请检查定位");
|
|
|
Toast("获取位置失败,请检查定位")
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ //腾讯地图经纬度转百度地图经纬度,并解析省市区
|
|
|
+ changeLocation(latitude, longitude){
|
|
|
+ var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
+ var x = parseFloat(longitude);
|
|
|
+ var y = parseFloat(latitude);
|
|
|
+ var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
|
+ var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
|
+ longitude = z * Math.cos(theta) + 0.0065;
|
|
|
+ latitude = z * Math.sin(theta) + 0.006;
|
|
|
+
|
|
|
+ //百度地图
|
|
|
+ var point = new BMap.Point(longitude, latitude);
|
|
|
+ var gc = new BMap.Geocoder();
|
|
|
+
|
|
|
+ gc.getLocation(point, function(rs) {
|
|
|
+ var addComp = rs.addressComponents;
|
|
|
+ console.log("addComp省市区信息=",addComp);
|
|
|
+ this.province = addComp.province;
|
|
|
+ this.city = addComp.city;
|
|
|
+ this.district = addComp.district;
|
|
|
+ });
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|