mrzhssss
2021-12-07 591c676bdd4a3f016fe060e69ff3c1711043bdd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Cool</title>
    <link rel="stylesheet" href="../static/css/bg.css">
    <link rel="stylesheet" href="../static/css/login.css">
    <link rel="shortcut icon" href="../static/image/doge.png" type="image/x-icon"  id='in_icon'/>
</head>
 
<body>
<div class="wrapper">
    <div class="cool-container clearfix">
        <div class="cool-center">
            <h3>车辆管理系统</h3>
            <br>
            <input id="username" value="" placeholder="账号"  class="cool-input cool-row-3">
            <br><br>
            <input type="password" id="password" value="" placeholder="密码" class="cool-input cool-row-3">
            <br><br>
            <button id="login" class="cool-button-default" lay-submit="" lay-filter="login" type="button">登录</button>
        </div>
    </div>
    <ul class="bg-bubbles">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>
 
</body>
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../static/js/tools/md5.js"></script>
<script type="text/javascript" src="../static/js/common.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['form','layer'],function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;
 
        form.verify({
            username: function (val) {
                if (val === "") {
                    return "请输入手机号";
                }
            },
            password: function (val) {
                if (val === "") {
                    return "请输入密码";
                }
            }
        });
 
        form.on('submit(login)', function (data) {
            var user = {
                username: $("#username").val(),
                password: hex_md5($("#password").val())
            };
            $.ajax({
                url: "/login.action",
                data: user,
                method: 'POST',
                success: function (res) {
                    if (res.code === 200){
                        localStorage.setItem("token", res.data.token);
                        localStorage.setItem("nickname", res.data.nickname);
                        window.location.href = "index.html";
                    } else {
                        layer.msg(res.msg)
                    }
                }
            });
            return false;
        });
 
        $('body').keydown(function () {
            if (event.keyCode === 13) {
                $("#login").click();
            }
        });
 
    });
    var linkImg = document.getElementById('in_icon');
    window.onfocus = function () {
        document.title = 'Cool';
        linkImg.href = '/static/image/doge.png'
    };
    window.onblur = function () {
        document.title = '快回来~页面崩溃了';
        linkImg.href = '/static/image/cry.gif'
    };
</script>
</html>