Commit 3aeddf2c by 张杰

修复围栏bug

1 parent e5d57ecd
......@@ -155,4 +155,9 @@ export const GET_DEVICE_LOCATION = params => {
// 批量查询设备在线状态
export const GET_MONITOR_ONLINELIST = params => {
return request(params, '/devicemonitor/monitor/onlinelist', 'get')
}
// 获取高德地图的省市区
export const GET_AMAP_PROVINCE = params => {
return request(params, 'https://restapi.amap.com/v3/config/district', 'get')
}
\ No newline at end of file
......@@ -3,6 +3,9 @@
</template>
<script>
import cityJson from "@/assets/json/city.json";
import { CONSTANT } from "@/constant";
// import axios from "axios";
// import store from "@/vuex/store";
export default {
name: "CitySelect",
props: {
......@@ -41,6 +44,14 @@ export default {
// immediate: true,
// },
},
created() {
// 查询
// console.log(store);
// let list = store.state.common.provinceList;
// if (!list || list.length <= 0) {
// this.getList();
// }
},
mounted() {
//this.city = this.value;
this.init();
......@@ -49,18 +60,18 @@ export default {
onChange(e) {
console.log(e);
let list = this.cityList;
let nameList = []
let nameList = [];
let m = list.find((k) => k.code == e[0]);
console.log(m)
nameList.push(m.name)
console.log(m);
nameList.push(m.name);
let n = m.children.find((k) => k.code == e[1]);
let b = (n && n.children || []).find((k) => k.code == e[2]);
let b = ((n && n.children) || []).find((k) => k.code == e[2]);
if (n) {
this.$emit("input", n.name);
nameList.push(n.name)
nameList.push(n.name);
}
if(b){
nameList.push(b.name)
if (b) {
nameList.push(b.name);
}
this.$emit("change", { code: e, name: nameList });
},
......@@ -131,6 +142,26 @@ export default {
});
return afterArray;
},
// 查询高德地图的省市区
getList() {
let oParams = {};
oParams.key = CONSTANT.MAP_SERVICE_KEY;
oParams.subdistrict = 3;
oParams.keywords = "中国";
axios({
url: "https://restapi.amap.com/v3/config/district",
params: oParams,
}).then((res) => {
console.log(res);
let obj = res.data;
let { districts } = obj;
let list = districts[0] ? districts[0].districts : [];
console.log(list);
this.cityList = list;
store.commit('SET_AMAP_PROVINCE',list)
});
},
},
};
</script>
......
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_SERVICE_KEY = 'd22348363c34c266f772ae9b635eef2a'
// 地图插件
export const MAP_PLUGINS = [
......@@ -19,6 +20,7 @@ export const CONSTANT = {
//ROOT: process.env.NODE_ENV === 'development'?'ots/':'',
API_URL: '/ots/',
MAP_KEY,
MAP_SERVICE_KEY,
MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}`
}
\ No newline at end of file
......@@ -228,6 +228,11 @@ export default {
});
} else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
}
},
drawFenceCircle(fenceCenter) {
......
......@@ -21,6 +21,7 @@ const state = {
zlAccount: false,
permission: [],
vehicleGenerate: false,
provinceList:[], // 高德地图的省市区
}
const mutations = {
......@@ -84,6 +85,12 @@ const mutations = {
[types.vehicleGenerate](state, data) {
state.vehicleGenerate = data
},
// 高德地图的省市区
SET_AMAP_PROVINCE(state,data){
state.provinceList = data
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!