<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>招生管理系统</title>
    <!-- import CSS -->
    <link rel="stylesheet" href="/njs/element-ui-2.13.2/index.css">

    <style>

        html, body {margin:0;}
        .login-container {
            width: 400px;
            margin: auto;
            margin-top: 50px;
        }
        .login-container .el-form {
            background: #ffffff30;
            padding: 10px 30px 15px;
            margin-top: 15px;
        }
        .login-container .title-container {
            text-align: center;
        }
        .login-container .title-container .title {
            font-weight: 500;
            color: #fff;
        }
        .login-container .el-input input {
            background: #fff;
            -webkit-appearance: none;
            border-radius: 0px;
            padding: 10px 5px 10px 15px;
            height: 40px;
        }
        .login-container .el-form-item {
            border-radius: 5px;
            color: #454545;
            margin-bottom: 15px;
        }
        .el-form-item__error {
            padding-top: 0;
            color: red;
        }
        .el-form-item__content {
            line-height: initial;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="login-container">
        <div class="title-container">
            <img src="/assets/images/logo.png" width="100" />
        </div>
        <el-form ref="dataForm" :model="dataForm" :rules="dataRule" class="login-form" auto-complete="on" label-position="left">
            <div class="title-container">
                <h2 class="title">招生管理系统</h2>
            </div>
            <el-form-item prop="loginName">
                <el-input v-model="dataForm.loginName" placeholder="帐号"></el-input>
            </el-form-item>
            <el-form-item prop="pwd">
                <el-input v-model="dataForm.pwd" type="password" placeholder="密码"></el-input>
            </el-form-item>
            <el-form-item prop="captcha">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-input v-model="dataForm.captcha" placeholder="验证码" maxlength="5">
                        </el-input>
                    </el-col>
                    <el-col :span="12" class="login-captcha">
                        <img :src="captchaPath" @click="getCaptcha()" alt="" height="40">
                    </el-col>
                </el-row>
            </el-form-item>
            <el-form-item>
                <el-button class="login-btn-submit" type="primary" @click="dataFormSubmit()">登录</el-button>
                <el-button class="login-btn-submit" type="primary" @click="SSOlogin()">统一身份认证登录</el-button>
            </el-form-item>
        </el-form>
    </div>
    <div class="backstretch" style="left: 0px; top: 0px; overflow: hidden; margin: 0px; padding: 0px; height: 100%; width: 100%; z-index: -999999; position: fixed;">
        <img style="position: absolute; margin: 0px; padding: 0px; border: none; width: 100%; height: 100%; max-width: none; z-index: -999999; left: 0; top: 0;" src="/assets/img/bg/3.jpg">
    </div>
</div>
</body>
<!-- import Vue before Element -->
<script type="text/javascript" src="/njs/vue-dev/dist/vue.js"></script>
<script type="text/javascript" src="/njs/vue-dev/axios.min.js"></script>
<!-- import JavaScript -->
<script src="/njs/element-ui-2.13.2/index.js"></script>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<!-- 生产环境版本，优化了尺寸和速度 -->
<script src="/assets/global/plugins/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="/njs/JSEncrypt/jsencrypt.min.js"></script>
<script type="text/javascript">
    var Main = {
        data() {
            return {
                dataForm: {
                    loginName: '',
                    pwd: '',
                    captcha: ''
                },
                dataRule: {
                    loginName: [
                        { required: true, message: '帐号不能为空', trigger: 'blur' }
                    ],
                    pwd: [
                        { required: true, message: '密码不能为空', trigger: 'blur' }
                    ],
                    captcha: [
                        { required: true, message: '验证码不能为空', trigger: 'blur' }
                    ]
                },
                captchaPath: ''
            }
        },
        created() {
            this.getCaptcha();
        },
        methods: {
            // 提交表单
            dataFormSubmit () {
                var _this = this
                this.$refs['dataForm'].validate((valid) => {
                    if (valid) {
                        const encrypt = new JSEncrypt();
                        encrypt.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmftpYJ/Z/c+y2AbzshsZNVOq2eK/BNOgUhbB3zJWaWrFDmE8COo/t8DK1h3S5DvJd+OeSdvNsqdLdLhYGpCBPVdlI1zi4jsR3ZMF6DOxcp59thTat1boVHVhbBwuAejXVQNj+YQy+6jiZ9YL5ou1306ZurLW6jPACU8nSU0POL6zhU+ToZOaTh4J3FfUAt7XXA+RsjCgRd1dAuL2lwz4jBmXd8fLiR9DoIWudGFGYXzCTrPlpUZYg7k/hhqM3xI9vi3TPBLis0S97pUlgZZ43Mr9NWLvDHZZkzQksOh257PXPUnpwtQ4s0rLRyKQlsPRsUOU3NOKrKwOs+mRrMAS2QIDAQAB");
                        const pwd = encrypt.encrypt(this.dataForm.pwd);

                        axios.post('/sys/login', {
                            loginName: this.dataForm.loginName,
                            pwd: pwd,
                            captcha:this.dataForm.captcha,
                        }).then(function (response) {
                            var data = response.data;
                            if (data.code == 0){
                                console.log(data.msg);
                                //window.location.href = "/membercenter/toIndex.do";
                                window.location.href = "/admin/rightmanage/toIndex.do";
                            }else {
                                console.log(data.msg);
                                _this.$alert(data.msg, '提示', {
                                    type: 'warning',
                                    dangerouslyUseHTMLString: true
                                });
                                _this.getCaptcha();
                            }

                        });
                    }
                })
            },
            // 获取验证码
            getCaptcha () {
                this.captchaPath = "captcha.jpg?t=" + $.now();
            },
            SSOlogin () {
                window.open("/oauth/login.do");
            }

        }
    }
    var Ctor = Vue.extend(Main)
    new Ctor().$mount('#app')
</script>
</html>