Commit 997453c1 by zhangxw

轨迹回放 默认时间 token问题

1 parent 86a98c8f
......@@ -114,7 +114,7 @@ export default defineComponent({
popup,
},
setup() {
const openFreq = ref(true);
const openFreq = ref(false);
const type = ref(0);
const route = useRoute();
let routeQuery = route.query;
......@@ -148,9 +148,10 @@ export default defineComponent({
const getInfoData = () => {
GET_FREQ_INFO({ sn: routeQuery.sn }).then((res) => {
if (res.code === 200) {
if (res.data.type === 3) {
if ((res.data && res.data.type === 3) || !res.data) {
openFreq.value = false;
} else {
openFreq.value = true;
type.value = res.data.type;
switch (res.data.type) {
case 0:
......
......@@ -199,11 +199,17 @@ export default defineComponent({
}
};
watch(mapIsUploaded, (newVal) => {
localStorage.removeItem("token");
localStorage.removeItem("sharePage");
if (route.query.token) {
localStorage.setItem("token", route.query.token);
}
if (route.query.sharePage) {
localStorage.setItem("sharePage", JSON.parse(route.query.sharePage));
isSharePage.value = JSON.parse(route.query.sharePage);
}
routeQuery.value = route.query;
if (newVal && routeQuery.value.sn) {
if (route.query.token) {
localStorage.setItem("token", route.query.token);
}
carItem.value = {
sns: routeQuery.value.sn,
ownerName:
......@@ -274,14 +280,6 @@ export default defineComponent({
}
});
onMounted(() => {
localStorage.removeItem("sharePage");
if (route.query.token) {
localStorage.setItem("token", route.query.token);
}
if (route.query.sharePage) {
localStorage.setItem("sharePage", JSON.parse(route.query.sharePage));
isSharePage.value = JSON.parse(route.query.sharePage);
}
AMapLoader.load({
key: CONSTANT.MAP_KEY,
version: "1.4.8",
......@@ -346,7 +344,9 @@ export default defineComponent({
if (
item.gpsLocation &&
item.gpsLocation.elng &&
item.gpsLocation.elat
item.gpsLocation.elat &&
Number(item.gpsLocation.elng) > 0 &&
Number(item.gpsLocation.elat) > 0
) {
locates.push(item.gpsLocation);
item.gpsLocation.transferAddress = "";
......@@ -354,7 +354,9 @@ export default defineComponent({
if (
item.bsLocation &&
item.bsLocation.elng &&
item.bsLocation.elat
item.bsLocation.elat &&
Number(item.bsLocation.elng) > 0 &&
Number(item.bsLocation.elat) > 0
) {
locates.push(item.bsLocation);
item.bsLocation.transferAddress = "";
......@@ -362,7 +364,9 @@ export default defineComponent({
if (
item.wifiLocation &&
item.wifiLocation.elng &&
item.wifiLocation.elat
item.wifiLocation.elat &&
Number(item.wifiLocation.elng) > 0 &&
Number(item.wifiLocation.elat) > 0
) {
locates.push(item.wifiLocation);
item.wifiLocation.transferAddress = "";
......
......@@ -79,7 +79,11 @@
/>
</div>
</popup>
<mapContent @refreshCb="refreshCb" ref="mapContentRefs">
<mapContent
@refreshCb="refreshCb"
@getData="getCarReplayData"
ref="mapContentRefs"
>
<template #mapBox>
<div id="replayContainer" class="map-container"></div>
</template>
......@@ -117,20 +121,24 @@ export default defineComponent({
setup() {
const mapContentRefs = ref(null);
const showSpeedPicker = ref(false);
const speedId = ref("慢");
const selectSpeedId = ref("");
const speedId = ref("正常");
const selectSpeedId = ref("正常");
const eParams = ref({});
const timeSelected = ref(null);
const timeSelected = ref(0);
const showTimeDialog = ref(false);
const showTimePicker = ref(false);
const currentDate = ref(new Date());
const timeBtnList = ["24小时", "3天", "7天"];
const customTime = ref("");
const searchTime = ref([]);
const searchTime = ref([
moment().subtract(1, "day").format("YYYY-MM-DD HH:mm:ss"),
moment().format("YYYY-MM-DD HH:mm:ss"),
]);
const route = useRoute();
const currDateText = ref("");
const currDateText = ref("24小时");
const maxDate = ref(new Date());
let map = null;
const replayList = ref([]);
let currentMap = null;
let routeQuery = route.query;
const replay = reactive({
PathS: null, //轨迹构造器
......@@ -153,16 +161,6 @@ export default defineComponent({
}).then((AMap) => {
window.AMap = AMap;
mapContentRefs.value.initMap("replayContainer");
window.AMapUI.load(
["ui/misc/PathSimplifier"],
function (PathSimplifier) {
if (!PathSimplifier.supportCanvas) {
alert("当前环境不支持 Canvas!");
return;
}
replay.PathS = PathSimplifier;
}
);
});
});
const refreshCb = () => {
......@@ -175,11 +173,12 @@ export default defineComponent({
});
}
isPlay.value = false;
map.clearMap();
currentMap.clearMap();
getCarReplayData();
};
// 获取车辆轨迹
const getCarReplayData = () => {
const getCarReplayData = (map) => {
currentMap = map ? map : currentMap;
getParams();
if (replay.navg) {
replay.navg.destroy();
......@@ -190,7 +189,7 @@ export default defineComponent({
});
}
isPlay.value = false;
map && map.clearMap();
currentMap && currentMap.clearMap();
GET_REPLAY_DATA({ ...eParams.value }).then((res) => {
showTimeDialog.value = false;
if (res.code === 200) {
......@@ -202,8 +201,10 @@ export default defineComponent({
arr.push(item.elat);
replayData.push(arr);
});
initPath(replayData);
replayList.value = replayData;
initPath(replayData, currentMap);
} else {
replayList.value = [];
Dialog({ message: "暂无轨迹数据" });
}
}
......@@ -318,13 +319,12 @@ export default defineComponent({
}
return speed;
};
const initPath = (replayData) => {
map = map ? map : mapContentRefs.value.init("replayContainer");
const initPath = (replayData, currentMap) => {
replay.dis = window.AMap.GeometryUtil.distanceOfLine(replayData) / 1000; // 算出轨迹的距离(km)
if (replay.PathS) {
replay.pathSimplifierIns = new replay.PathS({
zIndex: 100,
map: map, //所属的地图实例
map: currentMap, //所属的地图实例
getPath: function (pathData) {
return pathData.path;
},
......@@ -363,10 +363,25 @@ export default defineComponent({
replay.navg.on("pause", function () {
isPlay.value = false;
});
} else {
window.AMapUI.load(
["ui/misc/PathSimplifier"],
function (PathSimplifier) {
if (!PathSimplifier.supportCanvas) {
alert("当前环境不支持 Canvas!");
return;
}
replay.PathS = PathSimplifier;
initPath(replayData, currentMap);
}
);
}
};
// 播放轨迹
const play = () => {
if (!replayList.value.length) {
return Toast("暂无轨迹数据");
}
if (replay.navg) {
if (replay.navg.getCursor().idx === replay.navg.getPathEndIdx()) {
replay.navg.start();
......@@ -387,6 +402,9 @@ export default defineComponent({
};
// 重新播放
const replayPath = () => {
if (!replayList.value.length) {
return Toast("暂无轨迹数据");
}
if (replay.navg) {
replay.navg.start();
isPlay.value = true;
......@@ -421,6 +439,7 @@ export default defineComponent({
currDateText,
onShowTimePicker,
maxDate,
replayList,
};
},
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!