<template>
  <div class="shoula">
    <ul>
      <li
        @click="handleChange(item)"
        :style="{ '--bgColor': item.theme }"
        :class="{ active: item.id == $route.params.type }"
        v-for="(item, i) in themes"
        :key="i"
      >
        <img :src="require(`@/assets/images/proj2022/pc/diwen.png`)" alt="" />
        <div class="arrow" >
          <img :src="require(`@/assets/images/proj2022/pc/enter_1.png`)" alt="" />
        </div>

        <div class="txtcon">
          <span class="tag">{{ item.short }}</span>
          <span class="text" :title="item.desc || item.name">{{ item.desc || item.name }}</span>
        </div>
      </li>
    </ul>
    <img v-if="ishowzbtn" class="zhankai" @click="zhankai" :src="require(`@/assets/images/proj2022/pc/zhankai.png`)" alt="" />
  </div>
</template>

<script>
import panodata from "@/components/mapsvg/pano.js";
import { Booth } from "@/data/raw.js";

export default {
  props: ["currentPanoid"],

  mounted() {
    this.$bus.$on("isShowAside", (data) => {
      this.isShow = data;
    });

    this.$bus.$on("toggleShowZX", (data) => {
      this.ishowzbtn = !data;
    });
  },
  data() {
    return {
      isShow: true,
      panodata,
      showMap: false,
      hoverName: "",
      booth: Booth,
      ishowzbtn: false,
    };
  },
  computed: {
    cp() {
      return "v" + this.$route.params.type;
    },
    currentItem() {
      return this.themes.find((item) => item.id == this.theme);
    },
    currentPano() {
      return Booth.find((item) => item.panoId == this.currentPanoid) || {};
    },
  },

  watch: {
    isShow(newVal) {
      this.$bus.$emit("closehotspot", newVal);
    },
    currentPano(newVal) {
      this.$emit("currentPano", newVal);
    },
  },
  methods: {
    zhankai() {
      this.$bus.$emit("toggleShowZX", true);
    },
    handleChange(item) {
        this.$router.push({ params: { type: item.id, isjump: "yes" } });
    },
    handleHover(data) {
      this.hoverName = data.name;
    },
    openMap() {
      this.showMap = true;
      this.isShow = false;
    },
  },
};
</script>

<style lang="less" scoped>
@conW: 220px;
@gap: 20px;
@lgap: 8px;

.shoula {
  position: fixed;
  bottom: 120px;
  width: @conW;
  z-index: 999;
  > ul {
    margin: 0 auto;
    width: 100%;
    > li {
      width: 50%;
      height: 71px;
      display: block;
      margin-top: 10px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      font-size: 0;
      backdrop-filter: blur(15px) brightness(60%);
      transition: all ease 0.3s;
      clip-path: polygon(
        0 0,
        20px 0,
        10px 8px,
        10px + @lgap 8px,
        20px + @lgap 0,
        20px + 2 * @lgap 0,
        10px + 2 * @lgap 8px,
        10px + 3 * @lgap 8px,
        20px + 3 * @lgap 0,
        20px + 4 * @lgap 0,
        10px + 4 * @lgap 8px,
        10px + 5 * @lgap 8px,
        20px + 5 * @lgap 0,
        100% 0,
        100% calc(100% - @gap),
        calc(100% - @gap) 100%,
        0 100%
      );
      border-top-right-radius: 2px;
      &::before,
      &::after {
        background: linear-gradient(186deg, var(--bgColor) 0%, var(--bgColor) 40%, rgba(0, 144, 255, 0) 100%);
        content: "";
        width: 60%;
        height: 4px;
        position: absolute;
        top: 0;
        right: 0;
      }
      &::after {
        content: "";
        top: 4px;
        height: 50%;
        width: 4px;
      }
      > img {
        width: 100%;
        opacity: 0;
      }
      .arrow{
        opacity: 0;
      }

      .txtcon {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 22px;
        color: rgba(255, 255, 255, 0.8);
        max-width: 180px;
        .tag {
          font-size: 24px;
          display: block;
          font-family: "pangmen";
        }
        .text {
          display: inline-block;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          margin-top: 4px;
          padding-left: 10px;
          font-size: 14px;
          position: relative;
          line-height: 1;
          vertical-align: middle;
          transition: all ease 0.3s;
          width: 0;
          height: 0;
          &::before {
            position: absolute;
            display: none;
            content: "";
            width: 2px;
            height: 14px;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(255, 255, 255, 0.8);
          }
        }
      }
      &:hover {
        width: 100% !important;
        >img{
          opacity: 0.2;
        }
        .txtcon {
          .text {
            width: 100%;
            height: auto;
            &::before {
              position: absolute;
              display: inline-block;
              content: "";
            }
          }
        }
      }

      &.active {
        color: var(--bgColor);
        backdrop-filter: blur(15px) brightness(100%);
        background: linear-gradient(269deg, #FFFFFF 0%, rgba(255, 255, 255, 0.51) 100%);
        width: 54%;
         >img{
          opacity: 0;
        }
        .txtcon {
          color: var(--bgColor);
          .text {
            &::before {
              position: absolute;
              content: "";
              width: 2px;
              height: 14px;
              left: 0;
              top: 50%;
              transform: translateY(-50%);
              background: rgba(0, 0, 0, 0.2);
            }
          }
        }

        .arrow {
          width: 12px;
          position: absolute;
          opacity: 1;
          right: 14px;
          top: 50%;
          transform: translateY(-50%);
          z-index: 999;
          text-indent: -12px;
          overflow: hidden;
          >img{
            width: 100%;
            filter: drop-shadow(12px 0px var(--bgColor));
          }
        }
      }
    }
  }

  .zhankai {
    position: fixed;
    bottom: 65px;
    left: 20px;
    cursor: pointer;
  }
}
</style>
