diff --git a/src/components/PlaneStatus.vue b/src/components/PlaneStatus.vue index ed09c49..2038559 100644 --- a/src/components/PlaneStatus.vue +++ b/src/components/PlaneStatus.vue @@ -1,6 +1,15 @@ @@ -11,6 +20,10 @@ export default { name: 'PlaneStatus', data () { return { + /* 心跳 */ + heartAnimation: false, // 控制心跳动画图标 + online: false, + isOnlineSetTimeout: null } }, props: { @@ -20,11 +33,41 @@ export default { } }, components: { - }, computed: { + // 心跳随机数 + heartRandom () { + if (this.plane && this.plane.planeState) { + return this.plane.planeState.heartRandom + } + return 0 + }, + // 卫星数 + satCount () { + if (this.plane && this.plane.planeState) { + return this.plane.planeState.satCount + } + return 0 + } }, watch: { + heartRandom: { + handler (val) { + // 心跳动画 + this.heartAnimation = true + setTimeout(() => { + this.heartAnimation = false + }, 500) + // 在线状态 + if (this.isOnlineSetTimeout) { // 进入本次心跳 删除掉线计时 既以下会重新计时 + clearInterval(this.isOnlineSetTimeout) + } + this.online = true + this.isOnlineSetTimeout = setTimeout(() => { // 计时10秒后 掉线 + this.online = false + }, 10000) + } + } }, methods: {}, created () { @@ -35,4 +78,24 @@ export default { diff --git a/src/views/layout/components/main/planes/index.vue b/src/views/layout/components/main/planes/index.vue index c109036..a61ad72 100644 --- a/src/views/layout/components/main/planes/index.vue +++ b/src/views/layout/components/main/planes/index.vue @@ -3,6 +3,7 @@ @@ -14,6 +15,7 @@ import mqtt from '@/utils/mqtt' import MapBox from '@/components/MapBox' import ControllerTabs from '@/components/ControllerTabs' import BatteryStatus from '@/components/BatteryStatus' +import PlaneStatus from '@/components/PlaneStatus' export default { name: 'Planes', @@ -27,7 +29,8 @@ export default { components: { MapBox, ControllerTabs, - BatteryStatus + BatteryStatus, + PlaneStatus }, computed: { plane () {