Commit 997453c1 by zhangxw

轨迹回放 默认时间 token问题

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