王飞
2025-01-23 b108c63ceb09716fb04a62cc155a404b236b6794
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2023/12/8
  Time: 17:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link href="/hxzkuwb/view/CSS/style.css" rel="stylesheet">
    <link href="/hxzkuwb/view/JS/css/tac.css" rel="stylesheet">
    <style>
        .genggai:hover{
            color: red;
        }
        .form {
            width: 290px;
            height: 380px;
            display: flex;
            flex-direction: column;
            border-radius: 15px;
            background-color: white;
            box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
            transition: .4s ease-in-out;
        }
 
        .form:hover {
            box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
            scale: 0.99;
        }
 
        .heading {
            position: relative;
            text-align: center;
            color: black;
            top: 3em;
            font-weight: bold;
        }
 
        .check {
            position: relative;
            align-self: center;
            top: 4em;
        }
 
        .input {
            position: relative;
            width: 2.5em;
            height: 2.5em;
            margin: 1em;
            border-radius: 5px;
            border: none;
            outline: none;
            background-color: rgb(235, 235, 235);
            box-shadow: inset 3px 3px 6px #d1d1d1,
            inset -3px -3px 6px #ffffff;
            top: 6.5em;
            left: 1.5em;
            padding-left: 15px;
            transition: .4s ease-in-out;
        }
 
        .input:hover {
            box-shadow: inset 0px 0px 0px #d1d1d1,
            inset 0px 0px 0px #ffffff;
            background-color: lightgrey;
        }
 
        .input:focus {
            box-shadow: inset 0px 0px 0px #d1d1d1,
            inset 0px 0px 0px #ffffff;
            background-color: lightgrey;
        }
 
        .btn1 {
            position: relative;
            top: 8.5em;
            left: 2.4em;
            width: 17em;
            height: 3em;
            border-radius: 5px;
            border: none;
            outline: none;
            transition: .4s ease-in-out;
            box-shadow: 1px 1px 3px #b5b5b5,
            -1px -1px 3px #ffffff;
        }
 
        .btn1:active {
            box-shadow: inset 3px 3px 6px #b5b5b5,
            inset -3px -3px 6px #ffffff;
        }
 
        .btn2 {
            position: relative;
            top: 9.5em;
            left: 2.4em;
            width: 17em;
            height: 3em;
            border-radius: 5px;
            border: none;
            outline: none;
            transition: .4s ease-in-out;
            box-shadow: 1px 1px 3px #b5b5b5,
            -1px -1px 3px #ffffff;
        }
 
        .btn2:active {
            box-shadow: inset 3px 3px 6px #b5b5b5,
            inset -3px -3px 6px #ffffff;
        }
    </style>
</head>
<body style="overflow:hidden;">
 
<div class="loginav">
    <div class="video" style="position: relative;"><video src="/hxzkuwb/view/images/video.mp4" muted autoplay loop/></div>
    <div class=""></div>
    <div class="loginbox boxall" style="width: 450px;">
        <div class="logo">
            <h1 id="title">定位管理系统</h1>
            <!-- <img src="images/logo.png"> -->
        </div>
        <a href="javascript:;" class="yonghulog" onclick="yonghu()"><div class="logintit yh" style="display: inline-block">用户登录</div></a><a class="duanxinlog" href="javascript:;" style="margin-left: 5%" onclick="duanxin()"><div class="logintit dx" style="display: inline-block;margin-left: 30px">短信登录</div></a>
        <form id="marsMapForm" action="/hxzkuwb/Mars3" method="get">
            <ul class="logininput" id="yong" style="">
                <li>
                    <i><img src="/hxzkuwb/view/images/user.png"></i>
                    <input class="forminput" value="" id="yhm" required type="text" placeholder="用户名">
                </li>
                <li>
                    <i><img src="/hxzkuwb/view/images/password.png"></i>
                    <input class="forminput" type="password" id="pass"  required value="" placeholder="密码">
                </li>
                <div id="captcha-box"></div>
                <li id="denglu">
                    <button type="submit"  id="LoginDengLu" style="cursor:pointer;;border: none;width: 100%" class="btn btnblock btn-lg btn-block btn-primary">登录</button>
                </li>
                <%--            <li style="color: white;text-align: center;position: relative;left: 5%" id="title2">推荐您使用谷歌chorme浏览器<a class="genggai" href="./NotPassWord.jsp" style="color: #ccc;font-size: 13px;position: relative;left: 10%">更改密码</a></li>--%>
            </ul>
        </form>
        <form id="marsMapFormSMS" action="/hxzkuwb/Mars3" method="get">
        <ul class="logininput" style="display: none;" id="duan">
            <li>
                <i><img src="/hxzkuwb/view/images/user.png"></i>
                <input  class="forminput" value="" id="yhm1"  type="text" placeholder="请输入手机号">
            </li>
            <li>
                <i><img src="/hxzkuwb/view/images/password.png"></i>
                <input class="forminput" type="password" id="pass1"  value="" placeholder="请输入验证码">
            </li>
            <li>
                <button href="javascript:;"  id="LoginDengLu1" style="border: none;cursor: pointer;width: 100%;text-align: center;" class="btn btnblock btn-lg btn-block btn-primary">登录</button>
            </li>
            <li>
                <a type="submit" href="javascript:;"  id="yzm" style="width: 100px;height: 40px;font-size: 12px;line-height: 40px;float: right;position: relative;top: -154px;margin-right: 5px" class="btn btnblock btn-lg btn-block btn-primary" onclick="hqyzm()">获取验证码</a>
            </li>
        </ul>
        </form>
        <div class="boxfoot"></div>
    </div>
</div>
<div style="width: 100%;position: fixed;top: 32%;left: 40%">
</div>
 
<canvas id='canvas'
        style="position:fixed; width:100%; height:100%; left: 0; top: 0; opacity: .3; pointer-events: none;"></canvas>
<script src="JS/translate.js"></script>
<script>
 
    var canvas = document.querySelector('canvas');
    var ctx = canvas.getContext('2d');
    var w = window.innerWidth;//获取屏幕宽高
    var h = window.innerHeight * 2 / 2;
    canvas.width = w;//将屏幕宽高赋值给canvas
    canvas.height = h;
    // canvas.style.cssText += `;width:${w}px;height:${h}px;`;
    var dots = [];
    var minScale = 1;//设置圆点的最小缩放
    var maxScale = 3;//设置圆点的最大缩放
    var bei = 1;
    for (var i = 0; i < 300; i += 1) {  //设置白圆点的个数
        dots.push(new Dot())
    }
 
    render = () => {
        ctx.clearRect(0, 0, w, h);
        ctx.fillStyle = 'rgba(26,94,199,.6)';
        ctx.fillRect(0, 0, w, h);//描绘底层蓝色背景
        for (var i = 0; i < dots.length; i += 1) {
            var dot = dots[i];
            dot.update();
            dot.paint();
 
        }
        requestAnimationFrame(render)
    }
    render();
    function Dot() {
        this.radius = Math.floor(Math.random() * 3 + 2);//在选一个随机数为圆点半径
        this.d = Math.random() * 2 * Math.PI;//在0-2π之间随机一个弧度值
        this.rx = Math.random() * w * (Math.random() > 0.6 ? 2 / 3 : 1 / 4);// 选一个随机数,作为椭圆长轴顶点a的数值,也就是椭圆中心的x轴坐标,此处的x,y,是相对于椭圆圆心为中心点建立的直角坐标系。
        this.ry = Math.random() * h - h / 2;//选一个随机数作为椭圆短轴顶点b的数值,也就是椭圆中心的y轴坐标,此处的x,y,是相对于椭圆圆心为中心点建立的直角坐标系。这两个值可以根据自已需求来定。
        this.x = Math.cos(this.d) * this.rx + w / 2;
        this.y = Math.sin(this.d) * this.ry + h / 2;//根据椭圆x,y求值公式,x=a*cosα,y=a*sinα.求出圆点在椭圆上的x,y轴坐标.后面加w/2,h/2只是为了居中显示。此处的x,y是相对于canvas建立的直角坐标系的,按canvas约定,其中心点(0,0)点在左上角
        this.z = (Math.pow(Math.pow(this.rx, 2) + Math.pow(this.ry, 2), 0.5) / Math.pow(Math.pow(w / 2, 2) + Math.pow(h / 2, 2), 0.5))//求白色圆点离椭圆中心点的距离,可视为一个点到圆心的距离,用x平方+y平方=c平方求得。此处的x,y,是相对于椭圆圆心为中心点建立的直角坐标系。此处Z值只是一个比值
        this.scale = (Math.cos(this.d) + 1) * (maxScale - minScale) / 2 + minScale;//圆点的缩放大小,根据余弦函数公式y=cosα.标准的余弦函数最大值和最小值分别为1,-1.这里要自行设置最大值和最小值,所以要进行改写
        // this.speed = Math.random() * 0.0005 + 0.0005;
        this.speed = Math.random() * 0.0004 + 0.0004;//圆点运动的速度
        this.alpha = this.scale / maxScale * 0.3 + 0.1;//圆点运动的透明度
        this.count = 0;
        this.paint = () => {
            ctx.fillStyle = 'rgba(0,130,255,' + this.alpha + ')';
            ctx.beginPath();
            ctx.arc(this.x, this.y, this.radius * this.scale * this.z, 0, Math.PI * 2);
            ctx.fill();
        }
        this.update = () => {
            this.count += 0.01;
            if (Math.floor(this.count) % 12 === 0 && Math.floor(this.count) != 0) {
                this.d += 0.008;
                if (this.count > Math.floor(this.count) + 0.5) {
                    this.d -= 0.008;
                }
            }
 
 
            this.x = Math.sin(this.d) * this.rx + w / 2;
            this.y = Math.cos(this.d) * this.ry + h / 2;
            this.d -= this.speed;//通过改变它的弧度值来改变圆点在椭圆中运动
            this.scale = (Math.cos(this.d) + 1) * (maxScale - minScale) / 2 + minScale;
            this.alpha = this.scale / maxScale * 0.3 + 0.1;
        }
    }
 
</script>
</body>
<script src="/hxzkuwb/view/JS/layui.js"></script>
<script src="/hxzkuwb/view/JS/layer.js"></script>
<script src="/hxzkuwb/HouTai/Js/jquery-3.5.1.js"></script>
<script src="/hxzkuwb/view/JS/huakuai.js"></script>
<script src="/hxzkuwb/view/JS/tac.min.js"></script>
<script src="/hxzkuwb/view/tac/js/notify_stand.js"></script>
<script src="/hxzkuwb/view/tac/js/notify.js"></script>
<script>
 
    var LoginId = "";
    var loginTimer = null; // 用于存储计时器的变量
    var sessionId;
    var loginAttempts; // 用于记录连续登录失败的次数
    window.onload = function() {
        if (loginAttempts !== undefined && loginAttempts !== null) {
            document.cookie = "loginAttempts=" + loginAttempts + ";Path=/hxzkuwb;Max-Age=3600";
        } else {
            loginAttempts = 0;
            console.error("loginAttempts is 0");
        }
    };
    const form = document.getElementById('marsMapForm');
    form.addEventListener('submit', function(event) {
        // 阻止表单的默认提交行为
        event.preventDefault();
 
        if (loginAttempts >= 3) {
            notify.error("您已连续登录失败3次,请1分钟后再次尝试");
            return;
        }
        if (LoginId == "") {
            //没有验证过
            $("#denglu").hide()
            // config 对象为TAC验证码的一些配置和验证的回调
            const config = {
                requestCaptchaDataUrl: "/hxzkuwb/code", validCaptchaUrl: "/hxzkuwb/checkCode",
                bindEl: "#captcha-box",
                validSuccess: (res, c, tac) => {
                    // 销毁验证码服务
                    tac.destroyWindow();
                    console.log("验证成功,后端返回的数据为", res);
                    LoginId = res.data.id
                    $("#denglu").show()
                    // 启动1分钟的计时器
                    loginTimer = setTimeout(() => {
                        notify.error("1分钟内未登录,重新验证");
                        LoginId = "";
                        login(); // 重新调用login函数进行验证
                    }, 60000); // 60000毫秒 = 1分钟
                },
                // 验证失败的回调函数(可忽略,如果不自定义 validFail 方法时,会使用默认的)
                validFail: (res, c, tac) => {
                    console.log("验证码验证失败回调...")
                    LoginId = ""
                    // 验证失败后重新拉取验证码
                    tac.reloadCaptcha();
                },
                // 刷新按钮回调事件
                btnRefreshFun: (el, tac) => {
                    console.log("刷新按钮触发事件...")
                    LoginId = ""
                    tac.reloadCaptcha();
                },
                // 关闭按钮回调事件
                btnCloseFun: (el, tac) => {
                    console.log("关闭按钮触发事件...")
                    LoginId = ""
                    tac.destroyWindow();
                    $("#denglu").show()
                }
            }
            // 一些样式配置, 可不传
            let style = {
                logoUrl: null// 去除logo
                // logoUrl: "/xx/xx/xxx.png" // 替换成自定义的logo
            }
            // 参数1 为 tac文件是目录地址, 目录里包含 tac的js和css等文件
            // 参数2 为 tac验证码相关配置
            // 参数3 为 tac窗口一些样式配置
            window.initTAC("/hxzkuwb/view/tac", config, style).then(tac => {
                tac.init(); // 调用init则显示验证码
            }).catch(e => {
                console.log("初始化tac失败", e);
            })
        } else {
            //验证过
            //二次验证
            if (LoginId == "") {
                login()
            } else {
                clearTimeout(loginTimer);
                const username = $("#yhm").val();
                const password = $("#pass").val();
                var data = {
                    username,
                    password
                }
                $.ajax({
                    url: "/hxzkuwb/login",
                    type: "POST",
                    async: true, // 设置为同步请求
                    data: data,
                    success: function (response) {
                        if (response == "0") {
                            notify.error('当前登录用户不存在,请重新输入')
                            LoginId = ""
                            loginAttempts++; // 增加登录失败次数
                            if (loginAttempts >= 3) {
                                document.cookie = "loginAttempts=" + loginAttempts + ";Path=/hxzkuwb;Max-Age=3600";
                                loginTimer = setTimeout(() => {
                                    loginAttempts = 0; // 重置登录失败次数
                                    document.cookie = "loginAttempts=" + loginAttempts + ";Path=/hxzkuwb;Max-Age=3600";
                                    notify.success("可以再次尝试登录");
                                }, 60000); // 60000毫秒 = 1分钟
                            }
                        } else {
                            loginAttempts = 0; // 重置登录失败次数
                            document.cookie = "loginAttempts=" + loginAttempts + ";Path=/hxzkuwb;Max-Age=3600";
                            const username1 = $("#yhm").val();
                            notify.success("登录成功")
                            sessionId = response;
                            localStorage.setItem("hxzkmars3d", response)
                            sessionStorage.setItem("username", username1)
                            location.href ="/hxzkuwb/Mars3"
                            // form.submit();
                        }
                    }
                });
            }
        }
    });
 
    const form1 = document.getElementById('marsMapFormSMS');
    form1.addEventListener('submit', function(event) {
        // 阻止表单的默认提交行为
        event.preventDefault();
        if (hqyzmnum == 0){
            notify.error("请先获取验证码")
        }else{
            var yhm = $("#yhm1").val();
            var data ="phone="+yhm
            var usernames;
            $.get("/hxzkuwb/findPhoneUser",data,function (data){
                usernames = data.username
                if (data == "" || data.length == 0){
                    notify.error("当前手机号不存在,请重新输入")
                }else{
                    var pass = $("#pass1").val();
                    var data = "phone="+yhm
                    if (pass == yzms){
                        $.ajax({
                            url: "/hxzkuwb/login",
                            type: "POST",
                            async: true, // 设置为同步请求
                            data: data,
                            success: function (response) {
                                if (response == "0") {
                                    notify.error('登录有误,请重新登录!')
                                } else {
                                    notify.success("登录成功")
                                    loginAttempts = 0; // 重置登录失败次数
                                    document.cookie = "loginAttempts=" + loginAttempts + ";Path=/hxzkuwb;Max-Age=3600";
                                    sessionId = usernames;
                                    localStorage.setItem("hxzkmars3d", response)
                                    sessionStorage.setItem("username", usernames)
                                    location.href ="/hxzkuwb/Mars3"
                                }
                            }
                        });
 
                    }else{
                        notify.error("验证码有误请重新获取")
                    }
                }
 
            })
        }
 
    });
 
 
 
 
 
 
 
 
 
 
 
 
    function duanxin(){
        // 使用 jQuery 设置 ID 为 "loginbox" 的元素高度为 200px
        $("#duan").fadeIn(1000)
        $("#marsMapForm").hide();
        $(".loginbox").height("330px")
        $(".dx").css("text-decoration","underline")
        $(".yh").css("text-decoration","none")
        $("#yhm1").val("")
        $("#pass1").val("")
    }
    function yonghu(){
        $("#marsMapForm").fadeIn(500)
        $("#duan").hide()
        $(".yh").css("text-decoration","underline")
        $(".dx").css("text-decoration","none")
    }
 
 
 
 
    var yzms;
    var hqyzmnum = 0;
    function hqyzm(){
        var phone = $("#yhm1").val();
        if(phone == "" || phone == null){
            notify.error("请填写手机号后在获取验证码")
        }else{
            var data ="phone="+phone
            $.get("/hxzkuwb/findPhoneUser",data,function (data){
                if (data == "" || data.length == 0){
                    notify.error("当前手机号不存在,请重新输入")
                }else{
                    hqyzmnum++;
                    //发送验证码
                    var yzm = generateRandomCode();
                    var yzmpd = "";
                    var data = "phone="+phone+"&randomNumber="+yzm;
                    $.ajax({
                        url: "/hxzkuwb/sms",
                        data: data,
                        async: false,
                        success: function (data) {
                            // 处理返回的数据
                            yzms = data;
 
                        }
                    });
                    startCountdown(60)
                }
 
            })
 
        }
    }
 
    function generateRandomCode() {
        var code = "";
        var possible = "0123456789"; // 可选的字符集合
 
        for (var i = 0; i < 4; i++) {
            // 从字符集合中随机选择一个字符,并添加到验证码中
            code += possible.charAt(Math.floor(Math.random() * possible.length));
        }
 
        return code;
    }
 
    function startCountdown(seconds) {
        var btn = document.getElementById('yzm');
        btn.disabled = true;
        var count = seconds;
        btn.textContent = count + "秒后重新获取";
        var timer = setInterval(function() {
            count--;
            if (count <= 0) {
                clearInterval(timer);
                btn.textContent = "获取验证码";
                btn.disabled = false;
            } else {
                btn.textContent = count + "秒后重新获取";
            }
        }, 1000);
    }
</script>
</html>