|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
- <el-dialog width="80%" :show-close="false" destroy-on-close :visible.sync="dialogTableVisible">
|
|
|
|
- <el-form ref="ruleForm" class="demo-form-inline" :inline="true">
|
|
|
|
|
|
+ <el-dialog width="80%" destroy-on-close :visible.sync="dialogTableVisible">
|
|
|
|
+ <el-form v-if="showSearch" ref="ruleForm" class="demo-form-inline" :inline="true">
|
|
<el-form-item class="search-box">
|
|
<el-form-item class="search-box">
|
|
<el-input v-model="searchKey" type="search" id="search" style="width: 219px" placeholder="请输入关键字进行搜索" />
|
|
<el-input v-model="searchKey" type="search" id="search" style="width: 219px" placeholder="请输入关键字进行搜索" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -9,14 +9,20 @@
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<div class="tip-box" id="searchTip"></div>
|
|
<div class="tip-box" id="searchTip"></div>
|
|
<el-form-item label="经度" prop="lng">
|
|
<el-form-item label="经度" prop="lng">
|
|
- <el-input maxlength="11" v-model="lng" style="width: 219px" disabled></el-input>
|
|
|
|
|
|
+ <el-input maxlength="11" v-model="lng" style="width: 140px" disabled></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="维度:" prop="lat">
|
|
|
|
- <el-input maxlength="10" v-model="lat" style="width: 219px" disabled></el-input>
|
|
|
|
|
|
+ <el-form-item label="纬度:" prop="lat">
|
|
|
|
+ <el-input maxlength="10" v-model="lat" style="width: 140px" disabled></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" class="map-btn" @click="clickSureMap">确定</el-button>
|
|
<el-button type="primary" class="map-btn" @click="clickSureMap">确定</el-button>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <div v-show="showAddressList" class="address-list">
|
|
|
|
+ <div class="address" @click="getGeoCode(v)" v-for="(v,i) in promptList" :key="i">
|
|
|
|
+ <span class="name">{{v.name}}</span>
|
|
|
|
+ <span class="district">{{v.district}}{{v.address}}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</el-form>
|
|
</el-form>
|
|
<el-amap vid="container" :zoom="zoom" :center="center" style="height: 600px;" class="amap-demo">
|
|
<el-amap vid="container" :zoom="zoom" :center="center" style="height: 600px;" class="amap-demo">
|
|
<el-amap-marker v-for="(marker,index) in markers" :key="index" :position="marker.position" :icon="marker.icon"></el-amap-marker>
|
|
<el-amap-marker v-for="(marker,index) in markers" :key="index" :position="marker.position" :icon="marker.icon"></el-amap-marker>
|
|
@@ -28,6 +34,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import { getInputPrompt, getGeoCode } from "../../api/order.js";
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -35,52 +42,61 @@ export default {
|
|
dialogTableVisible: false,
|
|
dialogTableVisible: false,
|
|
order: {},
|
|
order: {},
|
|
markers: [],
|
|
markers: [],
|
|
- srcList: [],
|
|
|
|
- window: "",
|
|
|
|
- geocoder: "",
|
|
|
|
defaultCity: "苏州",
|
|
defaultCity: "苏州",
|
|
zoom: 18,
|
|
zoom: 18,
|
|
center: [121.329402, 31.228667],
|
|
center: [121.329402, 31.228667],
|
|
|
|
+ promptList: [],
|
|
address: "",
|
|
address: "",
|
|
- province: "",
|
|
|
|
- city: "",
|
|
|
|
- district: "",
|
|
|
|
|
|
+ addressDetail: {},
|
|
lng: "",
|
|
lng: "",
|
|
lat: "",
|
|
lat: "",
|
|
- addArr: {
|
|
|
|
- addr: {},
|
|
|
|
- },
|
|
|
|
|
|
+ showAddressList: false,
|
|
|
|
+ showSearch: false,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
- this.searchKey = this.defaultCity
|
|
|
|
- this.searchMap()
|
|
|
|
- },
|
|
|
|
|
|
+ created() {},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ getGeoCode(v) {
|
|
|
|
+ this.showAddressList = false;
|
|
|
|
+ let address = v.district + v.address + v.name;
|
|
|
|
+ getGeoCode({ address }).then((res) => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ console.log("object", res.data);
|
|
|
|
+ this.addressDetail = res.data[0];
|
|
|
|
+ let splitPoint = this.addressDetail.location.indexOf(",");
|
|
|
|
+ console.log("splitPoint", splitPoint);
|
|
|
|
+ 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,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
searchMap() {
|
|
searchMap() {
|
|
- fetch(
|
|
|
|
- `https://restapi.amap.com/v3/assistant/inputtips?key=5ae8644771ef9abf9cfb3ea23b1df6ca&keywords=${this.searchKey}&city=0512&offset=20&types=keywords`,
|
|
|
|
- {
|
|
|
|
- methods: "GET",
|
|
|
|
|
|
+ getInputPrompt({ keywords: this.searchKey }).then((res) => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ if (res.data.length) {
|
|
|
|
+ this.promptList = res.data;
|
|
|
|
+ this.showAddressList = true;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ type: "error",
|
|
|
|
+ message: res.msg,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- )
|
|
|
|
- .then((res) => {
|
|
|
|
- return res.json();
|
|
|
|
- })
|
|
|
|
- .then((result) => {
|
|
|
|
- fetch(
|
|
|
|
- `https://restapi.amap.com/v3/geocode/geo?key=4940f0a9fdc717ab27dd37fa0497c771&address=${result.tips[0].district}${result.tips[0].address}${result.tips[0].name}`,
|
|
|
|
- {
|
|
|
|
- methods: "GET",
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- .then((res1) => {
|
|
|
|
- return res1.json()
|
|
|
|
- })
|
|
|
|
- .then((rp) => {
|
|
|
|
- console.log('rp',rp);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
},
|
|
},
|
|
setDialogStatus(data, mapData) {
|
|
setDialogStatus(data, mapData) {
|
|
let sendM = {
|
|
let sendM = {
|
|
@@ -101,17 +117,21 @@ export default {
|
|
// marker标记
|
|
// marker标记
|
|
this.markers = [sendM, receiptM];
|
|
this.markers = [sendM, receiptM];
|
|
// 绘制折线
|
|
// 绘制折线
|
|
- this.polyline.path = [
|
|
|
|
- new AMap.LngLat(mapData.receiptLng, mapData.receiptLat),
|
|
|
|
- new AMap.LngLat(mapData.sendLng, mapData.sendLat),
|
|
|
|
- new AMap.LngLat(mapData.shipperLng, mapData.shipperLat),
|
|
|
|
- ];
|
|
|
|
|
|
+ // this.polyline.path = [
|
|
|
|
+ // new AMap.LngLat(mapData.receiptLng, mapData.receiptLat),
|
|
|
|
+ // new AMap.LngLat(mapData.sendLng, mapData.sendLat),
|
|
|
|
+ // new AMap.LngLat(mapData.shipperLng, mapData.shipperLat),
|
|
|
|
+ // ];
|
|
this.dialogTableVisible = true;
|
|
this.dialogTableVisible = true;
|
|
},
|
|
},
|
|
chooseLocation() {
|
|
chooseLocation() {
|
|
this.dialogTableVisible = true;
|
|
this.dialogTableVisible = true;
|
|
|
|
+ this.showSearch = true;
|
|
|
|
+ },
|
|
|
|
+ clickSureMap() {
|
|
|
|
+ this.$emit("getAddressDetail", this.addressDetail, this.lng, this.lat);
|
|
|
|
+ this.dialogTableVisible = false;
|
|
},
|
|
},
|
|
- clickSureMap() {},
|
|
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -122,8 +142,29 @@ export default {
|
|
border: none;
|
|
border: none;
|
|
}
|
|
}
|
|
.demo-form-inline {
|
|
.demo-form-inline {
|
|
|
|
+ position: relative;
|
|
display: flex;
|
|
display: flex;
|
|
align-items: center;
|
|
align-items: center;
|
|
|
|
+ .address-list {
|
|
|
|
+ position: absolute;
|
|
|
|
+ left: 0;
|
|
|
|
+ top: 45px;
|
|
|
|
+ border: 2px solid #3333;
|
|
|
|
+ background: #fff;
|
|
|
|
+ padding: 0 10px;
|
|
|
|
+ z-index: 2;
|
|
|
|
+ .address {
|
|
|
|
+ line-height: 30px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ .name {
|
|
|
|
+ color: #333333;
|
|
|
|
+ }
|
|
|
|
+ .district {
|
|
|
|
+ color: #999999;
|
|
|
|
+ margin-left: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/* 图标大小修改 */
|
|
/* 图标大小修改 */
|
|
/deep/ .el-dialog__header {
|
|
/deep/ .el-dialog__header {
|