优化代码
This commit is contained in:
parent
2ec2dfb5b8
commit
eb69eb582d
@ -234,7 +234,7 @@
|
|||||||
//加载后
|
//加载后
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
mapContext = map.getMap("mapRef", getCurrentInstance());
|
mapContext = map.getMap("mapRef", getCurrentInstance());
|
||||||
getZone(() => {
|
getZone((arrData) => {
|
||||||
//获取当前定位
|
//获取当前定位
|
||||||
map.getLoalcation(mapContext, (res) => {
|
map.getLoalcation(mapContext, (res) => {
|
||||||
const {
|
const {
|
||||||
@ -265,8 +265,9 @@
|
|||||||
city: "当前定位" + city,
|
city: "当前定位" + city,
|
||||||
country: [data]
|
country: [data]
|
||||||
}
|
}
|
||||||
const arrData=arrAreaData.value||[];
|
arrData = arrData || [];
|
||||||
arrAreaData.value=arrData.splice(0, 0, locationPoint);
|
arrData.splice(0, 0, locationPoint);
|
||||||
|
arrAreaData.value = arrData;
|
||||||
changeArea(data);
|
changeArea(data);
|
||||||
}, (res) => {
|
}, (res) => {
|
||||||
showModelMessage("切换区域失败!");
|
showModelMessage("切换区域失败!");
|
||||||
@ -277,60 +278,59 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
//获取行政区划
|
//获取行政区划
|
||||||
const getZone = (callback) => {
|
function getZone(callback) {
|
||||||
api.callOperateApi("ebikeRegion/getZone", null, "get").then((res) => {
|
api.callOperateApi("ebikeRegion/getZone", null, "get").then((res) => {
|
||||||
|
const arrData = [];
|
||||||
const {
|
const {
|
||||||
code,
|
code,
|
||||||
data,
|
data,
|
||||||
message
|
message
|
||||||
} = res;
|
} = res;
|
||||||
if (code == 200) {
|
if (code != 200) {
|
||||||
const arrData = [];
|
|
||||||
if (data && data.length > 0) {
|
|
||||||
data.map(item => {
|
|
||||||
const {
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
lng,
|
|
||||||
lat,
|
|
||||||
cityName
|
|
||||||
} = item;
|
|
||||||
let index = findIndex(arrData, {
|
|
||||||
city: cityName
|
|
||||||
});
|
|
||||||
let oData = arrData[index];
|
|
||||||
const obj = {
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
lat,
|
|
||||||
lng
|
|
||||||
};
|
|
||||||
if (index == "-1") {
|
|
||||||
index = 0;
|
|
||||||
oData = {
|
|
||||||
city: cityName,
|
|
||||||
country: [obj]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
oData["country"].push(obj);
|
|
||||||
}
|
|
||||||
arrData[index] = oData;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (locationPoint) {
|
|
||||||
arrData.splice(0, 0, locationPoint);
|
|
||||||
}
|
|
||||||
arrAreaData.value = arrData;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
showModelMessage(message);
|
showModelMessage(message);
|
||||||
|
if(callback) callback(arrData);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
callback();
|
if (data && data.length > 0) {
|
||||||
|
data.map(item => {
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
lng,
|
||||||
|
lat,
|
||||||
|
cityName
|
||||||
|
} = item;
|
||||||
|
let index = findIndex(arrData, {
|
||||||
|
city: cityName
|
||||||
|
});
|
||||||
|
let oData = arrData[index];
|
||||||
|
const obj = {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
lat,
|
||||||
|
lng
|
||||||
|
};
|
||||||
|
if (index == "-1") {
|
||||||
|
index = 0;
|
||||||
|
oData = {
|
||||||
|
city: cityName,
|
||||||
|
country: [obj]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oData["country"].push(obj);
|
||||||
|
}
|
||||||
|
arrData[index] = oData;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (locationPoint) {
|
||||||
|
arrData.splice(0, 0, locationPoint);
|
||||||
|
}
|
||||||
|
if(callback) callback(arrData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//定位
|
//定位
|
||||||
const getLocation = () => {
|
function getLocation() {
|
||||||
map.getLoalcation(mapContext, (res) => {
|
map.getLoalcation(mapContext, (res) => {
|
||||||
const {
|
const {
|
||||||
latitude,
|
latitude,
|
||||||
@ -341,18 +341,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//显示区域
|
//显示区域
|
||||||
const onShowDrawer = () => {
|
function onShowDrawer() {
|
||||||
showArea.value.open();
|
showArea.value.open();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//切换区域
|
//切换区域
|
||||||
const clickArea = (data) => {
|
function clickArea(data) {
|
||||||
changeArea(data);
|
changeArea(data);
|
||||||
showArea.value.close();
|
showArea.value.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeArea = (data, refresh) => {
|
function changeArea(data, refresh) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
lng,
|
lng,
|
||||||
@ -472,13 +472,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//地图数据
|
//地图数据
|
||||||
const loadMapData = (data) => {
|
function loadMapData(data) {
|
||||||
loadMapBikeData(showBike.value, data);
|
loadMapBikeData(showBike.value, data);
|
||||||
loadMapRegionData(showRegion.value, data);
|
loadMapRegionData(showRegion.value, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//显示隐藏车辆
|
//显示隐藏车辆
|
||||||
const showBikeData = () => {
|
function showBikeData() {
|
||||||
const show = !showBike.value
|
const show = !showBike.value
|
||||||
showBike.value = show;
|
showBike.value = show;
|
||||||
const {
|
const {
|
||||||
@ -491,7 +491,7 @@
|
|||||||
loadMapBikeData(show, data);
|
loadMapBikeData(show, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadMapBikeData = (show, data) => {
|
function loadMapBikeData(show, data) {
|
||||||
const {
|
const {
|
||||||
bikeData
|
bikeData
|
||||||
} = data;
|
} = data;
|
||||||
@ -509,7 +509,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//显示隐藏站点
|
//显示隐藏站点
|
||||||
const showRegionData = () => {
|
function showRegionData() {
|
||||||
const show = !showRegion.value;
|
const show = !showRegion.value;
|
||||||
showRegion.value = show;
|
showRegion.value = show;
|
||||||
const {
|
const {
|
||||||
@ -519,10 +519,10 @@
|
|||||||
zoneId: id
|
zoneId: id
|
||||||
});
|
});
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
loadMapRegionData(show,data);
|
loadMapRegionData(show, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadMapRegionData = (show, data) => {
|
function loadMapRegionData(show, data) {
|
||||||
const {
|
const {
|
||||||
arrCircles,
|
arrCircles,
|
||||||
arrPolygons,
|
arrPolygons,
|
||||||
@ -540,13 +540,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
//刷新
|
//刷新
|
||||||
const refreshArea = () => {
|
function refreshArea() {
|
||||||
changeArea(selArea, true);
|
changeArea(selArea, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//缩放
|
//缩放
|
||||||
const onZoom = (lx) => {
|
function onZoom(lx) {
|
||||||
switch (lx) {
|
switch (lx) {
|
||||||
case "out":
|
case "out":
|
||||||
scale.value = scale.value + 1;
|
scale.value = scale.value + 1;
|
||||||
@ -558,7 +558,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//电量筛选
|
//电量筛选
|
||||||
const quantityChange = (e) => {
|
function quantityChange(e) {
|
||||||
const {
|
const {
|
||||||
detail: {
|
detail: {
|
||||||
value
|
value
|
||||||
@ -576,12 +576,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//批量换电
|
//批量换电
|
||||||
const changeBatteries = () => {
|
function changeBatteries() {
|
||||||
showModelMessage("该功能暂未实现!");
|
showModelMessage("该功能暂未实现!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询工单
|
//查询工单
|
||||||
const queryOrders = (lx) => {
|
function queryOrders(lx) {
|
||||||
showModelMessage("该功能暂未实现!");
|
showModelMessage("该功能暂未实现!");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user