yanghb
2023-04-21 0481353111afb43a2322e18530dde26f1d841ead
ManagementTravel/guns-admin/src/main/webapp/WEB-INF/view/login.html
@@ -55,7 +55,7 @@
<div style="display: flex;align-items: center;justify-content: center;height: 100%">
<img src="${ctxPath}/static/img/login.png" style="width: 300px;height: 400px;z-index: 1000; border-radius: 20px;">
<img src="${ctxPath}/static/img/index4.png" style="width: 300px;height: 400px;z-index: 1000">
<div  style="position: relative;left: -20px; max-width: 300px;min-height: 300px;background: white;border-radius: 8px;box-sizing: border-box;padding: 0 30px 0 50px;display: flex;align-items: center;justify-content: center;">
    <div style="max-height: 100%">
        <h3 style="color: black;"><img src="${ctxPath}/static/img/logo.png" width="30px" height="30px"/>&nbsp;天马出租管理后台</h3>
@@ -64,11 +64,15 @@
        <form class="m-t" role="form" action="${ctxPath}/login" method="post">
            <div class="item">
                <img src="${ctxPath}/static/img/account.png" />
                <input class="itemInput" type="text" name="username"  placeholder="请输入您的账号" required="" value="">
                <input class="itemInput" type="text" name="username" id="username"  placeholder="请输入您的账号" required="" value="">
            </div>
            <div  class="item">
                <img src="${ctxPath}/static/img/password.png" />
                <input class="itemInput" type="password" name="password"  placeholder="请输入您的密码" required="" value="">
                <input class="itemInput" type="password" name="password" id="password"  placeholder="请输入您的密码" required="" value="">
            </div>
            <div  class="item">
                <input class="itemInput" name="sms_code" id="sms_code"  placeholder="请输入验证码" required="" value="" style="padding-left: 0px; text-align: center;">
                <button id="btn" type="button" onclick="sendSMSCode(this)" style="width: 150px; font-size: 14px;">获取验证码</button>
            </div>
            @if(kaptcha.getKaptchaOnOff() == true){
            <div class="form-group" style="float: left;">
@@ -87,18 +91,66 @@
                    </label>-->
                </div>
            </div>
            <button type="submit" class="btn full-width m-b" style="background-color: #d56b29;color: black;">登 录</button>
            <button onclick="login()" class="btn full-width m-b" style="background-color: #d56b29;color: black;">登 录</button>
            <button type="submit" id="submit" style="display: none;"></button>
            </p>
        </form>
    </div>
</div></div>
</body>
<script src="${ctxPath}/static/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxPath}/static/js/common/ajax-object.js"></script>
<script src="${ctxPath}/static/js/common/Feng.js"></script>
<script src="${ctxPath}/static/crypto-js/crypto-js.js"></script>
<script>
    $(function () {
        $("#kaptcha").on('click', function () {
            $("#kaptcha").attr('src', '${ctxPath}/kaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
        });
    });
    var key = CryptoJS.enc.Utf8.parse("xqT86jictTPpHMem");
    var iv = CryptoJS.enc.Utf8.parse("xqT86jicxqT86jic");
    //aes加密
    function encryptAES(context) {
        if(null == context || '' == context){
            return context;
        }
        var encrypted = '';
        if (typeof(context) == 'string') {
        }else if(typeof(context) == 'object'){
            context = JSON.stringify(context);
        }
        var srcs = CryptoJS.enc.Utf8.parse(context);
        encrypted = CryptoJS.AES.encrypt(srcs, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        return encrypted.toString();
    }
    // aes解密
    function decryptAES(context) {
        if(null == context || '' == context){
            return context;
        }
        var decrypt = CryptoJS.AES.decrypt(context, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
        return decryptedStr.toString();
    }
    function login(){
        let password = $('#password').val();
        password = encryptAES(password);
        $('#password').val(password);
        $('#submit').submit();
    }
    window.addEventListener(
        "mousewheel",
@@ -187,6 +239,50 @@
        }
    }
    fontSize(768, 1920);
    function sendSMSCode(obj) {
        let username = $('#username').val();
        if(null == username || '' == username){
            alert("请先输入您的账号");
            return
        }
        $.ajax({
            url: Feng.ctxPath + '/base/sendSMSCode',
            type: 'POST',
            data:{
                username: username
            },
            success: function (res) {
                if(res.status == 200){
                    invokeSettime(obj);
                }else{
                    alert(res.msg);
                }
            }
        });
    }
    function invokeSettime(obj){
        var countdown=60;
        settime(obj);
        function settime(obj) {
            if (countdown == 0) {
                $(obj).attr("disabled",false);
                $(obj).text("获取验证码");
                countdown = 60;
                return;
            } else {
                $(obj).attr("disabled",true);
                $(obj).text("(" + countdown + ")s重新发送");
                countdown--;
            }
            setTimeout(function() {
                    settime(obj) }
                ,1000)
        }
    }
</script>
</body>