<template>
  <div class="login-container">
    <div class="login-logo">
      <div style="cursor: pointer;">Fast亼算云</div>
      <a-menu v-model:selectedKeys="current" mode="horizontal" style="border-bottom: none;" :items="rightRoutes"
        @click="({ key }) => handleMenuClick(key)" />
    </div>
    <div class="login-content">
      <div class="login-content-main">
        <div class="login-content-title" v-if="currentTag === 'login'">
          <span :style="{ color: currentTag === 'login' && state.tabsActiveName === 'account' ? '#000' : '#666' }"
            style="cursor: pointer;" @click="state.tabsActiveName = 'account'">密码登录</span>
          <span style="margin: 0 10px;color: #666;">|</span>
          <span :style="{ color: currentTag === 'login' && state.tabsActiveName === 'code' ? '#000' : '#666' }"
            style="cursor: pointer;" @click="state.tabsActiveName = 'code'">手机登录</span>
        </div>
        <div v-if="currentTag === 'login'">
          <Account v-if="currentTag == 'login' && state.tabsActiveName === 'account'" />
          <Code v-if="currentTag == 'login' && state.tabsActiveName === 'code'" />

          <div style="width: 100%;display: flex;justify-content: space-between;font-size: 14px;">
            <div v-if="state.tabsActiveName === 'account'"> <a-checkbox v-model:checked="checked">记住密码</a-checkbox></div>
            <div>
              <span style="color:#1677ff;cursor: pointer;" @click="currentTag = 'register'">注册</span>
              <span style="color: #666666;margin: 0 5px;">|</span>
              <span style="color:#1677ff;cursor: pointer;" @click="currentTag = 'updatePwd'">忘记密码</span>
            </div>
          </div>
          <div
            style="width: 100%;display: flex;align-items: center;justify-content: space-around;margin: 20px 0;gap: 10px;">
            <div style="height: 1px;width: 100%;background: #c9c9c9;"></div>
            <div style="width: 80px;font-size: 14px;color: rgba(166, 166, 166, 1);">或者</div>
            <div style="height: 1px;width: 100%;background: #c9c9c9;"></div>
          </div>
          <div
            style="width: 100%;display: flex;justify-content: center;align-items: center;gap: 10px;cursor: pointer;height: 45px;border-radius:25px; border: 1px solid rgba(229, 229, 229, 1);">
            <img src="@/assets/weixin.png" alt="" srcset="" width="20spx">
            <span>使用微信扫码登录</span>
          </div>
        </div>
        <div v-if="currentTag == 'register'">
          <div>
            <Register />
            <div style="text-align: right;">
              <span style="color: #666;cursor: pointer;font-size: 14px;" @click="currentTag = 'login'">
                已有账号？去 <span style="color: #1677ff;">登录</span></span>
            </div>
          </div>
        </div>
        <div v-else-if="currentTag == 'updatePwd'">
          <div style="color: #666;cursor: pointer;font-size: 14px;">
            <UpdatePwd />
            <span style="color: #666;cursor: pointer;font-size: 14px;" @click="currentTag = 'login'">
              < 返回</span>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="login-copyright">
  </div>

</template>

<script setup lang="ts">
import { reactive, computed, ref } from "vue";
import Account from "@/views/login/component/account.vue";
import Code from "@/views/login/component/code.vue";
import Register from "./component/register.vue";
import UpdatePwd from "./component/updatePwd.vue";
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
// import Mobile from "@/views/login/component/mobile.vue";
// import Scan from "@/views/login/component/scan.vue";
// import { useThemeConfigStateStore } from "@/stores/themeConfig";
// const theme = useThemeConfigStateStore();
const currentTag = ref('login');//login:登录；register:注册；updatePwd:修改密码
const current = ref('');// 当前选中的菜单项
const rightRoutes = ref([
  { key: '/home', label: '首页' },
  { key: '/document', label: '用户文档' },
  { key: '/admin/home', label: '控制台' }
])
const checked = ref(false);
const state = reactive({
  tabsActiveName: "account",
  isTabPaneShow: true,
  isScan: false,
});
// 获取布局配置信息
// const getThemeConfig = computed(() => {
//   return theme.themeConfig;
// });
// 切换密码、手机登录
const onTabsClick = () => {
  state.isTabPaneShow = !state.isTabPaneShow;
};
// 点击菜单跳转
const handleMenuClick = (key) => {
  if (key === '/document') {
    window.open(key, '_blank');
  } else {
    // 否则按照正常方式在当前标签页跳转
    const fullPath = `/layout${key}`;
    router.push(fullPath);
  }
}
</script>

<style scoped lang="scss">
.login-container {
  width: 100%;
  height: 100vh;
  background: url("@/assets/login.png") no-repeat;
  background-size: 100% 100%;

  .login-logo {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.2);
    top: 0px;
    left: 50%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content:space-between;
    font-size: 20px;
    color: var(--color-primary);
    letter-spacing: 2px;
    width: 100%;
    padding: 0 20px;
    border-bottom: 1px solid #C9C9C9;
    transform: translateX(-50%);
  }

  .login-content {
    border-radius: 15px;
    box-shadow: 0px 19px 39px rgba(222, 225, 255, 1);
    width: 405px;
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 78%;
    transform: translate(-50%, -50%) translate3d(0, 0, 0);
    background-color: rgba(255, 255, 255, 0.99);
    transition: height 0.2s linear;
    height: 520px;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 1;

    .login-content-main {
      margin: 0 auto;
      width:90%;
      .login-content-title {
        color: #333;
        font-weight: 500;
        font-size: 22px;
        text-align: center;
        letter-spacing: 4px;
        margin: 30px 0 45px 0;
        white-space: nowrap;
        z-index: 5;
        position: relative;
        transition: all 0.3s ease;
      }
    }

    .login-content-icon {
      font-size: 25px;
      margin-right: 30px;
    }

    .login-content-main-sacn {
      position: absolute;
      top: 0;
      right: 0;
      width: 50px;
      height: 50px;
      overflow: hidden;
      cursor: pointer;
      transition: all ease 0.3s;

      &-delta {
        position: absolute;
        width: 35px;
        height: 70px;
        z-index: 2;
        top: 2px;
        right: 21px;
        background: var(--el-color-white);
        transform: rotate(-45deg);
      }

      &:hover {
        opacity: 1;
        transition: all ease 0.3s;
        color: var(--color-primary);
      }

      i {
        width: 47px;
        height: 50px;
        display: inline-block;
        font-size: 48px;
        position: absolute;
        right: 2px;
        top: -1px;
      }
    }
  }

  .login-content-mobile {
    height: 460px;
  }

  .login-copyright {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    text-align: center;
    color: var(--color-whites);
    font-size: 12px;
    opacity: 0.8;

    .login-copyright-company {
      white-space: nowrap;
    }

    .login-copyright-msg {
      @extend .login-copyright-company;
    }
  }
}
</style>
