<template>
  <div class="login">
    <div class="login-box">
      <!--      <img
              v-if="activeName !== 'codeLogin'"
              alt=""
              class="login-change"
              src="@/assets/img/login/code-login.png"
              @click="activeName = 'codeLogin'"
            />
            <img
              v-else
              alt=""
              class="login-change"
              src="@/assets/img/login/password-login.png"
              @click="activeName = 'accountLogin'"
            />-->
      <!--   账号和手机号登录   -->
      <template v-if="activeName !== 'codeLogin'">
        <div class="login-box-header">
          <img :src="manageLogoPath" alt="" />
          <span class="title">{{ systemInformation.name }}</span>
        </div>
        <div class="login-box-content">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="账号登录" name="accountLogin"
              >账号登录
            </el-tab-pane>
            <!-- <el-tab-pane label="短信登录" name="phoneNumberLogin"
                >短信登录</el-tab-pane
            > -->
          </el-tabs>
          <div class="tab-content">
            <!--    账号登录      -->
            <AccountLogin
              v-if="activeName === 'accountLogin'"
              :systemInformation="systemInformation"
            />
            <!--    短信登录      -->
            <!-- <PhoneNumberLogin
                v-if="activeName === 'phoneNumberLogin'"
            /> -->
            <!--    验证码登录      -->
          </div>
        </div>
        <div class="login-box-footer">
          <div class="footer-title">忘记密码请联系管理员</div>
        </div>
      </template>
      <!--   二维码登录   -->
      <template v-else>
        <CodeLogin />
      </template>
    </div>
  </div>
</template>

<script>
import AccountLogin from './components/AccountLogin.vue'
import PhoneNumberLogin from './components/PhoneNumberLogin.vue'
import CodeLogin from './components/CodeLogin.vue'
import {mapActions, mapGetters, mapMutations, mapState} from 'vuex'

export default {
  name: 'Login',
  props: ['tenant'],
  components: {CodeLogin, PhoneNumberLogin, AccountLogin},
  data() {
    return {
      activeName: 'accountLogin'
    }
  },
  computed: {
    ...mapGetters('system', ['manageLogoPath']),
    ...mapState('system', ['systemInformation'])
  },
  created() {
    this.getSystemInformation().then(() => this.SET_FAVICON()) // 获取系统信息并设定项目icon
  },
  methods: {
    ...mapActions('system', ['getSystemInformation']),
    ...mapMutations('system', ['SET_FAVICON']),

    handleClick() {}
  }
}
</script>
<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100%;
  background: url('~@/assets/img/login/bgImg.png') no-repeat 0 0;
  background-size: 100% 100%;
  //background-size: cover;
  position: relative;
  user-select: none;

  .welcome-text {
    position: absolute;
    left: 4%;
    top: 4.5%;
    width: 500px;
    user-select: none;
    -webkit-user-drag: none;
  }

  .login-box {
    width: 550px;
    //min-height: 500px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    right: 11%;
    top: 50%;
    transform: translateY(-50%);
    position: absolute;
    box-shadow: rgba(50, 50, 93, 0.25) 0 6px 12px -2px,
      rgba(0, 0, 0, 0.3) 0 3px 7px -3px;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    .login-change {
      position: absolute;
      width: 70px;
      top: 5px;
      right: 5px;
      cursor: pointer;
    }

    .login-box-header {
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: PingFangSC-Medium, serif;
      color: rgb(18, 100, 189);
      //flex-direction: column;
      row-gap: 20px;
      column-gap: 20px;
      padding: 80px 0 30px 0;

      .title {
        font-size: 22px;
        text-align: center;
        font-family: PingFang SC, serif;
        font-weight: bold;
        color: #333;
      }

      img {
        width: 80px;
      }
    }

    .login-box-content {
      padding: 0 40px;
      display: flex;
      flex-direction: column;

      ::v-deep .el-tabs {
        height: auto;

        .el-tabs__header {
          margin-bottom: 30px;

          .el-tabs__nav-wrap {
            &::after {
              background-color: transparent;
            }
          }

          .el-tabs__active-bar {
            color: rgb(18, 100, 189);
            height: 2.5px;
          }

          .el-tabs__item {
            height: 45px;
            padding: 0 10px;
            font-size: 18px;
            transition: all 0.2s;

            &:nth-child(2) {
              padding-left: 0;
            }

            &:hover {
              color: rgb(18, 100, 189);
            }

            &.is-active {
              color: rgb(18, 100, 189);
            }
          }
        }

        .el-tabs__content {
          display: none;
        }
      }

      .tab-content {
        flex: 1;
      }
    }

    .login-box-footer {
      flex: 1;
      padding: 20px 0;

      .footer-title {
        text-align: center;
        font-family: PingFangSC-Medium;
        font-size: 15px;
        margin-bottom: 20px;
      }
    }
  }
}
</style>
