yzt
2023-09-27 726603df43447f8cfedfeaae4267209adbd01699
src/main/webapp/hxzk/login.jsp
@@ -1,105 +1,191 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<html lang="en">
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/8/22
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <meta charset="utf-8">
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
   <title></title>
   <link rel="icon" type="image/x-icon" href="/hxzkoa/hxzk/assets/img/favicon.ico"/>
    <link href="https://fonts.googleapis.com/css?family=Quicksand:400,500,600,700&display=swap" rel="stylesheet">
    <link href="/hxzkoa/hxzk/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/hxzkoa/hxzk/assets/css/plugins.css" rel="stylesheet" type="text/css" />
    <link href="/hxzkoa/hxzk/assets/css/authentication/form-2.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/hxzkoa/hxzk/assets/css/forms/theme-checkbox-radio.css">
    <link rel="stylesheet" type="text/css" href="/hxzkoa/hxzk/assets/css/forms/switches.css">
    <link href="/hxzkoa/hxzk/plugins/sweetalerts/sweetalert2.min.css" rel="stylesheet" type="text/css" />
   <title>定位管理系统</title>
   <link href="/hxzkoa/hxzk/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
   <link rel="icon" type="image/x-icon" href="/hxzkoa/hxzk/assets/img/favicon.ico" />
   <link href="https://fonts.googleapis.com/css?family=Quicksand:400,500,600,700&display=swap"
        rel="stylesheet">
   <link href="/hxzkoa/hxzk/Cesium-1.88/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
   <link href="/hxzkoa/hxzk/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
   <link href="/hxzkoa/hxzk/assets/css/plugins.css" rel="stylesheet" type="text/css" />
   <link href="/hxzkoa/hxzk/assets/css/authentication/form-2.css" rel="stylesheet" type="text/css" />
   <link rel="stylesheet" type="text/css" href="/hxzkoa/hxzk/assets/css/forms/theme-checkbox-radio.css">
   <link rel="stylesheet" type="text/css" href="/hxzkoa/hxzk/assets/css/forms/switches.css">
   <link href="/hxzkoa/hxzk/plugins/sweetalerts/sweetalert2.min.css" rel="stylesheet" type="text/css" />
   <link href="/hxzkoa/hxzk/plugins/sweetalerts/sweetalert.css" rel="stylesheet" type="text/css" />
   <style>
   .form-control {
       height: auto;
       border: 1px solid #1b2e4b;
       color: #009688;
       font-size: 15px;
       padding: 8px 10px;
       letter-spacing: 1px;
       height: calc(1.4em + 1.4rem + 2px);
       padding: .75rem 1.25rem;
       border-radius: 6px;
       background: #1b2e4b;
       line-height: 1.5;
   }
      .form-control {
         height: 70px;
         border: 1px solid #1b2e4b;
         color: #009688;
         font-size: 15px;
         padding: 8px 10px;
         letter-spacing: 1px;
         height: calc(1.4em + 1.4rem + 2px);
         padding: .75rem 1.25rem;
         border-radius: 6px;
         background: #1b2e4b;
         line-height: 1.5;
      }
      .row{
         width: 30%;
         margin: auto;
      }
      .code1{
         width:   50%;
         float: left;
      }
      .code2{
         width: 50%;
         float: left;
      }
      .container-fluid{
         width:100%;
         overflow: hidden;
      }
      @media (min-width: 340px) and (max-width: 369px) {
         .container-fluid{
            width: 100%;
         }
         .row{
            width: 100%;
         }
         .code1{
            width: 50%;
            float: left;
         }
         .code2{
            width: 50%  ;
            float: left;
         }
      }
      @media (min-width: 370px ) and (max-width: 767px) {
         .container-fluid{
            width: 100%;
         }
         .row{
            width: 100%;
         }
         .code1{
            width: 50%;
            float: left;
         }
         .code2{
            width: 50%  ;
            float: left;
         }
      }
      @media (min-width: 767px ) and (max-width: 1500px) {
         .row{
            width: 30%;
            margin: auto;
         }
         .code1{
            width:   50%;
            float: left;
         }
         .code2{
            width: 50%;
            float: left;
         }
         .container-fluid{
            width:100%;
            overflow: hidden;
         }
      }
   </style>
    <script src="/hxzkoa/hxzk/assets/js/libs/jquery-3.1.1.min.js"></script>
    <script src="/hxzkoa/hxzk/bootstrap/js/popper.min.js"></script>
    <script src="/hxzkoa/hxzk/bootstrap/js/bootstrap.min.js"></script>
    <script src="/hxzkoa/hxzk/assets/js/authentication/form-2.js"></script>
    <script src="/hxzkoa/hxzk/plugins/sweetalerts/sweetalert2.min.js"></script>
   <script src="/hxzkoa/hxzk/plugins/sweetalerts/custom-sweetalert.js"></script>
</head>
<body class="form">
<body style="overflow-y: hidden">
<div class="container-fluid" style="">
   <div class="row" style="margin-top: 200px">
      <div class="col-md-12 col-xs-12" style="text-align: center">
         <h1 class="" style="position: relative;left: -10px">
            <span id="headTitle"></span>
         </h1>
      </div>
   </div>
   <div class="row" style="margin-top: 10px;">
      <div class="col-xs-12 col-md-12">
         <label for="username" style="color: #131527;"></label>
         <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
             viewBox="0 0 24 24" fill="none" stroke="currentColor"
             stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
             class="feather feather-user" style="position: relative;top: 32px;left: 3px">
            <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
            <circle cx="12" cy="7" r="4"></circle>
         </svg>
         <input id="username" name="username" type="text" class="form-control"
               placeholder="用户名" required="required" style="padding-left: 40px">
      </div>
   </div>
   <div class="row" style="margin-top: 10px">
      <div class="col-xs-12 col-md-12">
         <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
             viewBox="0 0 24 24" fill="none" stroke="currentColor"
             stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
             class="feather feather-lock" style="position: relative;top: 32px ;left: 6px">
            <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
            <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
         </svg>
         <input id="password" name="password" type="password"
               class="form-control" placeholder="密码" required="required" style="padding-left: 40px">
      </div>
   </div>
   <div class="row" style="margin-top: 30px;">
      <div class="col-xs-12 col-md-12">
         <svg t="1618403857453" class="feather feather-lock"
             viewBox="0 0 1024 1024" version="1.1"
             xmlns="http://www.w3.org/2000/svg" p-id="2231" width="24"
             height="24"style="position: absolute;top: 10px ;left: 14px;z-index: 999">
            <path
                  d="M895.744 273.28a59.2 59.2 0 0 0-46.72-51.936A1103.36 1103.36 0 0 1 697.92 186.56a561.28 561.28 0 0 1-135.008-78.912 61.76 61.76 0 0 0-72.16 0 354.112 354.112 0 0 1-136.032 78.4 507.264 507.264 0 0 1-146.944 36.32 55.04 55.04 0 0 0-46.208 51.936S160 404.64 160 519.36C160 727.04 405.056 928 527.616 928c122.528 0 330.24-141.76 363.456-405.504 8.32-155.776 2.56-248.704 2.56-248.704l2.112-0.544z m-133.44 160.416l-256 241.44c-11.52 10.976-29.12 12.704-42.56 4.16l-6.72-5.728-141.248-146.912a35.264 35.264 0 0 1 51.904-47.776l116.32 122.016 230.528-218.08a35.264 35.264 0 1 1 47.776 51.936v-1.056z"
                  p-id="2232" fill="#bfbfbf"></path>
         </svg>
         <input id="yanzheng" name="yanzheng" type="text" class="form-control code2"
               placeholder="验证码" style="padding-left: 40px;display: inline-block;">
         <!--                          <input type="button"  onclick="createCode()" id="code"  style ="margin-left:10px;width:40%;height:46.8px;font-family:Arial;font-style:italic;font-weight:bold;border:0;letter-spacing:2px;color:blue;"/>  -->
         <button type="button" onclick="shuaxin()" class="code1" id="code"
               style=" height: 43.8px; font-family: Arial;font-style: italic; font-weight: bold; border-radius: 10px; border: 0; letter-spacing: 2px; color: blue;"></button>
    <div class="form-container outer">
        <div class="form-form" style="position:absolute;width:20%;float:left;margin-left:40%;">
            <div class="form-form-wrap">
                <div class="form-container" >
                    <div class="form-content">
                        <h1 class="" ><span id="headTitle">华星智控定位管理系统</span></h1>
                        <form class="text-left">
                            <div class="form">
                                <div id="username-field" class="field-wrapper input">
                                    <label for="username">用户名</label>
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
                                    <input id="username" name="username" type="text" class="form-control" placeholder="用户名" required="required">
                                </div>
                                <div id="password-field" class="field-wrapper input mb-2">
                                    <div class="d-flex justify-content-between">
                                        <label for="password">密码</label>
                                    </div>
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-lock"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>
                                    <input id="password" name="password" type="password" class="form-control" placeholder="密码" required="required">
                                </div>
                                <div id="password-field" class="field-wrapper input mb-2">
                                    <div class="d-flex justify-content-between">
                                        <label for="password">验证码</label>
                                    </div>
                           <svg t="1618403857453" class="feather feather-lock" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2231" width="24" height="24"><path d="M895.744 273.28a59.2 59.2 0 0 0-46.72-51.936A1103.36 1103.36 0 0 1 697.92 186.56a561.28 561.28 0 0 1-135.008-78.912 61.76 61.76 0 0 0-72.16 0 354.112 354.112 0 0 1-136.032 78.4 507.264 507.264 0 0 1-146.944 36.32 55.04 55.04 0 0 0-46.208 51.936S160 404.64 160 519.36C160 727.04 405.056 928 527.616 928c122.528 0 330.24-141.76 363.456-405.504 8.32-155.776 2.56-248.704 2.56-248.704l2.112-0.544z m-133.44 160.416l-256 241.44c-11.52 10.976-29.12 12.704-42.56 4.16l-6.72-5.728-141.248-146.912a35.264 35.264 0 0 1 51.904-47.776l116.32 122.016 230.528-218.08a35.264 35.264 0 1 1 47.776 51.936v-1.056z" p-id="2232" fill="#bfbfbf"></path></svg>
                           <input id="yanzheng" name="yanzheng" type="text" class="form-control" placeholder="验证码" style ="width:40%;float:left;">
<!--                          <input type="button"  onclick="createCode()" id="code"  style ="margin-left:10px;width:40%;height:46.8px;font-family:Arial;font-style:italic;font-weight:bold;border:0;letter-spacing:2px;color:blue;"/>  -->
                           <button type="button" onclick="shuaxin()" id="code" style ="margin-left:10px;width:40%;height:46.8px;font-family:Arial;font-style:italic;font-weight:bold;border-radius:10px;border:0;letter-spacing:2px;color:blue;"></button>
                                </div>
                                <div class="d-sm-flex justify-content-between">
                                    <div class="field-wrapper">
                                        <button type="button" class="btn btn-primary login" value="">登录</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
    <script>
    var code ; //在全局定义验证码
      </div>
   </div>
   <div class="row" style="margin-top: 40px;">
      <div class="col-xs-12 col-md-12">
         <button type="button" class="btn btn-primary login"
               value="" style="width: 100%;height: 50px;">登录</button>
      </div>
   </div>
</div>
</body>
<script src="/hxzkoa/hxzk/assets/js/libs/jquery-3.1.1.min.js"></script>
<script src="/hxzkoa/hxzk/bootstrap/js/popper.min.js"></script>
<script src="/hxzkoa/hxzk/bootstrap/js/bootstrap.min.js"></script>
<script>
   var code; //在全局定义验证码
   //产生验证码
   window.onload = function createCode(){
       code = "";
       var codeLength = 4;//验证码的长度
       var checkCode = document.getElementById("code");
       var random = new Array(0,1,2,3,4,5,6,7,8,9);//随机数
       for(var i = 0; i < codeLength; i++) {//循环操作
         var index = Math.floor(Math.random()*10);//取得随机数的索引(0~35)
   window.onload = function createCode() {
      code = "";
      var codeLength = 4;//验证码的长度
      var checkCode = document.getElementById("code");
      var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);//随机数
      for (var i = 0; i < codeLength; i++) {//循环操作
         var index = Math.floor(Math.random() * 10);//取得随机数的索引(0~35)
         code += random[index];//根据索引取得随机数加到code上
      }
      var aaa = document.getElementById("yanzheng")
@@ -107,13 +193,13 @@
      checkCode.innerHTML = code;//把code值赋给验证码
   }
   //刷新验证码
   function shuaxin () {
      code = "";
       var codeLength = 4;//验证码的长度
       var checkCode = document.getElementById("code");
       var random = new Array(0,1,2,3,4,5,6,7,8,9);//随机数
       for(var i = 0; i < codeLength; i++) {//循环操作
         var index = Math.floor(Math.random()*10);//取得随机数的索引(0~35)
   function shuaxin() {
      code = "";
      var codeLength = 4;//验证码的长度
      var checkCode = document.getElementById("code");
      var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);//随机数
      for (var i = 0; i < codeLength; i++) {//循环操作
         var index = Math.floor(Math.random() * 10);//取得随机数的索引(0~35)
         code += random[index];//根据索引取得随机数加到code上
      }
      var aaa = document.getElementById("yanzheng")
@@ -121,101 +207,94 @@
      checkCode.innerHTML = code;//把code值赋给验证码
   }
   //校验验证码
   function validate(){
      var inputCode = document.getElementById("input").value.toUpperCase(); //取得输入的验证码并转化为大写
      if(inputCode.length <= 0) { //若输入的验证码长度为0
   function validate() {
      var inputCode = document.getElementById("input").value.toUpperCase(); //取得输入的验证码并转化为大写
      if (inputCode.length <= 0) { //若输入的验证码长度为0
         alert("请输入验证码!"); //则弹出请输入验证码
      }
      else if(inputCode != code ) { //若输入的验证码与产生的验证码不一致时
      }
      else if (inputCode != code) { //若输入的验证码与产生的验证码不一致时
         alert("验证码输入错误!@_@"); //则弹出验证码输入错误
         createCode();//刷新验证码
         document.getElementById("input").value = "";//清空文本框
      }
      }
      else { //输入正确时
         alert("^-^"); //弹出^-^
      }
      }
   }
    $(document).ready(function(){
      var title=""
   $(document).ready(function () {
      var title = ""
      $.ajax({
         async : false, //同步的
         type : "POST",
         url : "/hxzkoa/getSysSetting_list.do",
         data : {
         async: false, //同步的
         type: "POST",
         url: "/hxzkoa/getSysSetting_list.do",
         data: {
         },
         dataType : "json",
         success:function(data){
               title = data[0].title
               var obj = document.getElementById("headTitle");
         dataType: "json",
         success: function (data) {
            title = data[0].title
            var obj = document.getElementById("headTitle");
            //console.log("head:",title)
            obj.innerText= title;
            document.title = title;
            },
            obj.innerText = title;
            document.title = title;
         },
      });
    })
   function login () {
      var inputCode = document.getElementById("yanzheng").value.toUpperCase(); //取得输入的验证码并转化为大写
      if(inputCode.length <= 0) { //若输入的验证码长度为0
   })
   function login() {
      var inputCode = document.getElementById("yanzheng").value.toUpperCase(); //取得输入的验证码并转化为大写
      if (inputCode.length <= 0) { //若输入的验证码长度为0
         //console.log('if')
         swal(
            '登录失败!',
            '请输入验证码!',
            'error'
               '登录失败!',
               '请输入验证码!',
               'error'
         )
      }
      else if(inputCode != code ) { //若输入的验证码与产生的验证码不一致时
      }
      else if (inputCode != code) { //若输入的验证码与产生的验证码不一致时
         //console.log('elseif')
         swal(
            '登录失败!',
            '验证码错误!',
            'error'
               '登录失败!',
               '验证码错误!',
               'error'
         )
         createCode();//刷新验证码
         document.getElementById("input").value = "";//清空文本框
      }
      }
      else { //输入正确时
         //console.log('else')
         var username = $("#username").val();
         var password = $("#password").val();
         $.ajax({
            async : false, //同步的
            type : "POST",
            url : "/hxzkoa/login.do",
            data : {
               username : username,
               password : password,
            async: false, //同步的
            type: "POST",
            url: "/hxzkoa/login.do",
            data: {
               username: username,
               password: password,
            },
            dataType : "json",
            success:function(data){
                  //console.log(data)
                  if (data=="1"){
                     window.location.href="/hxzkoa/show.do"
                  } else {
                     swal(
                     '登录失败!',
                     '用户名和密码错误!',
                     'error'
                  )
                  }
               },
            dataType: "json",
            success: function (data) {
               //console.log(data)
               if (data == "1") {
                  localStorage.setItem("username",username);
                  window.location.href = "/hxzkoa/show.do"
               } else {
                  alert("用户名或密码错误!")
               }
            },
         });
      }
      }
   }
   window.onkeydown=(e)=>{
      if(e.code== "Enter"){
   window.onkeydown = (e) => {
      if (e.code == "Enter") {
         login()
         return false
      }
   }
    // 新增功能
   // 新增功能
   $('.login').on('click', login);
    </script>
    <!-- END GLOBAL MANDATORY SCRIPTS -->
</body>
</script>
</html>