#
Junjie
3 天以前 030a1abd26f8588c121ec47d53473e64a1e4f343
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统登录</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
    <link rel="icon" type="image/x-icon" href="../static/images/wcs_logo.png" />
    <link rel="stylesheet" href="../static/css/animate.min.css">
    <script type="text/javascript" src="../static/layui/layui.js"></script>
    <script type="text/javascript" src="../static/js/common.js"></script>
    <style>
        html{
            height: 100%;
        }
        body.login-bg {
            color: #777;
            height: 100%;
            /*background-image: linear-gradient(to right, #ff9569 0%, #e92758 100%);*/
            /*background-image: linear-gradient(-90deg, #a2e7f3 0%, #98baee 100%);*/
            background-image: url("../static/images/login.png");
            /*background: -webkit-linear-gradient(red, blue); !* Safari 5.1 - 6.0 *!;*/
            /*background-image: url("../static/image/login_bg.jpg");*/
            /*background-repeat: no-repeat;*/
            /*background-size: cover;*/
            /*background-position: top center;*/
        }
 
        #login-wrapper {
            box-sizing:border-box;
            background: #fff;
            position: absolute;
            top: 45%;
            left: 50%;
            margin-top: -210px;
            margin-left: -220px;
            width: 400px;
            min-height: 380px;
            padding: 50px;
            text-align: center;
            border-radius: 5px;
            box-shadow: 0px 0px 10px rgb(168, 165, 165);
            transform-origin: 50% 50%;
            /*animation: loading 1s 0s forwards;*/
            transform: rotateX(0deg);
        }
 
        #login-wrapper h2 {
            color: rgba(64,158,255,0.9);
            font-size: 26px;
            font-weight: bold;
            margin-bottom: 30px;
        }
 
        .layadmin-user-login-body .layui-form-item {
            margin-bottom: 20px;
            position: relative;
        }
        .layadmin-user-login-body .layui-form-item .layui-input {
            height: 42px;
            padding-left: 40px;
            font-size: 16px;
            border: 1px solid #c8cccf;
            color: inherit;
        }
        .login-submit {
            margin-top: 30px;
        }
        .layadmin-user-login-icon {
            position: absolute;
            left: 1px;
            top: 1px;
            width: 38px;
            line-height: 40px;
            text-align: center;
            color: #B2B2B2;
            font-size: 18px;
        }
        .layui-btn-normal {
            background-color: rgba(64,158,255,0.9);
            font-size: 20px;
            border-radius: 4px;
            height: 52px;
        }
    </style>
</head>
<body class="login-bg animsition">
 
<div id="login-wrapper" class="animate__animated animate__bounceInDown">
    <header>
        <h2 id="login-title" style="cursor: pointer; user-select: none;">WCS系统V3.0</h2>
        <div id="system-btns" style="display: none; margin-bottom: 20px;">
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-server-info">获取系统配置</button>
            <button class="layui-btn layui-btn-normal layui-btn-sm" id="btn-activate">一键激活</button>
        </div>
    </header>
    <div class="layui-form layadmin-user-login-body">
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-cellphone layadmin-user-login-icon"></label>
            <input id="mobile" class="layui-input" type="text" name="mobile" lay-verify="mobile" placeholder="账号">
        </div>
        <div class="layui-form-item">
            <label class="layui-icon layui-icon-password layadmin-user-login-icon"></label>
            <input id="password" class="layui-input" type="password" name="password" lay-verify="password" placeholder="密码">
        </div>
<!--        <div id="code-box" class="layui-form-item" style="">-->
<!--            <label id="code-label" class="layui-icon layui-icon-vercode layadmin-user-login-icon"></label>-->
<!--            <input id="code" class="layui-input" type="text" name="password" lay-verify="code" placeholder="验证码">-->
<!--            <img id="codeImg" title="看不清?点击换一张。">-->
<!--        </div>-->
        <!--<div class="layui-form-item">-->
            <!--<input id="rememberPwd" style="vertical-align: middle" type="checkbox" lay-filter="remPwd" lay-skin="switch" lay-text="开启|关闭" title="记住密码" checked="checked">-->
            <!--<span style="vertical-align: middle;font-size: 15px">记住密码</span>-->
        <!--</div>-->
    </div>
    <div class="layui-form-item login-submit">
        <button id="login-button" class="layui-btn layui-btn-fluid layui-btn-normal" lay-submit="" lay-filter="login">登 &nbsp  &nbsp 录</button>
    </div>
</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">
 
    // // 验证码开关
    // var codeSwitch = 'Y';
    // $.ajax({
    //     url: baseUrl+"/code/switch.action",
    //     async: false,
    //     success: function (res) {
    //         if (res.data === 'N'){
    //             codeSwitch = res.data;
    //             $('#code-box').css("display", "none");
    //         }
    //     }
    // });
 
    // // 初始化验证码
    // initCode();
    // $('#codeImg').click(function () {
    //     initCode();
    // });
    // function initCode() {
    //     var random = Math.random();
    //     $('#codeImg').attr("src", baseUrl+"/code.action?sd="+random);
    //     setTimeout(function () {
    //         $.ajax({
    //             url: baseUrl+"/code.do",
    //             data: {sd: random},
    //             method: 'POST',
    //             async: false,
    //             success: function (code) {
    //                 sessionStorage.setItem("code", code);
    //             }
    //         });
    //     }, 100);
    // }
 
    layui.use(['form','layer'],function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;
 
        // 连续点击三次标题显示隐藏功能
        var titleClickCount = 0;
        var titleClickTimer = null;
        $('#login-title').click(function() {
            titleClickCount++;
            if (titleClickTimer) {
                clearTimeout(titleClickTimer);
            }
            if (titleClickCount >= 3) {
                $('#system-btns').show();
                titleClickCount = 0;
            } else {
                titleClickTimer = setTimeout(function() {
                    titleClickCount = 0;
                }, 500);
            }
        });
 
        // 获取系统配置
        $('#btn-server-info').click(function() {
            $.ajax({
                url: baseUrl + "/license/getServerInfos",
                headers: {'token': localStorage.getItem('token')},
                method: 'GET',
                success: function (res) {
                    var pretty = '';
                    try {
                        pretty = JSON.stringify(res, null, 2);
                    } catch (e) {
                        pretty = res;
                    }
                    var html = ''
                        + '<div style="padding:15px 20px 5px 20px;">'
                        +   '<div style="font-weight:600;margin-bottom:8px;">系统配置信息</div>'
                        +   '<pre id="server-info-pre" style="background:#f7f7f7;border:1px solid #e6e6e6;border-radius:6px;padding:12px;white-space:pre-wrap;word-wrap:break-word;max-height:360px;overflow:auto;">'
                        +       pretty
                        +   '</pre>'
                        +   '<div class="layui-btn-container" style="text-align:right;margin-top:6px;">'
                        +       '<button class="layui-btn layui-btn-primary" id="copy-server-info">复制</button>'
                        +   '</div>'
                        + '</div>';
                    layer.open({
                        type: 1,
                        title: '获取系统配置',
                        area: ['640px','480px'],
                        shadeClose: true,
                        content: html,
                        success: function (layero, index) {
                            layero.find('#copy-server-info').on('click', function () {
                                var text = layero.find('#server-info-pre').text();
                                if (navigator.clipboard && navigator.clipboard.writeText) {
                                    navigator.clipboard.writeText(text).then(function () {
                                        layer.msg('已复制到剪贴板');
                                    }).catch(function () {
                                        fallbackCopy(text);
                                    });
                                } else {
                                    fallbackCopy(text);
                                }
                            });
                        }
                    });
                },
                error: function () {
                    layer.msg('获取系统配置信息失败');
                }
            });
            return false;
        });
 
        function fallbackCopy(text) {
            try {
                var textarea = document.createElement('textarea');
                textarea.value = text;
                textarea.style.position = 'fixed';
                textarea.style.opacity = '0';
                document.body.appendChild(textarea);
                textarea.select();
                document.execCommand('copy');
                document.body.removeChild(textarea);
                layer.msg('已复制到剪贴板');
            } catch (err) {
                layer.msg('复制失败');
            }
        }
 
        // 一键激活
        $('#btn-activate').click(function() {
            layer.confirm('确定执行一键激活吗', function(index){
                layer.close(index);
                $.ajax({
                    url: baseUrl + "/license/activate",
                    headers: {'token': localStorage.getItem('token')},
                    method: 'POST',
                    success: function (res) {
                        if (res.code === 200){
                            layer.msg('激活成功');
                        } else {
                            layer.msg(res.msg)
                        }
                    },
                    error: function () {
                        layer.msg('激活失败');
                    }
                });
            });
            return false;
        });
 
        form.on('submit(login)', function (data) {
            var mobile = $("#mobile").val();
            if (mobile === "") {
                layer.msg("请输入账号", {offset: '150px'});
                return;
            }
            var password = $("#password").val();
            if (password === "") {
                layer.msg("请输入密码", {offset: '150px'});
                return;
            }
            // var code = $("#code").val();
            // if (code === "" && codeSwitch === 'Y') {
            //     layer.msg("请输入验证码", {offset: '150px'});
            //     return;
            // }
            // if (sessionStorage.getItem("code").toUpperCase() !== code.toUpperCase()&&codeSwitch==='Y'){
            //     layer.msg("验证码错误", {offset: '150px'});
            //     return;
            // }
 
            var user = {
                mobile: mobile,
                password: hex_md5(password)
            };
            $.ajax({
                url: baseUrl+"/login.action",
                data: user,
                method: 'POST',
                success: function (res) {
                    if (res.code === 200){
                        localStorage.setItem("token", res.data.token);
                        localStorage.setItem("username", res.data.username);
                        window.location.href = "index.html";
                    } else {
                        layer.msg(res.msg, {offset: '150px'});
                    }
                }
            });
            return false;
        });
 
        $('body').keydown(function () {
            if (event.keyCode === 13) {
                $("#login-button").click();
            }
        });
 
    });
</script>
<script type></script>
</html>