<template>
  <View>
    <div class="nav-methods animate__animated animate__fadeInUp animate__faster">
      <div class="r1">导航到</div>
      <div class="r2">{{ shop.shopName }}</div>
      <div class="r3">
        <div
          class="box w-200 mr-8"
          @click="handleControl(item.name, index)"
          v-for="(item, index) of methodsList"
          :key="item.name"
          :class="{ active: methodIdx === index }"
        >
          <img :src="item.icon" class="box-icon mr-20 z-index" alt="" />
          <div class="box-right z-index">
            <p class="name">{{ item.name }}</p>
          </div>
        </div>
      </div>
      <div class="back" @click="$router.back()"></div>
    </div>

    <PassShop :shop="shop" :current-floor="currentFloor" :direction="directionInfo" :config="config" :list="pathShopList" />
  </View>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/root'
import View from '@/layouts/View.vue'
import { methodsList } from './methodsList'
import { useMapNavControl } from '@/composables/useMapNavControl'
import { useChangeNavMethod } from '@/composables/useChangeNavMethod'
import { useStartNavi } from '@/composables/useStartNavi'
import PassShop from './children/PassShop.vue'
import { useStatistics } from '@/composables/useStatistics'

const store = useStore()
const { shop, currentFloor, config } = storeToRefs(store)

const { setPause } = useMapNavControl()
const { directionInfo, pathShopList, backPathArray } = useStartNavi(shop, currentFloor, setPause)
const { methodIdx, handleControl } = useChangeNavMethod(backPathArray)

useStatistics('navigation')
</script>

<style lang="scss" scoped>
.top-right-wrapper {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 130px;
  height: 499px;
  left: 0;
  top: 0px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
  z-index: 51;
  backdrop-filter: blur(20px);
}
.mr-20 {
  margin-right: 20px;
}
.hands {
  position: fixed;
  top: 37px;
  right: 170px;
  width: 246px;
  z-index: 51;
}
.back-icon {
  width: 132px;
  margin-left: 22px;
  margin-bottom: 16px;
}
.nav-methods {
  position: absolute;
  width: 100vw;
  height: 260px;
  left: 0;
  background: linear-gradient(113.71deg, #435acd 0%, #749cf3 100%);
  bottom: 688px;
  z-index: 51;
  padding-top: 30px;
  padding-left: 68px;
  .r1 {
    font-weight: 700;
    font-size: 24px;
    line-height: 28px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
  }
  .r2 {
    font-weight: 700;
    font-size: 40px;
    line-height: 47px;
    color: #ffffff;
    margin-bottom: 25px;
  }
  .r3 {
  }
  .back {
    position: absolute;
    width: 180px;
    height: 180px;
    left: 832px;
    top: 40px;
    background: center / cover no-repeat url(./back.png);
  }

  .rotate {
    @include rotate(-360deg, 1);
    animation-duration: 0.5s;
  }
  .box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 80px;
    text-align: center;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, #ffffff 100%);

    .box-icon {
      position: relative;
      display: block;
      width: 34px;
      height: 34px;
      flex-shrink: 0;
    }
    .box-right {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
    }
    .name {
      font-weight: 700;
      font-size: 16px;
      line-height: 19px;
      color: rgba(0, 0, 0, 0.8);
    }

    &.active {
      background: linear-gradient(99.5deg, #f0b92b 0%, #f9d556 100%);
    }
  }

  .mr-8 {
    margin-right: 8px;
  }

  .w-200 {
    width: 200px;
  }
  .z-index {
    z-index: 5;
  }
}
</style>
