553 lines
16 KiB
JavaScript
553 lines
16 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_map = require("../../utils/map.js");
|
|
const utils_tools = require("../../utils/tools.js");
|
|
const utils_api = require("../../utils/api.js");
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
const _easycom_uni_col2 = common_vendor.resolveComponent("uni-col");
|
|
const _easycom_uni_row2 = common_vendor.resolveComponent("uni-row");
|
|
const _easycom_uni_drawer2 = common_vendor.resolveComponent("uni-drawer");
|
|
(_easycom_uni_icons2 + _easycom_uni_col2 + _easycom_uni_row2 + _easycom_uni_drawer2)();
|
|
}
|
|
const _easycom_uni_icons = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js";
|
|
const _easycom_uni_col = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-col/uni-col.js";
|
|
const _easycom_uni_row = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-row/uni-row.js";
|
|
const _easycom_uni_drawer = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-drawer/uni-drawer.js";
|
|
if (!Math) {
|
|
(_easycom_uni_icons + _easycom_uni_col + _easycom_uni_row + _easycom_uni_drawer)();
|
|
}
|
|
const iconsize = 16;
|
|
const iconcolor = "#6f7777";
|
|
const color_down = "#EF4B4D";
|
|
const color_middle = "#F29710";
|
|
const color_high = "#3DB71A";
|
|
const showColor = "#1088FD";
|
|
const _sfc_main = {
|
|
__name: "home",
|
|
setup(__props) {
|
|
var qqmapsdk = new common_vendor.QQMapWX({
|
|
key: utils_map.sdkKey
|
|
});
|
|
const arrRight = common_vendor.ref([
|
|
{
|
|
name: "换电",
|
|
lx: "changebatteries"
|
|
},
|
|
{
|
|
name: "调度",
|
|
lx: "deploy"
|
|
},
|
|
{
|
|
name: "维修",
|
|
lx: "maintenance"
|
|
},
|
|
{
|
|
name: "巡检",
|
|
lx: "xj"
|
|
},
|
|
{
|
|
name: "全部",
|
|
lx: "all"
|
|
}
|
|
]);
|
|
const selRight = common_vendor.ref(0);
|
|
common_vendor.ref("mapRef");
|
|
let mapContext = null;
|
|
const showArea = common_vendor.ref(null);
|
|
const mapcenter = common_vendor.ref({
|
|
longitude: null,
|
|
latitude: null
|
|
});
|
|
const scale = common_vendor.ref(13);
|
|
const markers = common_vendor.ref([]);
|
|
const polygons = common_vendor.ref([]);
|
|
common_vendor.ref([]);
|
|
const circles = common_vendor.ref([]);
|
|
const orderCount = common_vendor.ref(0);
|
|
const quantityCount = common_vendor.ref(100);
|
|
const quantityColor = common_vendor.ref(color_high);
|
|
let locationPoint = null;
|
|
const arrAreaData = common_vendor.ref(null);
|
|
const mapData_opt = [];
|
|
let selArea = null;
|
|
const showMore = common_vendor.ref(false);
|
|
const showBike = common_vendor.ref(true);
|
|
const showRegion = common_vendor.ref(false);
|
|
common_vendor.onMounted(() => {
|
|
mapContext = utils_map.getMap("mapRef", common_vendor.getCurrentInstance());
|
|
getZone(() => {
|
|
utils_map.getLoalcation(mapContext, (res) => {
|
|
const {
|
|
latitude: lat,
|
|
longitude: lng
|
|
} = res;
|
|
mapcenter.value = {
|
|
latitude: lat,
|
|
longitude: lng
|
|
};
|
|
utils_map.reverseGeocoder(qqmapsdk, lng, lat, (res2) => {
|
|
const {
|
|
ad_info: {
|
|
adcode,
|
|
city,
|
|
district
|
|
}
|
|
} = res2;
|
|
const data = {
|
|
id: adcode,
|
|
name: district,
|
|
lat,
|
|
lng
|
|
};
|
|
locationPoint = {
|
|
city: "当前定位" + city,
|
|
country: [data]
|
|
};
|
|
const arrData = arrAreaData.value || [];
|
|
arrAreaData.value = arrData.splice(0, 0, locationPoint);
|
|
changeArea(data);
|
|
}, (res2) => {
|
|
utils_tools.showModelMessage("切换区域失败!");
|
|
});
|
|
});
|
|
});
|
|
});
|
|
const getZone = (callback) => {
|
|
utils_api.callOperateApi("ebikeRegion/getZone", null, "get").then((res) => {
|
|
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 = common_vendor.lodashExports.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 {
|
|
utils_tools.showModelMessage(message);
|
|
}
|
|
callback();
|
|
});
|
|
};
|
|
const getLocation = () => {
|
|
utils_map.getLoalcation(mapContext, (res) => {
|
|
});
|
|
};
|
|
const onShowDrawer = () => {
|
|
showArea.value.open();
|
|
};
|
|
const clickArea = (data) => {
|
|
changeArea(data);
|
|
showArea.value.close();
|
|
};
|
|
const changeArea = (data, refresh) => {
|
|
const {
|
|
id,
|
|
lng,
|
|
lat
|
|
} = data;
|
|
selArea = data;
|
|
const zoneId = id;
|
|
mapcenter.value = {
|
|
latitude: lat,
|
|
longitude: lng
|
|
};
|
|
let mapDataIndex = common_vendor.lodashExports.findIndex(mapData_opt, {
|
|
zoneId
|
|
});
|
|
if (!refresh) {
|
|
if (mapDataIndex > -1) {
|
|
loadMapData(mapData_opt[mapDataIndex]);
|
|
return;
|
|
}
|
|
}
|
|
common_vendor.index.showLoading({
|
|
title: "加载中"
|
|
});
|
|
const params = {
|
|
zoneId
|
|
};
|
|
utils_api.callOperateApi("ebikeRegion/getOperation", params, "get").then((res) => {
|
|
common_vendor.index.hideLoading();
|
|
const {
|
|
code,
|
|
message,
|
|
data: data2
|
|
} = res;
|
|
if (code == 200) {
|
|
const arrCircles = [];
|
|
const arrPolygons = [];
|
|
const arrRegionID = [];
|
|
data2.map((item, index) => {
|
|
const {
|
|
shapeType,
|
|
regionId,
|
|
radius,
|
|
points
|
|
} = item;
|
|
arrRegionID.push(regionId);
|
|
const scolor = "#578FD4";
|
|
const fcolor = "#C0DAF5";
|
|
if (shapeType == 1) {
|
|
const {
|
|
longitude: lng2,
|
|
latitude: lat2
|
|
} = points[0];
|
|
arrCircles.push(utils_map.addCirle(scolor, fcolor, lng2, lat2, radius));
|
|
} else if (shapeType == 2) {
|
|
const arrPoint = points.map((p) => {
|
|
return {
|
|
longitude: p.longitude,
|
|
latitude: p.latitude
|
|
};
|
|
});
|
|
arrPolygons.push(utils_map.addPolygon(scolor, fcolor, arrPoint));
|
|
}
|
|
});
|
|
let mapdata = {
|
|
zoneId,
|
|
arrCircles,
|
|
arrPolygons,
|
|
arrData: data2
|
|
};
|
|
polygons.value = arrPolygons;
|
|
circles.value = arrCircles;
|
|
mapDataIndex = mapDataIndex == -1 ? mapData_opt.length : mapDataIndex;
|
|
mapData_opt[mapDataIndex] = mapdata;
|
|
if (arrRegionID.length == 0)
|
|
return;
|
|
utils_map.getRegionData(arrRegionID, (res2) => {
|
|
const {
|
|
arrData,
|
|
arrCircles: arrCircles2,
|
|
arrPolygons: arrPolygons2
|
|
} = res2;
|
|
mapdata = {
|
|
...mapdata,
|
|
regionData: {
|
|
arrData,
|
|
arrCircles: arrCircles2,
|
|
arrPolygons: arrPolygons2
|
|
}
|
|
};
|
|
mapData_opt[mapDataIndex] = mapdata;
|
|
loadMapRegionData(showRegion.value, mapdata);
|
|
if (arrRegionID.length == 0)
|
|
return;
|
|
utils_map.getBikeData(arrRegionID, (res3) => {
|
|
const {
|
|
arrData: arrData2,
|
|
arrPoints
|
|
} = res3;
|
|
mapdata = {
|
|
...mapdata,
|
|
bikeData: {
|
|
arrData: arrData2,
|
|
arrPoints
|
|
}
|
|
};
|
|
mapData_opt[mapDataIndex] = mapdata;
|
|
loadMapBikeData(showBike.value, mapdata);
|
|
});
|
|
});
|
|
} else {
|
|
utils_tools.showModelMessage(message);
|
|
}
|
|
});
|
|
};
|
|
const loadMapData = (data) => {
|
|
loadMapBikeData(showBike.value, data);
|
|
loadMapRegionData(showRegion.value, data);
|
|
};
|
|
const showBikeData = () => {
|
|
const show = !showBike.value;
|
|
showBike.value = show;
|
|
const {
|
|
id
|
|
} = selArea;
|
|
const data = common_vendor.lodashExports.find(mapData_opt, {
|
|
zoneId: id
|
|
});
|
|
if (!data)
|
|
return;
|
|
loadMapBikeData(show, data);
|
|
};
|
|
const loadMapBikeData = (show, data) => {
|
|
const {
|
|
bikeData
|
|
} = data;
|
|
if (show) {
|
|
if (bikeData) {
|
|
const {
|
|
arrData,
|
|
arrPoints
|
|
} = bikeData;
|
|
markers.value = arrPoints;
|
|
return;
|
|
}
|
|
}
|
|
markers.value = [];
|
|
};
|
|
const showRegionData = () => {
|
|
const show = !showRegion.value;
|
|
showRegion.value = show;
|
|
const {
|
|
id
|
|
} = selArea;
|
|
const data = common_vendor.lodashExports.find(mapData_opt, {
|
|
zoneId: id
|
|
});
|
|
if (!data)
|
|
return;
|
|
loadMapRegionData(show, data);
|
|
};
|
|
const loadMapRegionData = (show, data) => {
|
|
const {
|
|
arrCircles,
|
|
arrPolygons,
|
|
regionData
|
|
} = data;
|
|
if (show) {
|
|
if (regionData) {
|
|
polygons.value = [...arrPolygons, ...regionData.arrPolygons];
|
|
circles.value = [...arrCircles, ...regionData.arrCircles];
|
|
return;
|
|
}
|
|
}
|
|
polygons.value = arrPolygons;
|
|
circles.value = arrCircles;
|
|
};
|
|
const refreshArea = () => {
|
|
changeArea(selArea, true);
|
|
};
|
|
const onZoom = (lx) => {
|
|
switch (lx) {
|
|
case "out":
|
|
scale.value = scale.value + 1;
|
|
break;
|
|
case "in":
|
|
scale.value = scale.value - 1;
|
|
break;
|
|
}
|
|
};
|
|
const quantityChange = (e) => {
|
|
const {
|
|
detail: {
|
|
value
|
|
}
|
|
} = e;
|
|
quantityCount.value = value;
|
|
if (value <= 20) {
|
|
quantityColor.value = color_down;
|
|
} else if (value <= 60) {
|
|
quantityColor.value = color_middle;
|
|
} else {
|
|
quantityColor.value = color_high;
|
|
}
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
};
|
|
const changeBatteries = () => {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
};
|
|
const queryOrders = (lx) => {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.f(arrRight.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.name),
|
|
b: common_vendor.n(selRight.value == index ? "divHeadSel" : ""),
|
|
c: index,
|
|
d: common_vendor.o(queryOrders, index)
|
|
};
|
|
}),
|
|
b: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikeqiehuan",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
c: common_vendor.o(onShowDrawer),
|
|
d: common_vendor.p({
|
|
span: 8
|
|
}),
|
|
e: common_vendor.t(orderCount.value),
|
|
f: common_vendor.p({
|
|
span: 14
|
|
}),
|
|
g: common_vendor.o(($event) => onZoom("out")),
|
|
h: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikejia",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
i: common_vendor.o(($event) => onZoom("in")),
|
|
j: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikejian",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
k: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedingwei2",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
l: common_vendor.o(getLocation),
|
|
m: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikeshuaxin",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
n: common_vendor.o(refreshArea),
|
|
o: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikea-gengduo3x",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
p: common_vendor.o(() => {
|
|
showMore.value = !showMore.value;
|
|
}),
|
|
q: showMore.value
|
|
}, showMore.value ? {
|
|
r: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikeP",
|
|
color: showRegion.value ? showColor : iconcolor,
|
|
size: iconsize
|
|
}),
|
|
s: showRegion.value ? showColor : iconcolor,
|
|
t: common_vendor.o(showRegionData),
|
|
v: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedianpingchechongdianzhuang",
|
|
color: showBike.value ? showColor : iconcolor,
|
|
size: iconsize
|
|
}),
|
|
w: showBike.value ? showColor : iconcolor,
|
|
x: common_vendor.o(showBikeData)
|
|
} : {}, {
|
|
y: common_vendor.p({
|
|
type: "scan",
|
|
color: iconcolor,
|
|
size: iconsize
|
|
}),
|
|
z: common_vendor.o(changeBatteries),
|
|
A: color_down,
|
|
B: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedianliang",
|
|
color: color_down,
|
|
size: iconsize
|
|
}),
|
|
C: common_vendor.p({
|
|
span: 8
|
|
}),
|
|
D: color_middle,
|
|
E: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedianliang1",
|
|
color: color_middle,
|
|
size: iconsize
|
|
}),
|
|
F: common_vendor.p({
|
|
span: 8
|
|
}),
|
|
G: color_high,
|
|
H: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedianliang2",
|
|
color: color_high,
|
|
size: iconsize
|
|
}),
|
|
I: common_vendor.p({
|
|
span: 8
|
|
}),
|
|
J: common_vendor.p({
|
|
span: 6
|
|
}),
|
|
K: quantityCount.value,
|
|
L: quantityColor.value,
|
|
M: quantityColor.value,
|
|
N: common_vendor.o(quantityChange),
|
|
O: common_vendor.p({
|
|
span: 16
|
|
}),
|
|
P: common_vendor.f(arrAreaData.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.city),
|
|
b: common_vendor.f(item.country, (data, indexd, i1) => {
|
|
return {
|
|
a: common_vendor.t(data.name),
|
|
b: common_vendor.o(($event) => clickArea(data), indexd),
|
|
c: indexd,
|
|
d: "07e72d3c-24-" + i0 + "-" + i1 + "," + ("07e72d3c-23-" + i0)
|
|
};
|
|
}),
|
|
c: "07e72d3c-23-" + i0 + ",07e72d3c-22",
|
|
d: index
|
|
};
|
|
}),
|
|
Q: common_vendor.p({
|
|
span: 12
|
|
}),
|
|
R: common_vendor.sr(showArea, "07e72d3c-22", {
|
|
"k": "showArea"
|
|
}),
|
|
S: common_vendor.p({
|
|
mode: "right",
|
|
width: 300
|
|
}),
|
|
T: scale.value,
|
|
U: markers.value,
|
|
V: mapcenter.value.longitude,
|
|
W: mapcenter.value.latitude,
|
|
X: circles.value,
|
|
Y: polygons.value
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-07e72d3c"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/home/home.js.map
|