|
|
@@ -1,22 +1,23 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
- title="车辆轨迹"
|
|
|
- append-to-body
|
|
|
- custom-class="dialog_two"
|
|
|
- :visible.sync="dialogVisible"
|
|
|
- lock-scroll
|
|
|
- :before-close="handleClose"
|
|
|
- width="80%">
|
|
|
+ title="车辆轨迹"
|
|
|
+ append-to-body
|
|
|
+ custom-class="dialog_two"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ lock-scroll
|
|
|
+ :before-close="handleClose"
|
|
|
+ width="80%"
|
|
|
+ >
|
|
|
<div id="container" v-if="dialogVisible"></div>
|
|
|
- <div class="input-card" style="right: 10.3%;bottom: 10.3%" v-if="this.lineArr.length>0">
|
|
|
+ <div class="input-card" style="right: 10.3%;bottom: 10.3%" v-if="this.lineArr.length > 0">
|
|
|
<h4>轨迹回放控制</h4>
|
|
|
<div class="input-item">
|
|
|
- <input type="button" class="btn" value="开始动画" id="start" @click="startAnimation()"/>
|
|
|
- <input type="button" class="btn" value="暂停动画" id="pause" @click="pauseAnimation()"/>
|
|
|
+ <input type="button" class="btn" value="开始动画" id="start" @click="startAnimation()" />
|
|
|
+ <input type="button" class="btn" value="暂停动画" id="pause" @click="pauseAnimation()" />
|
|
|
</div>
|
|
|
<div class="input-item">
|
|
|
- <input type="button" class="btn" value="继续动画" id="resume" @click="resumeAnimation()"/>
|
|
|
- <input type="button" class="btn" value="停止动画" id="stop" @click="stopAnimation()"/>
|
|
|
+ <input type="button" class="btn" value="继续动画" id="resume" @click="resumeAnimation()" />
|
|
|
+ <input type="button" class="btn" value="停止动画" id="stop" @click="stopAnimation()" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="input-card" style="right: 10.3%;bottom: 10.3%" v-else>
|
|
|
@@ -26,6 +27,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {dateFormat} from "@/util/date";
|
|
|
export default {
|
|
|
name: "trackPlayback",
|
|
|
props: {
|
|
|
@@ -35,33 +37,34 @@ export default {
|
|
|
parkingPoint: {
|
|
|
type: Boolean
|
|
|
},
|
|
|
- lineArr:Object,
|
|
|
+ lineArr: Object
|
|
|
},
|
|
|
- data(){
|
|
|
- return{
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
map: null,
|
|
|
marker: null,
|
|
|
infoWindow: null
|
|
|
- }
|
|
|
+ };
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.map && this.map.destroy();
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
handleClose(done) {
|
|
|
- this.dialogVisible = false
|
|
|
- this.$emit('closeDialog')
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.$emit("closeDialog");
|
|
|
},
|
|
|
- initMap() {
|
|
|
+ initMap(carData) {
|
|
|
+ let isCar = carData ? true : false;
|
|
|
this.map = new AMap.Map("container", {
|
|
|
resizeEnable: true,
|
|
|
- center: this.lineArr.length >0 ?this.lineArr[this.lineArr.length - 1]:[120.382891,36.066460],
|
|
|
+ center: this.lineArr.length > 0 ? this.lineArr[this.lineArr.length - 1] : [120.382891, 36.06646],
|
|
|
zoom: 17
|
|
|
});
|
|
|
let icon = new AMap.Icon({
|
|
|
size: new AMap.Size(52, 26), // 图标尺寸
|
|
|
- image: 'http://trade.tubaosoft.com/file/bladex/000000/1123598821738675201/che.png',
|
|
|
- imageSize: new AMap.Size(52, 26), // 根据所设置的大小拉伸或压缩图片
|
|
|
+ image: "http://trade.tubaosoft.com/file/bladex/000000/1123598821738675201/che.png",
|
|
|
+ imageSize: new AMap.Size(52, 26) // 根据所设置的大小拉伸或压缩图片
|
|
|
});
|
|
|
// 绘制轨迹
|
|
|
let polyline = new AMap.Polyline({
|
|
|
@@ -81,7 +84,7 @@ export default {
|
|
|
strokeWeight: 6 //线宽
|
|
|
// strokeStyle: "solid" //线样式
|
|
|
});
|
|
|
- if (this.parkingPoint.length>0){
|
|
|
+ if (this.parkingPoint.length > 0) {
|
|
|
this.infoWindow = new AMap.InfoWindow({
|
|
|
offset: new AMap.Pixel(0, -30)
|
|
|
});
|
|
|
@@ -90,19 +93,47 @@ export default {
|
|
|
position: this.parkingPoint[i].location,
|
|
|
map: this.map
|
|
|
});
|
|
|
- let fun = this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete)==='获取失败'?'':this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete)
|
|
|
- this.marker.content = '<div style="width: 300px;">'
|
|
|
- + '<p style="font-size: 22px;font-weight: bold;background-color: #2d8cf0;color: #fff;">' + fun + '</p>'
|
|
|
- + '<p style="padding: 5px 0"><span style="color: #a0a0a0">停车时间:</span>' + (new Date(Number(this.parkingPoint[i].bte) + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(0, 19)).slice(5,19)+'至'+ (new Date(Number(this.parkingPoint[i].ete) + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(0, 19)).slice(5,19)+ '</p>'
|
|
|
- + '<p><span style="color: #a0a0a0">当前位置:</span>' +this.parkingPoint[i].address + '</p>'
|
|
|
- + '</div>'
|
|
|
- this.marker.on('click', this.markerClick);
|
|
|
- this.marker.emit('click', {target: this.marker});
|
|
|
+ let fun =
|
|
|
+ this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete) === "获取失败"
|
|
|
+ ? ""
|
|
|
+ : this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete);
|
|
|
+ this.marker.content =
|
|
|
+ '<div style="width: 300px;">' +
|
|
|
+ '<p style="font-size: 22px;font-weight: bold;background-color: #2d8cf0;color: #fff;">' +
|
|
|
+ fun +
|
|
|
+ "</p>" +
|
|
|
+ '<p style="padding: 5px 0"><span style="color: #a0a0a0">停车时间:</span>' +
|
|
|
+ new Date(Number(this.parkingPoint[i].bte) + 8 * 60 * 60 * 1000)
|
|
|
+ .toJSON()
|
|
|
+ .split("T")
|
|
|
+ .join(" ")
|
|
|
+ .substr(0, 19)
|
|
|
+ .slice(5, 19) +
|
|
|
+ "至" +
|
|
|
+ new Date(Number(this.parkingPoint[i].ete) + 8 * 60 * 60 * 1000)
|
|
|
+ .toJSON()
|
|
|
+ .split("T")
|
|
|
+ .join(" ")
|
|
|
+ .substr(0, 19)
|
|
|
+ .slice(5, 19) +
|
|
|
+ "</p>" +
|
|
|
+ '<p><span style="color: #a0a0a0">当前位置:</span>' +
|
|
|
+ this.parkingPoint[i].address +
|
|
|
+ "</p>" +
|
|
|
+ '<p><span style="color: #a0a0a0">设备状态:</span>' +
|
|
|
+ (isCar ? (carData.is_online ? '<span style="color: #67C23A">在线</span>' : '<span style="color: #F56C6C">离线</span>') : "暂无设备") +
|
|
|
+ "</p>" +
|
|
|
+ '<span style="color: #a0a0a0">当前温度:</span><span style="color: #F56C6C">' +
|
|
|
+ (isCar ? carData.wd?carData.wd + "℃ " +dateFormat(new Date(carData.ts*1000)):'暂无温度': "暂无设备") +
|
|
|
+ "</span>" +
|
|
|
+ "</div>";
|
|
|
+ this.marker.on("click", this.markerClick);
|
|
|
+ this.marker.emit("click", { target: this.marker });
|
|
|
}
|
|
|
}
|
|
|
this.marker = new AMap.Marker({
|
|
|
map: this.map,
|
|
|
- position: this.lineArr.length >0 ?this.lineArr[this.lineArr.length - 1]:[120.382891,36.066460],
|
|
|
+ position: this.lineArr.length > 0 ? this.lineArr[this.lineArr.length - 1] : [120.382891, 36.06646],
|
|
|
// icon: "https://webapi.amap.com/images/car.png",
|
|
|
icon: icon,
|
|
|
markerMeta: new AMap.Size(28, 28),
|
|
|
@@ -112,17 +143,17 @@ export default {
|
|
|
});
|
|
|
this.map.setFitView();
|
|
|
},
|
|
|
- fun(startTime,endTime) {
|
|
|
+ fun(startTime, endTime) {
|
|
|
let usedTime = endTime - startTime; // 相差的毫秒数
|
|
|
let days = Math.floor(usedTime / (24 * 3600 * 1000)); // 计算出天数
|
|
|
let leavel = usedTime % (24 * 3600 * 1000); // 计算天数后剩余的时间
|
|
|
let hours = Math.floor(leavel / (3600 * 1000)); // 计算剩余的小时数
|
|
|
let leavel2 = leavel % (3600 * 1000); // 计算剩余小时后剩余的毫秒数
|
|
|
let minutes = Math.floor(leavel2 / (60 * 1000)); // 计算剩余的分钟数
|
|
|
- if (startTime && endTime){
|
|
|
- return days + '天' + hours + '时' + minutes + '分'
|
|
|
- }else {
|
|
|
- return '获取失败'
|
|
|
+ if (startTime && endTime) {
|
|
|
+ return days + "天" + hours + "时" + minutes + "分";
|
|
|
+ } else {
|
|
|
+ return "获取失败";
|
|
|
}
|
|
|
},
|
|
|
markerClick(e) {
|
|
|
@@ -140,9 +171,9 @@ export default {
|
|
|
},
|
|
|
stopAnimation() {
|
|
|
this.marker.stopMove();
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped src="../styles/demo-center.css"></style>
|
|
|
@@ -195,11 +226,11 @@ export default {
|
|
|
padding: 0 20px 10px 20px !important;
|
|
|
}
|
|
|
|
|
|
-::v-deep .amap-info-close{
|
|
|
- right: 10px!important;
|
|
|
+::v-deep .amap-info-close {
|
|
|
+ right: 10px !important;
|
|
|
top: 12px !important;
|
|
|
}
|
|
|
-::v-deep .amap-info-content{
|
|
|
+::v-deep .amap-info-content {
|
|
|
padding: 5px 5px 5px 5px !important;
|
|
|
}
|
|
|
</style>
|