|
@@ -2,7 +2,7 @@
|
|
|
<el-dialog v-loading='loading' element-loading-text="拼命加载中" width="80%" destroy-on-close :visible.sync="dialogTableVisible" append-to-body>
|
|
|
<el-form v-if="showSearch" ref="ruleForm" class="demo-form-inline" :inline="true">
|
|
|
<el-form-item class="search-box">
|
|
|
- <el-input size="small" @keydown.enter.native="seachEnterFun" v-model="searchKey" type="search" id="search" style="width: 219px" placeholder="请输入关键字进行搜索" />
|
|
|
+ <el-input size="small" @keydown.enter.native="seachEnterFun" v-model="searchKey" type="search" id="search" style="width: 280px" placeholder="请输入关键字进行搜索" />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button size="small" type="primary" class="map-btn" @click="searchMap">搜索</el-button>
|
|
@@ -12,7 +12,7 @@
|
|
|
<el-input size="small" maxlength="11" v-model="lng" style="width: 140px" disabled></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="纬度:" prop="lat">
|
|
|
- <el-input size="small" maxlength="10" v-model="lat" style="width: 140px" disabled></el-input>
|
|
|
+ <el-input size="small" maxlength="10" v-model="lat" style="width: 140px" disabled></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button size="small" type="primary" class="map-btn" @click="clickSureMap">确定</el-button>
|
|
@@ -24,7 +24,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-form>
|
|
|
- <amap @click="onMapClick" ref="map" :zoom="zoom" :center="center" style="height: 600px;" class="amap-demo">
|
|
|
+ <amap @click="onMapClick" ref="map" :zoom="zoom" :center="center" style="height: 620px;" class="amap-demo">
|
|
|
<amap-marker v-for="(marker,index) in markers" :key="index" :offset="marker.offset" :position="marker.position" :icon="marker.icon" :label="marker.label" />
|
|
|
</amap>
|
|
|
</el-dialog>
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
getLocation,
|
|
|
} from "../../api/order.js";
|
|
|
// import AmapVue from "@amap/amap-vue";
|
|
|
-// import { AMapUILoader } from "amap-js";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -61,14 +60,7 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
created() {},
|
|
|
- mounted() {
|
|
|
- // const loader = AMapUILoader.loadUI(["overlay/SimpleMarker"])
|
|
|
- // .then(([SimpleMarker]) => {
|
|
|
- // // 其他逻辑
|
|
|
- // console.log(SimpleMarker);
|
|
|
- // })
|
|
|
- // .catch((e) => {});
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
seachEnterFun(e) {
|
|
|
var keyCode = window.event ? e.keyCode : e.which;
|
|
@@ -78,36 +70,18 @@ export default {
|
|
|
},
|
|
|
getGeoCode(v) {
|
|
|
this.showAddressList = false;
|
|
|
- let address =
|
|
|
- (v.district ? v.district : v.cityname + v.adname) + v.address + v.name;
|
|
|
- getGeoCode({ address }).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (!res.data.length) {
|
|
|
- return this.$message({
|
|
|
- type: "error",
|
|
|
- message: "该点没有具体的地址信息,请重新选点!",
|
|
|
- });
|
|
|
- }
|
|
|
- this.addressDetail = res.data[0];
|
|
|
- this.addressDetail.address = address;
|
|
|
- let splitPoint = this.addressDetail.location.indexOf(",");
|
|
|
- this.lng = this.addressDetail.location.slice(0, splitPoint);
|
|
|
- this.lat = this.addressDetail.location.slice(splitPoint + 1);
|
|
|
- this.center = [this.lng, this.lat];
|
|
|
- this.markers = [
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- position: this.center,
|
|
|
- icon: "/static/image/map_current.png",
|
|
|
- },
|
|
|
- ];
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- type: "error",
|
|
|
- message: res.msg,
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ let splitPoint = v.location.indexOf(",");
|
|
|
+ this.lng = v.location.slice(0, splitPoint);
|
|
|
+ this.lat = v.location.slice(splitPoint + 1);
|
|
|
+ this.center = [this.lng, this.lat];
|
|
|
+ this.markers = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ position: this.center,
|
|
|
+ icon: "/static/image/map_current.png",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ this.getLocation();
|
|
|
},
|
|
|
searchMap() {
|
|
|
if (!this.searchKey.trim()) {
|
|
@@ -238,6 +212,7 @@ export default {
|
|
|
this.position = null;
|
|
|
}
|
|
|
},
|
|
|
+ // 获取当前点详细地址信息
|
|
|
getLocation() {
|
|
|
this.$axios
|
|
|
.get("https://restapi.amap.com/v3/geocode/regeo", {
|
|
@@ -247,22 +222,25 @@ export default {
|
|
|
extensions: "all",
|
|
|
},
|
|
|
})
|
|
|
- .then(function (res) {
|
|
|
- console.log("数据", res);
|
|
|
+ .then((res) => {
|
|
|
+ let data = res.data;
|
|
|
+ let address = data.regeocode.formatted_address.split(
|
|
|
+ data.regeocode.addressComponent.township
|
|
|
+ );
|
|
|
+ this.searchKey = address[address.length - 1];
|
|
|
+ this.addressDetail = {
|
|
|
+ address: this.searchKey,
|
|
|
+ province: data.regeocode.addressComponent.province,
|
|
|
+ city: data.regeocode.addressComponent.city.length
|
|
|
+ ? data.regeocode.addressComponent.city
|
|
|
+ : data.regeocode.addressComponent.province,
|
|
|
+ citycode: data.regeocode.addressComponent.citycode,
|
|
|
+ district: data.regeocode.addressComponent.district,
|
|
|
+ };
|
|
|
})
|
|
|
- .catch(function (res) {
|
|
|
+ .catch((res) => {
|
|
|
console.log(res);
|
|
|
});
|
|
|
- // getLocation({
|
|
|
- // location: `${this.lng},${this.lat}`,
|
|
|
- // radius: 500,
|
|
|
- // page: 1,
|
|
|
- // offset: 20,
|
|
|
- // }).then((res) => {
|
|
|
- // console.log("数据", res);
|
|
|
- // this.promptList = res.data;
|
|
|
- // this.showAddressList = true;
|
|
|
- // });
|
|
|
},
|
|
|
// 定位
|
|
|
getCurrentLocation() {
|