<template>

<div class="space-ctrl">

  <div class="status-block">

    <div v-if="trackCar" class="car">
      <div class="text">
        <div class="icon speed"></div>实时车速：{{ carTracked.speed }}km/h
      </div>
      <div class="text">
        <div class="icon pile"></div>车辆桩号：{{ carMilestone }}
      </div>
    </div>

  </div>

  <MapScale ref="mapScaleRef" />

</div>

</template>

<script lang='ts' setup>

import MapScale from './MapScale.vue'

import { defineExpose } from 'vue'
import { numToStone } from '@/utils/tunnel'
import { carTracked, bus } from '@/views/3DModel/_state'

// 追踪车辆桩米号
const carMilestone = computed(() => {
  if (!carTracked.value) return ''
  return numToStone(parseInt(carTracked.value.milestone))
})

const mapScaleRef = ref(null)

defineExpose({
  setCurrent: e => {
    if (mapScaleRef.value) {
      mapScaleRef.value.setCurrent(e)
    }
  }
})

</script>

<style lang='scss' scoped>

$Common_Url: '@/assets/images/3d/';

.space-ctrl {
  height: 100px;
  position: fixed;
  bottom: 0;
  z-index: 2;
  left: 485px;
  right: 450px;
  transition: all .5s ease-out;
  // background: salmon;

  .status-block {
    display: flex;
    color: white;
    font-size: 14px;
    .event {
      display: flex;
      margin-right: 65px;
      .icon {
        width: 20px;
        height: 20px;
        margin-right: 10px;
        background: url($Common_Url + 'play.png') no-repeat;
        background-size: auto 100%;
      }
    }
    .car {
      display: flex;
      .text {
        display: flex;
        align-items: center;
        margin-right: 15px;
        .icon {
          width: 20px;
          height: 20px;
          &.speed {
            background: url($Common_Url + 'speed.png') no-repeat;
            background-size: auto 100%;  
            background-position: center;
            margin-right: 5px;
          }
          &.pile {
            background: url($Common_Url + 'point.png') no-repeat;
            background-size: auto 100%;
            background-position: center;  
          }
        }
      }
    }
  }
  .space-block {
    background: rgba($color: #243247, $alpha: 0.5);
    height: 70px;
    margin-top: 25px;
    overflow: hidden;
    display: flex;
    .direction {
      width: 80px;
      margin-left: 15px;
      height: 45px;
      margin-top: 15px;
      color: white;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .x-direct {
        font-size: 14px;
        display: flex;
        align-items: center;
        cursor: pointer;
        .def-radio {
          width: 16px;
          height: 16px;
          border-radius: 16px;
          box-sizing: border-box;
          border: 2px solid rgba($color: #ffffff, $alpha: 0.5);
          margin-right: 5px;
        }
        &.act {
          font-weight: bold;
          .def-radio {
            position: relative;
            border-color: #33FFF1;
            &::after {
              content: " ";
              width: 6px;
              height: 6px;
              border-radius: 6px;
              position: absolute;
              left: 50%;
              top: 50%;
              background: #33FFF1;
              transform: translate(-50%, -50%);
            }
          }
        }
      }
    }
    .scales {
      flex-grow: 1;
      margin-right: 18px;
      height: 10px;
      background: salmon;
    }
  }
}

</style>