<template>
    <div class="page-account">
        <div v-if="showI18n" class="page-account-header">
            <i-header-i18n />
        </div>
        <div class="page-account-container">
            <div class="page-account-top">
                <div class="page-account-top-logo">
                    <img src="@/assets/images/logo.png" alt="logo">
                </div>
                <div class="page-account-top-desc">微服务架构平台</div>
            </div>
            <Login @on-submit="handleSubmit">
                <UserName name="account" value="abcdefg" placeholder="请输入工号" :rules="pernr" enter-to-submit/>
                <!-- <UserName name="username" value="admin" />
                <Password name="password" value="admin" enter-to-submit />
                <div class="page-account-auto-login">
                    <Checkbox v-model="autoLogin" size="large">{{ $t('page.login.remember') }}</Checkbox>
                    <a href="">{{ $t('page.login.forgot') }}</a>
                </div> -->
                <Submit>{{ $t('page.login.submit') }}</Submit>
            </Login>
            <!-- <div class="page-account-other">
                <span>{{ $t('page.login.other') }}</span>
                <img src="@/assets/svg/icon-social-wechat.svg" alt="wechat">
                <img src="@/assets/svg/icon-social-qq.svg" alt="qq">
                <img src="@/assets/svg/icon-social-weibo.svg" alt="weibo">
                <router-link class="page-account-register" :to="{ name: 'register' }">{{ $t('page.login.signup') }}</router-link>
            </div> -->
        </div>
        <!-- <i-copyright /> -->
    </div>
</template>
<script>
    import iCopyright from '@/components/copyright';
    import { mapActions } from 'vuex';
    import mixins from '../mixins';

    export default {
        name:'plat-login',
        mixins: [ mixins ],
        components: { iCopyright },
        data () {
            return {
                autoLogin: true,
                pernr: [
                    { required: true, message: '请输入工号', trigger: 'blur' }
                ]
            }
        },
        methods: {
            ...mapActions('admin/account', [
                'login'
            ]),
            /**
             * @description 登录
             * 表单校验已有 iView Pro 自动完成，如有需要修改，请阅读 iView Pro 文档
             */
            handleSubmit (valid, values) {
                if (valid) {
                    // const { username, password } = values;
                    const { account } = values;
                    this.login({
                        // username,
                        // password
                        account
                    })
                        .then(() => {
                            // 重定向对象不存在则返回顶层路径
                            this.$router.replace(this.$route.query.redirect || '/');
                    });
                }
            }
        }
    };
</script>
