<%--
|
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>
|