|
@@ -127,7 +127,6 @@
|
|
|
:scale="mapProps.scale"
|
|
:scale="mapProps.scale"
|
|
|
@regionchange="mapChange"
|
|
@regionchange="mapChange"
|
|
|
@updated="mapUpdated"
|
|
@updated="mapUpdated"
|
|
|
- @labeltap="tapMarker"
|
|
|
|
|
@markertap="tapMarker"
|
|
@markertap="tapMarker"
|
|
|
:show-scale="true"
|
|
:show-scale="true"
|
|
|
></map>
|
|
></map>
|
|
@@ -269,11 +268,9 @@ const defaultScale = 12;
|
|
|
const pointSize = {
|
|
const pointSize = {
|
|
|
width: 30,
|
|
width: 30,
|
|
|
height: 55,
|
|
height: 55,
|
|
|
- fontSize: 7,
|
|
|
|
|
iconPath: "/static/images/map-point.png",
|
|
iconPath: "/static/images/map-point.png",
|
|
|
currentWidth: 42,
|
|
currentWidth: 42,
|
|
|
currentHeight: 72,
|
|
currentHeight: 72,
|
|
|
- currentFontSize: 10,
|
|
|
|
|
currentIconPath: "/static/images/map-point-current.png",
|
|
currentIconPath: "/static/images/map-point-current.png",
|
|
|
androidX:-4,
|
|
androidX:-4,
|
|
|
androidCurrentX: -7,
|
|
androidCurrentX: -7,
|
|
@@ -282,15 +279,14 @@ import { fetchHomeBanner } from "@/api";
|
|
|
import { deCode } from "../../utils/code";
|
|
import { deCode } from "../../utils/code";
|
|
|
import { rpxToPx } from "../../utils/device";
|
|
import { rpxToPx } from "../../utils/device";
|
|
|
import { fetchToken, onLogin } from "@/api/auth";
|
|
import { fetchToken, onLogin } from "@/api/auth";
|
|
|
-import { fetchStations, fetchChargeStatus } from "@/api/charge";
|
|
|
|
|
|
|
+import { fetchMapStations, fetchStationCards, fetchChargeStatus } from "@/api/charge";
|
|
|
import { fetchCollectList } from "@/api/user";
|
|
import { fetchCollectList } from "@/api/user";
|
|
|
import { fetchLocation } from "@/utils/location";
|
|
import { fetchLocation } from "@/utils/location";
|
|
|
import { to } from "@/utils/navigate";
|
|
import { to } from "@/utils/navigate";
|
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
-import { ref } from "vue";
|
|
|
|
|
|
|
+import { ref, watch } from "vue";
|
|
|
|
|
|
|
|
-const currentLocation = ref(null)
|
|
|
|
|
-const isIOS = ref(false);
|
|
|
|
|
|
|
+const currentLocation = ref<any>(null)
|
|
|
const token = ref<string>();
|
|
const token = ref<string>();
|
|
|
const ready = ref(false);
|
|
const ready = ref(false);
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
@@ -364,11 +360,6 @@ const filterDialog = ref({
|
|
|
],
|
|
],
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const stationPage = ref({
|
|
|
|
|
- page: 1,
|
|
|
|
|
- pageSize: 6,
|
|
|
|
|
- hasNext: false,
|
|
|
|
|
-});
|
|
|
|
|
const station = ref<any[]>([]);
|
|
const station = ref<any[]>([]);
|
|
|
const charging = ref<any>();
|
|
const charging = ref<any>();
|
|
|
|
|
|
|
@@ -387,92 +378,42 @@ const mapBanner = ref<any[]>([]);
|
|
|
let isIgnoreChangeLocation = false;
|
|
let isIgnoreChangeLocation = false;
|
|
|
|
|
|
|
|
const refreshStation = (location: any) => {
|
|
const refreshStation = (location: any) => {
|
|
|
- let length = 0;
|
|
|
|
|
- let available = 0;
|
|
|
|
|
const { latitude, longitude } = location;
|
|
const { latitude, longitude } = location;
|
|
|
- return fetchStations(
|
|
|
|
|
- stationPage.value.page,
|
|
|
|
|
- stationPage.value.pageSize,
|
|
|
|
|
|
|
+ // 轻量接口:仅站点基础信息,地图拖动时走缓存本地重排序,不再请求后台
|
|
|
|
|
+ return fetchMapStations(
|
|
|
latitude,
|
|
latitude,
|
|
|
longitude,
|
|
longitude,
|
|
|
mapProps.value.selflatitude,
|
|
mapProps.value.selflatitude,
|
|
|
- mapProps.value.selflongitude,
|
|
|
|
|
- {
|
|
|
|
|
- distance: filterDialog.value.options.distance,
|
|
|
|
|
- status: filterDialog.value.options.status,
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mapProps.value.selflongitude
|
|
|
).then((res) => {
|
|
).then((res) => {
|
|
|
- const _markersIndex = stationPage.value.page === 1 ? 0 : markersIndex.value;
|
|
|
|
|
- // console.log("xxxxx",res)
|
|
|
|
|
- const _markers: any[] = res.map((item, index) => {
|
|
|
|
|
- item.totalFee =(Number(item.currentPolicyInfo?.servicePrice||0)+Number(item.currentPolicyInfo?.elecPrice||0)).toFixed(2)
|
|
|
|
|
- length = 0;
|
|
|
|
|
- available = 0;
|
|
|
|
|
- // item.equipmentInfos &&
|
|
|
|
|
- // item.equipmentInfos.forEach((eq: any) => {
|
|
|
|
|
- // eq.connectorInfos &&
|
|
|
|
|
- // eq.connectorInfos.forEach((co: any) => {
|
|
|
|
|
- // length += 1;
|
|
|
|
|
- // if (
|
|
|
|
|
- // co.connectorStatusInfo &&
|
|
|
|
|
- // co.connectorStatusInfo.status === 1
|
|
|
|
|
- // ) {
|
|
|
|
|
- // available += 1;
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ const _markers: any[] = res.map((item: any, index: number) => {
|
|
|
|
|
+ item.totalFee = (Number(item.currentPolicyInfo?.servicePrice||0)+Number(item.currentPolicyInfo?.elecPrice||0)).toFixed(2)
|
|
|
return {
|
|
return {
|
|
|
id: Number(item.StationID),
|
|
id: Number(item.StationID),
|
|
|
- // (Number()+Number(item.electricityFee)||0).toFixed(2),
|
|
|
|
|
latitude: item.location.stationLat,
|
|
latitude: item.location.stationLat,
|
|
|
longitude: item.location.stationLng,
|
|
longitude: item.location.stationLng,
|
|
|
iconPath:
|
|
iconPath:
|
|
|
- index === _markersIndex
|
|
|
|
|
|
|
+ index === 0
|
|
|
? pointSize.currentIconPath
|
|
? pointSize.currentIconPath
|
|
|
: pointSize.iconPath,
|
|
: pointSize.iconPath,
|
|
|
- width:
|
|
|
|
|
- index === _markersIndex ? pointSize.currentWidth : pointSize.width,
|
|
|
|
|
- height:
|
|
|
|
|
- index === _markersIndex ? pointSize.currentHeight : pointSize.height,
|
|
|
|
|
- label: {
|
|
|
|
|
- content: `${item.availableParkingNum||0}/${item.parkingNum||0}`,
|
|
|
|
|
- // content: `1/10`,
|
|
|
|
|
- color: "#ffffff",
|
|
|
|
|
- fontSize:
|
|
|
|
|
- index === _markersIndex
|
|
|
|
|
- ? pointSize.currentFontSize
|
|
|
|
|
- : pointSize.fontSize,
|
|
|
|
|
- textAlign: isIOS.value ? "center" : "left",
|
|
|
|
|
- anchorX: isIOS.value
|
|
|
|
|
- ? 0
|
|
|
|
|
- : index === _markersIndex
|
|
|
|
|
- ? -17 // 针对安卓设备调整 anchorX 实现居中
|
|
|
|
|
- : -10,
|
|
|
|
|
- anchorY: -(
|
|
|
|
|
- (index === _markersIndex
|
|
|
|
|
- ? pointSize.currentHeight
|
|
|
|
|
- : pointSize.height- 3)
|
|
|
|
|
- ),
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ width: index === 0 ? pointSize.currentWidth : pointSize.width,
|
|
|
|
|
+ height: index === 0 ? pointSize.currentHeight : pointSize.height,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
- if (stationPage.value.page === 1) {
|
|
|
|
|
- _markers.push({
|
|
|
|
|
- id: -1,
|
|
|
|
|
- latitude: mapProps.value.selflatitude,
|
|
|
|
|
- longitude: mapProps.value.selflongitude,
|
|
|
|
|
- iconPath: "/static/images/map-current.png",
|
|
|
|
|
- width: 34,
|
|
|
|
|
- height: 34,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ _markers.push({
|
|
|
|
|
+ id: -1,
|
|
|
|
|
+ latitude: mapProps.value.selflatitude,
|
|
|
|
|
+ longitude: mapProps.value.selflongitude,
|
|
|
|
|
+ iconPath: "/static/images/map-current.png",
|
|
|
|
|
+ width: 34,
|
|
|
|
|
+ height: 34,
|
|
|
|
|
+ });
|
|
|
isIgnoreChangeLocation = markers.value.length !== _markers.length;
|
|
isIgnoreChangeLocation = markers.value.length !== _markers.length;
|
|
|
- stationPage.value.hasNext = res.length >= stationPage.value.pageSize;
|
|
|
|
|
- // empty.value = stationPage.value.page === 1 ? res.length <= 0 : false;
|
|
|
|
|
- station.value =
|
|
|
|
|
- stationPage.value.page === 1 ? res : [...station.value, ...res];
|
|
|
|
|
- markersIndex.value = _markersIndex;
|
|
|
|
|
|
|
+ station.value = res;
|
|
|
|
|
+ markersIndex.value = 0;
|
|
|
markers.value = _markers;
|
|
markers.value = _markers;
|
|
|
|
|
+ // 默认选中距离最近的站点,按需加载其卡片详情(空闲数/活动)
|
|
|
|
|
+ loadStationCard(0);
|
|
|
return res;
|
|
return res;
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
@@ -486,8 +427,6 @@ const refresh = () => {
|
|
|
title: "加载中",
|
|
title: "加载中",
|
|
|
});
|
|
});
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
- stationPage.value.page = 1;
|
|
|
|
|
- stationPage.value.hasNext = false;
|
|
|
|
|
station.value = [];
|
|
station.value = [];
|
|
|
markers.value = [];
|
|
markers.value = [];
|
|
|
markersIndex.value = 0;
|
|
markersIndex.value = 0;
|
|
@@ -549,8 +488,6 @@ onLoad((query: any) => {
|
|
|
console.log("扫普通码", decodeURIComponent(query.q));
|
|
console.log("扫普通码", decodeURIComponent(query.q));
|
|
|
getApp<any>().globalData.normalCode = decodeURIComponent(query.q); // 获取到二维码原始链接内容
|
|
getApp<any>().globalData.normalCode = decodeURIComponent(query.q); // 获取到二维码原始链接内容
|
|
|
}
|
|
}
|
|
|
- const device = uni.getSystemInfoSync();
|
|
|
|
|
- isIOS.value = device.osName === "ios";
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
token.value = getApp<any>().globalData.token || "";
|
|
token.value = getApp<any>().globalData.token || "";
|
|
@@ -690,7 +627,6 @@ const mapChange = (e: any) => {
|
|
|
|
|
|
|
|
const debounceRefreshStation = throttle(() => {
|
|
const debounceRefreshStation = throttle(() => {
|
|
|
const { latitude, longitude } = currentLocation.value;
|
|
const { latitude, longitude } = currentLocation.value;
|
|
|
- stationPage.value.page = 1;
|
|
|
|
|
console.log("debounceRefreshStation run...")
|
|
console.log("debounceRefreshStation run...")
|
|
|
refreshStation({
|
|
refreshStation({
|
|
|
latitude,
|
|
latitude,
|
|
@@ -698,35 +634,90 @@ const debounceRefreshStation = throttle(() => {
|
|
|
});
|
|
});
|
|
|
}, 500)
|
|
}, 500)
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 按需加载单个站点卡片详情(空闲桩数量/活动),点击站点图标时调用
|
|
|
|
|
+ */
|
|
|
|
|
+const loadStationCard = (index: number) => {
|
|
|
|
|
+ const item = station.value[index];
|
|
|
|
|
+ if (!item || item.cardLoaded) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ item.cardLoaded = true; // 先标记防止重复请求,失败时回滚
|
|
|
|
|
+ fetchStationCards([item.StationID])
|
|
|
|
|
+ .then((cards: any[]) => {
|
|
|
|
|
+ const card = cards.find(
|
|
|
|
|
+ (c: any) => Number(c.stationId) === Number(item.StationID)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (card) {
|
|
|
|
|
+ item.availableParkingNum = card.availableParkingNum;
|
|
|
|
|
+ item.activityList = card.activityList;
|
|
|
|
|
+ if (card.parkingNum != null) {
|
|
|
|
|
+ item.parkingNum = card.parkingNum;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ item.cardLoaded = false;
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 展开列表模式时,批量加载尚未加载详情的站点卡片(空闲桩数量/活动)
|
|
|
|
|
+ */
|
|
|
|
|
+const loadAllStationCards = () => {
|
|
|
|
|
+ const ids = station.value
|
|
|
|
|
+ .filter((item: any) => !item.cardLoaded)
|
|
|
|
|
+ .map((item: any) => item.StationID);
|
|
|
|
|
+ if (!ids.length) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ station.value.forEach((item: any) => (item.cardLoaded = true));
|
|
|
|
|
+ fetchStationCards(ids)
|
|
|
|
|
+ .then((cards: any[]) => {
|
|
|
|
|
+ cards.forEach((card: any) => {
|
|
|
|
|
+ const item = station.value.find(
|
|
|
|
|
+ (s: any) => Number(s.StationID) === Number(card.stationId)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ item.availableParkingNum = card.availableParkingNum;
|
|
|
|
|
+ item.activityList = card.activityList;
|
|
|
|
|
+ if (card.parkingNum != null) {
|
|
|
|
|
+ item.parkingNum = card.parkingNum;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ // 失败时回滚未加载站点的标记,允许下次重试
|
|
|
|
|
+ station.value.forEach((item: any) => {
|
|
|
|
|
+ if (item.availableParkingNum == null) {
|
|
|
|
|
+ item.cardLoaded = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 下拉展开列表时批量补齐卡片详情
|
|
|
|
|
+watch(mapMode, (val) => {
|
|
|
|
|
+ if (!val) {
|
|
|
|
|
+ loadAllStationCards();
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const _changeMarker = (current: number) => {
|
|
const _changeMarker = (current: number) => {
|
|
|
const _markers = JSON.parse(JSON.stringify(markers.value));
|
|
const _markers = JSON.parse(JSON.stringify(markers.value));
|
|
|
const markersNewIndex = current;
|
|
const markersNewIndex = current;
|
|
|
_markers[markersIndex.value].iconPath = pointSize.iconPath;
|
|
_markers[markersIndex.value].iconPath = pointSize.iconPath;
|
|
|
_markers[markersIndex.value].width = pointSize.width;
|
|
_markers[markersIndex.value].width = pointSize.width;
|
|
|
_markers[markersIndex.value].height = pointSize.height;
|
|
_markers[markersIndex.value].height = pointSize.height;
|
|
|
- _markers[markersIndex.value].label.fontSize = pointSize.fontSize;
|
|
|
|
|
- _markers[markersIndex.value].label.anchorY = -(pointSize.height - 3);
|
|
|
|
|
- _markers[markersIndex.value].label.textAlign = isIOS.value ? "center" : "left";
|
|
|
|
|
- _markers[markersIndex.value].label.anchorX = isIOS.value ? 0 : -10;
|
|
|
|
|
|
|
|
|
|
_markers[markersNewIndex].iconPath = pointSize.currentIconPath;
|
|
_markers[markersNewIndex].iconPath = pointSize.currentIconPath;
|
|
|
_markers[markersNewIndex].width = pointSize.currentWidth;
|
|
_markers[markersNewIndex].width = pointSize.currentWidth;
|
|
|
_markers[markersNewIndex].height = pointSize.currentHeight;
|
|
_markers[markersNewIndex].height = pointSize.currentHeight;
|
|
|
- _markers[markersNewIndex].label.fontSize = pointSize.currentFontSize;
|
|
|
|
|
- _markers[markersNewIndex].label.textAlign = isIOS.value ? "center" : "left";
|
|
|
|
|
- _markers[markersNewIndex].label.anchorY = -(pointSize.currentHeight - 3);
|
|
|
|
|
- _markers[markersNewIndex].label.anchorX = isIOS.value ? 0 : -17;
|
|
|
|
|
|
|
|
|
|
isIgnoreChangeLocation = true;
|
|
isIgnoreChangeLocation = true;
|
|
|
markers.value = _markers;
|
|
markers.value = _markers;
|
|
|
markersIndex.value = markersNewIndex;
|
|
markersIndex.value = markersNewIndex;
|
|
|
- if (stationPage.value.hasNext && markersNewIndex >= _markers.length - 2) {
|
|
|
|
|
- stationPage.value.page += 1;
|
|
|
|
|
- refreshStation({
|
|
|
|
|
- latitude: mapProps.value.selflatitude,
|
|
|
|
|
- longitude: mapProps.value.selflongitude,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
};
|
|
};
|
|
|
const tapMarker = (e: any) => {
|
|
const tapMarker = (e: any) => {
|
|
|
if (e.detail.markerId === -1) {
|
|
if (e.detail.markerId === -1) {
|
|
@@ -737,6 +728,8 @@ const tapMarker = (e: any) => {
|
|
|
);
|
|
);
|
|
|
if (findIndex >= 0) {
|
|
if (findIndex >= 0) {
|
|
|
_changeMarker(findIndex);
|
|
_changeMarker(findIndex);
|
|
|
|
|
+ // 点击站点图标时按需查询详情(空闲数/活动)
|
|
|
|
|
+ loadStationCard(findIndex);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|