享飞-小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

205 lines
6.2 KiB

<script setup>
import { computed, ref } from 'vue';
import { Left, Right } from '@nutui/icons-vue-taro';
import { toFixed } from '../utils/helpers';
import { formatTime } from '../utils/helpers';
import deviceCruise from '../core/deviceCruise';
const isVisible = ref(true);
// const toggleVisibility = () => {
// isVisible.value = !isVisible.value;
// };
// const showTip = ref(true);
// const toggleBtnClass = computed(() => {
// return {
// 'toggle-btn': true,
// 'is-active': !isVisible.value
// };
// });
const info = computed(() => deviceCruise.timelyData);
</script>
<template>
<div :class="[s.root, { [s.hidden]: !isVisible }]">
<div class="nav">
<div :class="{ 'toggle-btn': true, 'is-active': !isVisible }" @click="() => isVisible = !isVisible">
<Left v-if="isVisible" style="font-size: 14px;" />
<Right style="font-size: 14px;" v-else />
</div>
</div>
<div class="text-row">
<span class="label">时间:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ formatTime(info.timestamp) }}</small>
<span class="unit"></span>
</div>
</span>
</div>
<div class="text-row">
<span class="label">经度:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.lng, 7) }}</small>
<span class="unit">°</span>
</div>
</span>
</div>
<div class="text-row">
<span class="label">纬度:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.lat, 7) }}</small>
<span class="unit">°</span>
</div>
</span>
</div>
<div class="text-row" v-if="(info.xspeed === 0) || info.xspeed">
<span class="label">水平速度:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.xspeed, 2) }}</small>
<span class="unit">米/秒</span>
</div>
</span>
</div>
<div class="text-row" v-if="(info.velocity === 0) || info.velocity">
<span class="label">速度:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.velocity, 2) }}</small>
<span class="unit">千米/小时</span>
</div>
</span>
</div>
<div class="text-row" v-if="(info.breadth === 0) || info.breadth">
<span class="label">幅宽:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.breadth, 2) }}</small>
<span class="unit">米</span>
</div>
</span>
</div>
<div class="text-row" v-if="(info.deep === 0) || info.deep">
<span class="label">耕深:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.deep, 2) }}</small>
<span class="unit">厘米</span>
</div>
</span>
</div>
<div class="text-row" v-if="(info.seeding === 0) || info.seeding">
<span class="label">播种速度:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ info.seeding }}</small>
<span class="unit">粒/s</span>
</div>
</span>
</div>
<div class="text-row">
<span class="label">航向角:</span>
<span class="value">
<div class="value-unit">
<small class="value">{{ toFixed(info.yaw, 2) }}</small>
<span class="unit">°</span>
</div>
</span>
</div>
</div>
</template>
<style lang="less" module="s">
.root {
pointer-events: visible;
position: absolute;
left: 5px;
top: 5px;
background-color: rgba(0, 0, 0, 0.6);
padding: 8px;
border-radius: 8px;
color: white;
font-size: 11px;
width: fit-content;
min-width: 120px;
z-index: 2;
transition: transform 0.3s ease;
&.hidden {
transform: translateX(calc(-100% - 5px));
}
:global {
.nav {
position: absolute;
right: -20px;
top: 6px;
.toggle-btn {
width: 20px;
height: 20px;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 0 4px 4px 0;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s ease;
&:hover {
background-color: rgba(0, 0, 0, 0.8);
}
&.is-active {
background-color: rgba(0, 0, 0, 0.9);
}
}
}
}
:global {
.text-row {
margin-bottom: 4px;
display: flex;
align-items: center;
gap: 2px;
&:last-child {
margin-bottom: 0;
}
.label {
min-width: 40px;
color: rgba(255, 255, 255, 0.8);
font-size: 10px;
}
.value {
color: white;
}
.value-unit {
display: inline-flex;
align-items: baseline;
gap: 1px;
.value {
font-weight: 500;
}
.unit {
font-size: 0.85em;
opacity: 0.8;
}
small {
font-size: 0.85em;
}
}
}
}
}
</style>