<template>
  <div class="navbar flex justify-between items-center">
    <div class="flex items-center gap-[10px]">
      <van-image class="logo" :src="logoIcon" />
      <span>三优云试剂管家</span>
    </div>
    <van-icon name="wap-nav" @click="goMenu" class="menu-icon" :src="menuIcon" />
  </div>
  <van-popup 
    v-model:show="show"
    class="menu-popup" 
    position="left" 
    duration="0.4"
    :transition-appear="true" 
    :style="{ width: '80%', height: '100%' }"
    @close="handleClose" >
    <div class="menu-container">
      <div class="menu-header">
        <van-image class="logo" :src="logoIcon" />
        
        <div class="menu-header-title">三优云试剂管家</div>
      </div>
      <div class="menu-list">
        <div class="menu-item" @click="goAbout">
          <div class="menu-item-icon">
            <van-icon name="miniprogram-o" />
          </div>
          <div class="menu-item-title" :class="{ active: currentTag === 'about' }">关于三优</div>
          <div v-if="currentTag === 'about'" class="menu-item-arrow">
            <van-icon name="success" />
          </div>
        </div>
        <div class="menu-item" :class="{ active: currentTag === 'home' }" @click="goIndex">
          <div class="menu-item-icon">
            <van-icon name="home-o" />
          </div>
          <div class="menu-item-title">首页</div>
          <div v-if="currentTag === 'home'" class="menu-item-arrow">
            <van-icon name="success" />
          </div>
        </div>
        <div class="menu-item" :class="{ active: currentTag === 'contact' }" @click="goContact">
          <div class="menu-item-icon">
            <van-icon name="phone-o" />
          </div>
          <div class="menu-item-title">联系我们</div>
          <div v-if="currentTag === 'contact'" class="menu-item-arrow">
            <van-icon name="success" />
          </div>
        </div>
      </div>
      <div class="menu-footer">
        <div class="w-full">
          <img class="w-full" src="../assets/Vector 21.png" alt="" />
        </div>
        <div class="menu-footer-item">@ 三优生物医药（上海）有限公司</div>
      </div>
    </div>

   
    </van-popup>
</template>

<script setup>
import { defineProps, ref } from "vue";
import { useRouter } from 'vue-router';
import logoIcon from '../assets/image 111.png';
import menuIcon from '../assets/menu.png';

// 接收父组件传递的 activeTag
const props = defineProps({
  activeTag: {
    type: String,
    default: "home", // 可以定义默认值
  },
});

const currentTag = ref(props.activeTag);

const router = useRouter();

const goIndex = () => {
  currentTag.value = 'home';
  router.push('/');
};

const goContact = () => {
  currentTag.value = 'contact';
  router.push('/contact');
};

const goAbout = () => {
  currentTag.value = 'about';
  window.location.href = 'https://www.sanyoubio.com.cn';
};

const show = ref(false);
const isRotated = ref(false);

const goMenu = () => {
  // isRotated.value = !isRotated.value;
  show.value = true;
}

const handleClose = () => {
  isRotated.value = false;
  show.value = false;
}
</script>

<style lang="less" scoped>
.menu-popup {
  width: 100%;
  height: 100%;
  background: #00203b;
  color: #ffffff;
  .menu-container {
    width: 100%;
    height: 100%;
    padding: 50px 0;
    .menu-header {
      display: flex;
      align-items: center;
      justify-content: start;
      padding: 10px 40px;
      
      .menu-header-title {
        font-size: 20px;
        font-weight: 600;
        margin-left: 10px;
      }
    }
  }
  .menu-list {
    margin-top: 50px;
    .menu-item {
      height: 64px;
      line-height: 64px;
      font-size: 16px;
      margin-bottom: 20px;
      padding-left: 40px;
      display: flex;
      align-items: center;
      position: relative;
      &.active {
        background: rgb(31, 60, 100);
        .menu-item-icon {
          font-weight: bold;
          color: #000000;
          background: #fff;
        }
      }
      .menu-item-icon {
        width: 37px;
        height: 37px;
        font-size: 20px;
        background-color: rgb(45, 73, 110);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 20px;
        }
      .menu-item-arrow {
        position: absolute;
        right: 40px;
        font-size: 20px;
        top: 0;
        bottom: 0;
        right: 40px;
        margin: auto;
      }
    }
  }
  .menu-footer {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    width: 100%;  
    height: 60px;
    .menu-footer-item {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 44px;
      line-height: 44px;
      font-size: 12px;
      // padding-left: 40px;
    }
  }
}
.navbar {
  width: 100%;
  height: 44px;
  min-height: 44px;
  background: #fff;
  padding: 0 16px;
  color: rgb(66, 110, 163);
  font-size: 16px;
  font-weight: 600;

}
.logo {
  width: 63px;
  height: 28px;
}
.menu-icon {
  font-size: 24px;
  color: #000;
  transition: transform 0.3s ease;
  &.rotate {
    transform: rotate(90deg);
  }
}
</style>
