<template>
  <div v-show="route.fullPath === '/nav' || route.fullPath === '/guide'">
    <div class="wave-wrapper">
      <!-- 地图容器 -->
      <div id="mapContainer"></div>
      <img class="mask-map" src="@/assets/images/map/bg.svg" alt="" />
      <img class="mask-top" src="@/assets/images/guide/mask_top.svg" />

      <transition enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
        <img v-if="route.fullPath === '/'" src="@/assets/images/header/search.svg" alt="" @click="store.SET_SHOW_SEARCH(true)" />
        <img v-else src="@/assets/images/header/back.svg" alt="" @click="router.back()" />
      </transition>
    </div>
    <div class="language-items">
      <div class="language-item" :class="{ active: language === 'zh' }" @click="changeLang('zh')">中</div>
      <div class="language-item" :class="{ active: language === 'en' }" @click="changeLang('en')">EN</div>
      <div class="language-item" :class="{ active: language === 'tw' }" @click="changeLang('tw')">繁</div>
    </div>
    <!-- 标题组 -->
    <transition enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
      <div class="title-container">
        <!-- 标题 -->
        <span>{{ route.meta.titleEn }}</span>
        <svg width="24" height="40" viewBox="0 0 24 40" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M22.2845 0L24 1.00072L1.71546 40L0 38.9993L22.2845 0Z" fill="black" fill-opacity="0.2" />
        </svg>
        <span>{{ route.meta.title }}</span>
      </div>
    </transition>

    <!-- 地图弹框 -->
    <div id="shopInfo" class="boxShop boxShop2">
      <div id="shopNum">{{ switchLanguage(shop, 'shopName') }}</div>
      <div class="map-flex">
        <div class="pop-bottom__detail" @click="handleDetail">{{ $t('detail') }}</div>
        <div class="go-button" @click="handleGO">{{ $t('nav') }}</div>
      </div>
    </div>
    <div id="moveFloorBG">
      <span id="moveFloor"></span>
      <div id="floorBox"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRootStore } from '@/store/root'
import { storeToRefs } from 'pinia'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const store = useRootStore()
const { shop, language } = storeToRefs(store)

const emits = defineEmits(['handle-go', 'handle-Detail'])

function handleGO() {
  emits('handle-go')
}

// 点击地图弹框详情
function handleDetail() {
  emits('handle-Detail')
}
function changeLang(lang: Language) {
  if (lang === language.value) {
    return
  }
  store.SET_LANGUAGE(lang)
}
</script>

<style lang="scss" scoped>
/* stylelint-disable-next-line selector-id-pattern */
#mapContainer {
  position: absolute;
  top: 111px;
  left: 404px;
  z-index: 2;
  width: 1080px;
  height: 900px;
}
.map-flex {
  display: flex;
  align-items: center;
}
/* stylelint-disable-next-line selector-id-pattern */
#shopInfo {
  position: absolute;
  top: 0;
  z-index: 500;
  width: 221px;
  height: 132px;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: contain;
  visibility: hidden;
  background-image: url('@/assets/images/map/map-dialog.png');

  /* stylelint-disable-next-line selector-id-pattern */
  #shopNum {
    height: 60px;
    padding: 25px 27px 0 36px;
    font-size: 18px;
    font-family: 'font_bold';
    color: #fff;
    font-weight: 700;

    @include no-wrap;
  }
  .go-button {
    width: 125px;
    height: 30px;
    padding-right: 20px;
    font-size: 14px;
    font-family: 'font_medium';
    text-align: center;
    color: rgb(0 0 0 / 90%);
    line-height: 40px;
    // font-weight: 700;
  }

  /* stylelint-disable-next-line selector-class-pattern */
  .pop-bottom__detail {
    height: 30px;
    padding-left: 24px;
    font-size: 14px;
    font-family: 'font_medium';
    text-align: center;
    color: rgb(0 0 0 / 90%);
    flex: 1;
    line-height: 40px;
    // font-weight: 700;
  }
}
/* stylelint-disable-next-line selector-id-pattern */
#moveFloorBG {
  position: absolute;
  z-index: 500;
  width: 48px;
  background-color: #fff;
  border-radius: 5px;
  visibility: hidden;
}
/* stylelint-disable-next-line selector-id-pattern */
#moveFloor {
  position: absolute;
  bottom: 2px;
  left: 2px;
  z-index: -1;
  width: 48px;
  height: 48px;
  background-color: #dbb186;
  border-radius: 5px;
  opacity: 1;
}
/* stylelint-disable-next-line selector-class-pattern */
#floorBox {
  position: absolute;
  z-index: 128;
}
.other-pop {
  position: fixed;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 24px;
  font-size: 16px;
  color: #fff;
  background: #ad9c85;
  border: 2px solid #fff;
  border-radius: 20px;
  line-height: 24px;
  user-select: none;
}

.wave-wrapper {
  position: absolute;
  top: 119px;
  left: -404px;
  z-index: 1;
  width: 1484px;
  height: 230px;
  background-position: left bottom;
  // background-image: url('@/assets/images/map/bg.svg');
  background-repeat: no-repeat;
  transition: all 0.3s linear;
  img {
    position: absolute;
    top: 24px;
    left: 448px;
    z-index: 2;
    &.mask-map {
      top: -119px;
      left: 404px;
      z-index: 1;
      width: 1080px;
    }
  }
  .mask-top {
    position: absolute;
    top: 100px;
    left: 404px;
    z-index: 2;
    width: 1080px;
    height: 150px;
    pointer-events: none;
  }
}
.language-items {
  position: absolute;
  top: 123px;
  left: 896px;
  z-index: 2;
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  height: 40px;
  background: rgb(0 0 0 / 10%);
  border-radius: 4px;
}
.language-item {
  width: 40px;
  height: 40px;
  font-size: 14px;
  font-family: 'font_bold';
  text-align: center;
  color: #fff;
  border-radius: 4px;
  line-height: 40px;
  &.active {
    background: rgb(0 0 0 / 20%);
  }
}

.title-container {
  position: absolute;
  top: 285px;
  right: 64px;
  z-index: 2;
  display: flex;
  align-items: center;
  font-size: 20px;
  font-family: 'font_bold';
  text-align: right;
  white-space: pre-wrap;
  color: rgb(0 0 0 / 60%);
  text-transform: uppercase;
  span:nth-child(1) {
    line-height: 29px;
    width: fit-content;
  }
  span:nth-child(3) {
    font-size: 48px;
    color: rgb(0 0 0 / 90%);
  }
  svg {
    display: inline-block;
    margin-right: 16px;
    margin-left: 16px;
  }
}
</style>
