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