<template>
  <!-- :style="{ 'background-image': 'url(' + getAssetsFile('images/vsualized/screenbg.png') + ')' }" -->
  <div class="data-warp">
    <div class="chart-content">
      <div class="top">
        <slot v-if="$slots.top" name="top"></slot>
        <!--:style="{ 'background-image': 'url(' + getAssetsFile('images/vsualized/hraderbg.png') + ')' }" -->
        <div v-else class="top-content-warp">
          <div class="top-left"></div>
          <div class="top-content">
            <div class="top-content-p">
              <div class="b-nav-l">
                <template v-for="(n, indexn) in navlist" :key="n.name">
                  <div
                    v-if="indexn <= 3"
                    class="b-nav-item"
                    :style="{
                      'background-image':
                        'url(' +
                        (currentName == n.name ? getAssetsFile('images/vsualized/home/nav-on.png') : getAssetsFile('images/vsualized/home/nav.png')) +
                        ')',
                    }"
                    :class="currentName == n.name ? 'nav-act' : 'nav-normal'"
                    @click="itemAct(n.name)"
                  >
                    <span>{{ n.title }}</span>
                  </div>
                </template>
              </div>

              <!-- <div class="title txt-ellipsis clamp1">{{ topTitle }}</div> -->
              <div class="title txt-ellipsis clamp1">{{ '农业产业政务云平台' }}</div>
              <div class="b-nav-r">
                <template v-for="(m, indexm) in navlist" :key="m.name">
                  <div
                    v-if="indexm > 3"
                    class="b-nav-item"
                    :style="{
                      'background-image':
                        'url(' +
                        (currentName == m.name ? getAssetsFile('images/vsualized/home/nav-on.png') : getAssetsFile('images/vsualized/home/nav.png')) +
                        ')',
                    }"
                    :class="currentName == m.name ? 'nav-act' : 'nav-normal'"
                    @click="itemAct(m.name)"
                  >
                    <span>{{ m.title }}</span>
                  </div>
                </template>
              </div>
            </div>
          </div>
          <!-- <div class="top-right">{{ currentTime }}</div> -->
        </div>
      </div>
      <div class="content">
        <slot name="center"></slot>
      </div>
    </div>
  </div>
</template>
<script setup>
import { isEmpty, getAssetsFile } from '@/utils';
import { ref, reactive, onMounted, watch, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import { useApp } from '@/hooks';
const router = useRouter();
const props = defineProps({
  nameVal: {
    type: String,
    default: 'home',
  },
  topTitle: {
    type: String,
    default: '系统',
  },
});

const navlist = ref([
  { title: '首页', name: 'home' },
  { title: '土地资源', name: 'land' },
  { title: '投入品', name: 'inputs' },
  { title: '生产经营主体', name: 'entities' },
  // { title: '智慧种植监测', name: 'plant' },
  // { title: '智慧养殖监测', name: 'breed' },
  { title: '全流程溯源', name: 'trace' },
  { title: '产业预警决策', name: 'early' },
]);

let currentName = ref('home');

watch(
  () => props.nameVal,
  () => {
    currentName.value = props.nameVal;
  },
  {
    deep: true,
    immediate: true,
  }
);

const itemAct = (name) => {
  currentName.value = name;
  router.push({ name: name });
};
</script>
<style lang="scss" scoped>
div {
  box-sizing: border-box;
}
.data-warp {
  width: 100%;
  height: 100vh;
  background-size: 100% 100%;

  .chart-content {
    width: 100%;
    height: 100vh;
    z-index: 1;
    position: absolute;
    left: 0;
    top: 0;
    .top,
    .content,
    .bottom {
      width: 100%;
      padding: 0 16px;
      background-size: cover;
      display: inline-flex;
      flex-direction: column;
      justify-content: center;
    }
    .top {
      height: 55px;
      .top-content-warp {
        width: 100%;
        height: 100%;
        background-size: 100% 100%;
        background-repeat: no-repeat;
        .top-left,
        .top-content,
        .top-right {
          display: inline-block;
          vertical-align: middle;
        }
        .top-content {
          width: calc(100% - 400px);
          height: 100%;
          display: inline-flex;
          justify-content: center;
          flex-direction: column;
          .top-content-p {
            width: 100%;
          }
          .title,
          .b-nav-l,
          .b-nav-r {
            display: inline-block;
            vertical-align: middle;
          }
          .b-nav-l,
          .b-nav-r {
            width: calc((100% - 300px) / 2);
          }
          .b-nav-r {
            text-align: right;
          }
          .title {
            width: 300px;
            line-height: 38px;
            text-align: center;
            font-size: 22px;
            font-weight: bold;
            transform: skewX(-8deg);
            background: linear-gradient(to bottom, '#ff7e5f', '#548fff');
            -webkit-background-clip: text;
            color: #fff;
            letter-spacing: 8px;
            text-shadow: -6px 0 0 1px #add8f1;
            max-height: unset !important;
          }
        }
        .b-nav-l,
        .b-nav-r {
          margin: auto;
          display: inline-flex;
          gap: 20px;
          .b-nav-item {
            display: inline-block;
            cursor: pointer;
            min-width: 132px;
            height: 38px;
            text-align: center;
            line-height: 38px;
            span {
              font-size: 14px;
              font-weight: bold;
              display: inline-flex;
              transform: skewX(-8deg);
              background: linear-gradient(to bottom, '#ff7e5f', '#548fff');
              -webkit-background-clip: text;

              letter-spacing: 4px;
              text-shadow: -2px 0 0 1px #add8f1;
            }

            &.nav-act {
              color: rgba(255, 255, 255, 1);
            }
            &.nav-normal {
              color: rgba(255, 255, 255, 0.6);
            }
          }
        }
        .top-left {
          width: 200px;
        }
        .top-right {
          text-align: right;
          width: 200px;
          color: #add8f1;
        }
      }
    }
    .bottom {
      height: 80px;
      text-align: center;

      .b-nav {
        margin: auto;
        display: inline-flex;
        gap: 20px;
        .b-nav-item {
          display: inline-block;
          cursor: pointer;
          min-width: 132px;
          height: 42px;
          text-align: center;
          line-height: 38px;
          span {
            font-size: 14px;
            font-weight: bold;
            display: inline-flex;
            transform: skewX(-8deg);
            background: linear-gradient(to bottom, '#ff7e5f', '#548fff');
            -webkit-background-clip: text;

            letter-spacing: 4px;
            text-shadow: -2px 0 0 1px #add8f1;
          }

          &.nav-act {
            color: rgba(255, 255, 255, 1);
          }
          &.nav-normal {
            color: rgba(255, 255, 255, 0.6);
          }
        }
      }
    }
    .content {
      height: calc(100% - 60px);
    }
  }
}
</style>
