<script setup>
import { computed, ref } from 'vue';
import { Left, Right } from '@nutui/icons-vue-taro';
// import { toFixed } from '@/utils/helpers.js';
import { toFixed } from '../../utils/helpers';
// import deviceCruise from '../../../core/deviceCruise';
import { IconFont } from "@nutui/icons-vue-taro";
import { TIP_TEXT } from '../../config/tipTextMap';
import Taro from "@tarojs/taro";

const isVisible = ref(true);

// const info = computed(() => ({}));
defineProps({
    info: {
        type: Object,
        default: () => ({}),
    }
})

function onBack() {
    Taro.reLaunch({ url: '/pages/home/index' });
}
</script>

<template>
    <div :class="s.root" :catch-move="true">
<!--        <canvas class="canvas-bg" type="2d" />-->
        <div class="box">
            <div class="countdown">
                <div class="title">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="time" />
                </div>
                <div class="value">{{ toFixed(info.timeTicker || 0, 1) }}</div>
            </div>
        </div>
        <div class="box box2">
            <div class="data-item">
                <div class="text" v-if="false">切线速度：</div>
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="tangent-speed" />
                </div>
                <div class="value-wrapper">{{ toFixed(info?.speed || 0, 2) }}</div>
            </div>
            <div class="data-item">
                <div class="text" v-if="false">航向偏差：</div>
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="tangent-angle" />
                </div>
                <div class="value-wrapper">{{ toFixed(info?.angle || 0, 2) }}</div>
            </div>
            <div class="data-item">
                <div class="text" v-if="false">高度偏差：</div>
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="offset-v" />
                </div>
                <div class="value-wrapper">{{ toFixed(info?.vertical || 0, 2) }}</div>
            </div>
            <div class="data-item">
                <div class="text" v-if="false">水平偏差：</div>
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="offset-h" />
                </div>
                <div class="value-wrapper">{{ toFixed(info?.horizontal || 0, 2) }}</div>
            </div>
            <div class="data-item">
                <div class="text" v-if="false">角速度：</div>
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" name="angle-speed" />
                </div>
                <div class="value-wrapper">{{ toFixed(info?.angleSpeed || 0, 2) }}</div>
            </div>
        </div>
        <div class="box box3">
            <div class="data-item" v-for="(item, index) in (info?.errPoints || [])" :key="index">
                <div class="icon-wrapper">
                    <IconFont font-class-name="iconfont" class-prefix="icon" :name="TIP_TEXT[item.audioCode]?.icon" />
                </div>
                <div class="value-wrapper">{{ toFixed(item.value || 0, 2) }}</div>
            </div>
        </div>
        <div class="box box4" @click="onBack">
            <span>返回首页</span>
        </div>
    </div>
</template>

<style lang="less" module="s">
.root {
    pointer-events: visible;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    // padding: 8px;
    color: white;
    font-size: 11px;
    width: 100px;
    z-index: 2;
    display: flex;
    flex-direction: column;

    :global {
        .canvas-bg {
            width: 100%;
            height: 80%;
            position: absolute;
            //top: 0;
            //right: 0;
            //left: 0;
            //bottom: 20px;
        }
        .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);
                }
            }
        }

        .box {
            display: flex;
            flex-direction: column;
            gap: 2px;
            font-family: monospace;
            color: #7FFF00;
            border-bottom: 1px solid rgb(255, 255, 255);
            // padding: 4px 8px;

            .countdown {
                display: flex;
                align-items: center;
                padding: 0 8px;
                //justify-content: center;
                //justify-content: ;
                .title {
                    width: 25px;
                    height: 25px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 20px;
                    background: rgba(127, 255, 0, 0.1);
                    border-radius: 4px;
                    overflow: hidden;
                }

                .value {
                    font-size: 24px;
                    font-weight: bold;
                    text-align: center;
                    padding: 5px;
                }
            }

            .data-item {
                display: flex;
                align-items: center;
                justify-content: center;
                // gap: 12px;
                // padding: 5px;

                .text {
                    font-size: 9px;
                    white-space: nowrap;
                    overflow: hidden;
                }

                .icon-wrapper {
                    width: 25px;
                    height: 25px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 20px;
                    background: rgba(127, 255, 0, 0.1);
                    border-radius: 4px;
                    overflow: hidden;
                }

                .value-wrapper {
                    flex: 1;
                    font-size: 18px;
                    font-weight: 500;
                    text-align: left;
                    padding-left: 8px;
                }
            }
        }

        .box2 {
            padding: 8px;
        }

        .box3 {
            flex: 1;
            color: red;
            padding: 4px 8px;

            .icon-wrapper {
                background: rgba(255, 0, 0, 0.1) !important;
            }
        }

        .box4 {
            padding: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            //height: 40px;
            color: white;
            //text-align: center;
            border-bottom: none;
        }
    }
}
</style>
