zhongrj
2025-03-28 4ff3eee77b41466d08117970970d01be6e48ffe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
  <div class="drone-pilot-list-warp">
    <van-nav-bar
      title="机场/遥控器"
      left-arrow
      @click-left="onClickLogin"
    />
    <div class="drone-pilot-list">
      <template v-if="droneOrPilotTxt == 'drone'">
      <div class="box-info" v-for="item in cardList" :key="item.sn">
        <div class="info-title" @touchstart="infoClick(item)">
          <div class="nike-name">{{ item.name }}</div>
          <div :class="item.isOnline?'line-status':'not-line-status'">{{ item.isOnline?'在线':'不在线' }}</div>
        </div>
        <div class="info-contain"></div>
      </div>
      </template>
      <template v-if="droneOrPilotTxt == 'pilot'">
      <div class="box-info" v-for="item in ykqList" :key="item.sn">
        <div class="info-title" @touchstart="infoClick(item)">
          <div class="nike-name">{{ item.name }}</div>
          <div :class="item.isOnline?'line-status':'not-line-status'">{{ item.isOnline?'在线':'不在线' }}</div>
        </div>
        <div class="info-contain"></div>
      </div>
      </template>
    </div>
    <div class="drone-pilot-btns">
      <div class="drone-pilot" @click="dronePilotClick(false, 'drone')" :class="{ active:!droneOrPilot }">机场</div>
      <div class="drone-pilot" @click="dronePilotClick(true, 'pilot')" :class="{ active:droneOrPilot }">遥控器</div>
    </div>
  </div>
</template>
 
<script lang="ts" setup>
import { ref, onMounted, onUnmounted, reactive } from 'vue'
import { projectCard } from './components/data'
import { getDroneData, getDroneDataYkq } from '@/api/manage'
import { getRoot } from '../../root'
import { ERouterName } from '@/types'
import { useMyStore } from '@/store'
// import VConsole from 'vconsole';
 
const root = getRoot()
 
const store = useMyStore()
 
// 机场和遥控器切换
const droneOrPilot = ref<Boolean>(false)
let droneOrPilotTxt = ref<String>('drone')
// 机场列表
const cardList = ref<projectCard[]>([])
 
// 遥控器列表
const ykqList = ref<projectCard[]>([])
 
// 机场和遥控器切换
const dronePilotClick = (value:Boolean,type:String) => {
  droneOrPilot.value = value
  droneOrPilotTxt.value = type
}
// 存储设备值
let osdVisible = reactive<any>({})
 
// const vConsole = new VConsole();
 
// 点击信息详情
const infoClick = (data:any) => {
  // 存储设备信息
  if (data.isOnline) { // 在线才有主要信息
    window.localStorage.setItem('sbInfo', JSON.stringify(data));
    osdVisible.sn = data.children.device_sn || ''
    osdVisible.callsign = data.children.nickname || '--'
    osdVisible.model = data.children.device_name || ''
    osdVisible.visible = true
    osdVisible.gateway_sn = data.children.device_sn || ''
    osdVisible.is_dock = true
    osdVisible.gateway_callsign = data.children.nickname || '--'
    osdVisible.payloads = data.children.payloads_list || []
    osdVisible.device_domain = data.children.domain || 0
    osdVisible.device_sub_type = data.children.sub_type || 1
    osdVisible.device_type = data.children.type || 0
    // osdVisible.domain = data.children.domain || 0
    // 前端自己加的判断
    window.sessionStorage.setItem('domain', JSON.stringify(droneOrPilotTxt.value == 'drone'? 0 : 2));
    store.commit('SET_OSD_VISIBLE_INFO', osdVisible)
    // 存储机场信息
    store.commit('SET_AIRPORT_INFO', data)
    // 跳转操作屏幕
    root.$router.push({ path:ERouterName.DRONEPILOTDETAILS })
  }
}
 
let intervalId = null;
 
// 获取机场列表信息
const init = async () => {
  await getDroneData().then((res:any) => {
    if (res.code != 200) return
    // 获取列表数据
    cardList.value = res.data
  })
  
  // 获取飞行器的
  await getDroneDataYkq().then((res:any) => {
    if (res.code != 200) return
    // 遥控器列表
    ykqList.value = res.data
  })
  
}
 
const onClickLogin = () => {
  history.back();
}
 
onMounted(() => {
  init()
  // 设置定时器,每隔 3 秒刷新一次数据
  intervalId = setInterval(init, 3000);
});
onUnmounted(() => {
  // 组件卸载时清除定时器
  if (intervalId) {
    clearInterval(intervalId);
  }
});
</script>
 
<style lang="scss" scoped>
.drone-pilot-list-warp {
  width: 100%;
  height: 100vh;
  background-color: #b8b3b338;
  // background-image: url('@/assets/images/newcon_box.png');
  .drone-pilot-list {
    height: calc(100vh - 50px - 46px);
    overflow: auto;
    .box-info {
      background-color: #fff;
      margin: 2%;
      border-bottom: 1px solid #fff;
      .info-title {
        display: flex;
        justify-content: space-between;
        padding: 2%;
        .nike-name {
          color: #000;
          font-weight: 300;
        }
        .line-status {
          padding: 3px;
          border: 1px solid #409eff;
          border-radius: 4px;
          font-size: 11px;
          color: #409eff;
        }
        .not-line-status {
          padding: 3px;
          border: 1px solid #999;
          border-radius: 4px;
          font-size: 11px;
          color: #999;
        }
      }
    }
  }
  .drone-pilot-btns {
    position: fixed;
    bottom: 0;
    background-color: #fff;
    display: flex;
    align-items: center;
    width: 100%;
    height: 50px;
    border: 1px solid #eee;
    .drone-pilot {
      width: 50%;
      height: 50px;
      line-height: 50px;
      align-content: center;
      text-align: center;
      color: #000;
    }
    .active {
      background-color: #409eff;
      color: #fff;
    }
  }
}
</style>