<template>
  <div class="app-wrap">
    <div class="top-bar">
      <img
        class="logo"
        src="@/assets/images/logo.png"
        alt=""
        draggable="false"
      >
      <menu class="tab-bar">
        <button
          :class="{
            active: $route.meta.tabIdx === 1
          }"
          @click="$router.push({
            name: 'HomeView'
          })"
        >
          要素地图
        </button>
        <button
          :class="{
            active: $route.meta.tabIdx === 2
          }"
          @click="$router.push({
            name: 'CityOfXishan'
          })"
        >
          锡善云城
        </button>
        <button
          :class="{
            active: $route.meta.tabIdx === 3
          }"
          @click="$router.push({
            name: 'MuseumView'
          })"
        >
          慈善博物馆
        </button>
        <!-- <button
          :class="{
            active: $route.meta.tabIdx === 4
          }"
          @click="$router.push({
            name: 'CloudSchool'
          })"
        >
          慈善云学校
        </button>
        <button
          :class="{
            active: $route.meta.tabIdx === 5
          }"
          @click="$router.push({
            name: 'SquareView'
          })"
        >
          慈善广场
        </button>
        <button
          :class="{
            active: $route.meta.tabIdx === 6
          }"
          @click="onClickLoveForest"
        >
          爱心林场
        </button>
        <button
          :class="{
            active: $route.meta.tabIdx === 7
          }"
          @click=" router.push({
            name: 'CharityHall'
          })"
        >
          慈善堂
        </button> -->
        <button
          :class="{
            active: $route.meta.tabIdx === 8
          }"
          @click="onClickFeedBack"
        >
          留言反馈
        </button>
      </menu>
      <div class="right-button-wrap">
        <button
          class="shop"
          :class="{
            active: $route.meta.tabIdx === 9

          }"
          @click="onClickShop"
        />
        <button
          class="user"
          @click="router.push({
            name: 'CityOfXishan',
            query: {
              scene: 4,
            }
          })"
        />
      </div>
    </div>

    <FeedBack
      v-if="isShowFeedBack"
      @close="isShowFeedBack = false"
    />

    <div class="content-area">
      <router-view />
    </div>
  </div>
</template>

<script setup>
import { ref, computed, watch, onMounted } from "vue"
import { useRoute, useRouter } from "vue-router"
import { useStore } from "vuex"
import FeedBack from "@/components/FeedBack.vue"
import { ElMessageBox } from 'element-plus'
import {
  // checkLoginStatusAndProcess,
  getUserFromStorageIfNeed,
} from '@/api.js'

const route = useRoute()
const router = useRouter()
const store = useStore()

store.commit('getPageVisitRecordFromStorage')
// checkLoginStatusAndProcess()
getUserFromStorageIfNeed()

const isShowFeedBack = ref(false)
function onClickFeedBack() {
  if (process.env.VUE_APP_CLI_MODE === 'dev' || store.state.loginStatus === store.getters.loginStatusEnum.wxUser) {
    isShowFeedBack.value = true
  } else {
    location.href = `https://open.weixin.qq.com/connect/qrconnect?appid=wx3d4f2e0cfc3b8e54&redirect_uri=https%3A%2F%2Fsit-wuxicishan.4dage.com%2F%23%2Flogin-temp&response_type=code&scope=snsapi_login&state=${encodeURIComponent(route.name)}#wechat_redirect`
  }
}

function onClickShop() {
  if (process.env.VUE_APP_CLI_MODE === 'dev' || store.state.loginStatus === store.getters.loginStatusEnum.wxUser) {
    router.push({
      name: 'ShopView'
    })
  } else {
    location.href = `https://open.weixin.qq.com/connect/qrconnect?appid=wx3d4f2e0cfc3b8e54&redirect_uri=https%3A%2F%2Fsit-wuxicishan.4dage.com%2F%23%2Flogin-temp&response_type=code&scope=snsapi_login&state=${encodeURIComponent('ShopView')}#wechat_redirect`
  }
}
</script>

<style lang="less">
html, body {
  // overscroll-behavior: none;
  // overflow: hidden;
  height: 100%;
}

// * {
//   user-select: none;
//   -webkit-touch-callout: none;
// }

#app {
  height: 100%;
}

// // 360浏览器不支持not()
// input, textarea {
//   user-select: initial;
// }

// 字体
@font-face {
  font-family: 'Source Han Sans CN';
  src: url('@/assets/style/SOURCEHANSANSCN-LIGHT.OTF');
  // src: url('@/assets/style/SourceHanSansCN-Regular.otf');
}
// @font-face {
//   font-family: 'Source Han Serif CN-Bold';
//   src: url('@/assets/style/SourceHanSerifCN-Bold.otf');
// }
@font-face{
  font-family: 'Source Han Serif CN';
  src: url('@/assets/style/SourceHanSerifCN-Regular.otf');
}
// i {
//   font-style: italic;
// }

// 滚动条，只设置某一项可能导致不生效。
&::-webkit-scrollbar { background: transparent; width: 6px; height: 0; }
&::-webkit-scrollbar-thumb { background: #589498; opacity: 0.5; border-radius: 3px;}


// vue组件过渡效果
.fade-out-leave-active {
  transition: opacity 1s;
  pointer-events: none;
}
.fade-out-leave-to {
  opacity: 0;
}

// vue组件过渡效果
.fade-in-enter-active {
  transition: opacity 1s;
}
.fade-in-enter-from {
  opacity: 0;
}

.fade-in-out-enter-active {
  transition: opacity 2s;
}
.fade-in-out-leave-active {
  transition: opacity 2s;
  pointer-events: none;
}
.fade-in-out-enter-from {
  opacity: 0;
}
.fade-in-out-leave-to {
  opacity: 0;
}

// 不断渐变显隐 animation
.animation-show-hide {
  animation: show-hide 1.8s infinite;
}
@keyframes show-hide {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

// // vue-viewer
// .viewer-container {
//   background-color: rgba(0, 0, 0, 80%) !important;
// }
// 或者
// .viewer-backdrop {
//   background-color: rgba(0, 0, 0, 90%) !important;
// }
</style>

<style lang="less" scoped>
.app-wrap{
  height: 100%;
  display: flex;
  flex-direction: column;
  background-image: url(@/assets/images/bg.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  >.top-bar{
    flex: 0 0 auto;
    height: 89px;
    background: linear-gradient( 180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.3) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-around;
    >img.logo{
      flex: 0 0 auto;
    }
    >menu.tab-bar{
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 55px;
      @media only screen and (max-width: 1500px) {
        gap: 20px;
      }
      @media only screen and (max-width: 1250px) {
        gap: 10px;
      }
      >button{
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 22px;
        color: #FFFFFF;
        line-height: 26px;
        position: relative;
        z-index: 0;
        &:hover{
          font-weight: bold;
          color: #589498;
        }
        &.active{
          font-weight: bold;
          color: #589498;
          perspective: 1000px;
          &::before{
            content: '';
            display: block;
            position: absolute;
            width: 127px;
            height: 8px;
            background: #589498;
            clip-path: polygon(0 0, 100% 0, 97% 100%, 3% 100%);
            left: 50%;
            top: -31px;
            transform: translate(-50%, 0);
          }
          &::after{
            content: '';
            display: block;
            position: absolute;
            z-index: -1;
            width: 100%;
            top: 100%;
            height: 12px;
            background: #FFE794;
            filter: blur(15.945178985595703px);
          }
        }
      }
    }
    >.right-button-wrap{
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 14px;
      >button.shop{
        width: 42px;
        height: 42px;
        background-image: url(@/assets/images/icon_shop.png);
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
        &:hover, &.active{
          background-image: url(@/assets/images/icon_shop-active.png);
          background-size: cover;
          background-repeat: no-repeat;
          background-position: center center;
        }
      }
      >button.user{
        width: 42px;
        height: 42px;
        background-image: url(@/assets/images/icon_user.png);
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
        &:hover{
          background-image: url(@/assets/images/icon_user-active.png);
          background-size: cover;
          background-repeat: no-repeat;
          background-position: center center;
        }
      }
    }
  }
  >.content-area{
    flex: 1 0 1px;
    position: relative;
  }
}
</style>