<template>
    <div class="login">
        <div class="welcome-text">{{ systemName }}</div>
        <div class="login-box">
            <template v-if="activeName !== 'codeLogin'">
                <div class="login-box-header">
                    <img src="@/assets/img/login/logo-gyl.png" alt="" />
                    <span class="title">{{ systemName }}</span>
                </div>
                <div class="login-box-content">
                    <el-tabs v-model="activeName">
                        <el-tab-pane label="账号登录" name="accountLogin">账号登录</el-tab-pane>
                    </el-tabs>
                    <div class="tab-content">
                        <!--    账号登录      -->
                        <AccountLogin v-if="activeName === 'accountLogin'" />
                    </div>
                </div>
                <div class="login-box-footer">
                    <div class="footer-title">忘记密码请联系管理员</div>
                </div>
            </template>
        </div>
        <div class="mask" v-if="showMask">
            <el-icon class="is-loading" size="40" color="rgba(255, 255, 255, 0.3)">
                <loading />
            </el-icon>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import AccountLogin from './components/AccountLogin.vue'
import { sysInfoQuery } from '@/api/system/sysinfo'

const route = useRoute()
const activeName = ref('accountLogin')
const systemName = ref('')
const showMask = ref(true)

onMounted(() => {
    if (!route.query || !route.query.tokenKey) {
        showMask.value = false
    }
    sysInfoQuery('platform').then((res) => {
        systemName.value = res?.name || ''
    })
})
</script>

<style lang="scss" scoped>
.mask {
    position: fixed;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgb(17, 64, 102);
    z-index: 99;
}
.login {
    width: 100%;
    height: 100%;
    background: url('@/assets/img/login/bgImg.png') no-repeat 0 0;
    background-size: 100% 100%;
    position: relative;
    user-select: none;

    .welcome-text {
        position: absolute;
        left: 4%;
        top: 10%;
        user-select: none;
        -webkit-user-drag: none;
        font-family: FZZhengHei;
        font-weight: bolder;
        font-size: 66px;
        color: #fff;
        // font-style: italic;
        letter-spacing: 4px;
        text-shadow: 0 2px 10px rgb(40, 88, 221);
        transform: skewX(-6deg);
    }

    .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;
            color: rgb(18, 100, 189);
            flex-direction: column;
            row-gap: 20px;
            padding: 60px 0 30px 0;

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

            img {
                width: 200px;
            }
        }

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

            :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>
