管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-08 e7b3a5e891287b1291d2ac38f7c83d5d73bc7906
src/main/resources/templates/login.html
@@ -2,60 +2,73 @@
<html>
<head>
  <title>管道基础大数据平台服务-登录</title>
  <meta charset="utf-8" />
  <meta http-equiv="pragma" content="no-cache" />
  <meta http-equiv="cache-control" content="no-cache" />
  <meta http-equiv="expires" content="0" />
  <link href="../favicon.ico" rel="icon" type="image/x-icon" />
  <link href="../css/reset.css" rel="stylesheet" />
  <link href="../css/JCXM_style.css" rel="stylesheet" />
  <link href="../js/font-awesome.min.css" rel="stylesheet" />
  <link href="../css/cas.css" rel="stylesheet" />
  <link href="../css/style.css" rel="stylesheet" />
  <script src="../js/jquery.min.js"></script>
  <script src="../js/zxcvbn.js"></script>
  <script src="../js/jquery-ui.min.js"></script>
  <script src="../js/jquery.cookie.min.js"></script>
  <script src="../js/bootstrap.min.js"></script>
  <style>
    .errorMessage_show {
      width: 200px;
      text-align: left;
      line-height: 6px;
      height: 6px;
      clear: both;
      color: #d56969;
      font-size: 12px;
    }
    .code {
      /* background:url(code_bg.jpg); */
      font-family: Arial;
      font-style: italic;
      color: blue;
      font-size: 30px;
      border: 0;
      padding: 2px 3px;
      letter-spacing: 3px;
      font-weight: bolder;
      float: left;
      cursor: pointer;
      width: 88px;
      height: 35px;
      line-height: 34px;
      text-align: center;
      vertical-align: middle;
      border-top-right-radius: 5px;
      border-bottom-right-radius: 5px;
      background-color: white;
    }
    a {
      text-decoration: underline;
    }
      a:hover {
        text-decoration: underline;
      }
  </style>
  <script src="../js/zxcvbn.js"></script>
  <script src="../js/rsa.min.js"></script>
</head>
<body style="background-color: #0059cf; overflow-y: hidden !important;">
  <form method="post" id="fm1" class="fm-v clearfix" action="/sign/login">
    <div class="loginheader" style='display: none;'>
      <span class="loginname">单点登录</span>
      <img class="devline" src="../images/login/loginline.png" /><span class="lognameE">Log in</span>
    </div>
    <div id="topBg" style="background-color: #1a65c9; height: 30%; display: none;"></div>
    <div id='div_middle' class="loginmain">
      <div id='div_loginTitle' class="logintitle" style="display: none;"></div>
      <div id="topBgColor" style="background-color: #1a65c9; height: 19%; display: none;"></div>
      <div id='div_loginBox' class="logintable">
        <div id="loginBox_Title" style="height: 60px; line-height: 60px;">
          <span style="color: #fff; font-size: 50px; font-family: initial; font-weight: 700;">用户登录</span>
        </div>
        <!-- 用户名 -->
        <div class="loginid" style='width: 400px; margin-right: 50px; margin-top: 45px; border-bottom: 1px solid #fff;'>
          <label for="username"></label>
          <input class="required" id="username" placeholder="请输入用户名" size="20" tabindex="1"
            type="text" accesskey="n" autocomplete="off" name="username" value="" />
        </div>
        <!-- 密码 -->
        <section>
          <div class="loginpwd" style='width: 400px; margin-right: 20px; margin-top: 30px; border-bottom: 1px solid #fff;'>
            <label for="password"></label>
            <input class="required" placeholder="请输入密码" type="password" id="password" size="20" tabindex="2"
              accesskey="p" autocomplete="off" name="password" value="" /><span id="capslock-on" style="display: none;">
                <i class="fa fa-exclamation-circle"></i>
                <span>CAPSLOCK key is turned on!</span>
              </span>
          </div>
        </section>
        <section class="row check">
        </section>
        <!-- 验证码 -->
        <section>
          <div class="loginvalifield" style="width: 400px; margin-right: 20px; margin-top: 30px; border-bottom: 1px solid #fff;">
            <div class="loginvalicode">
              <label for="inputCode"></label>
              <input id="inputCode" placeholder="请输入验证码" name="inputCode" class="required" tabindex="3" accesskey="v" type="text" value="" size="35" autocomplete="off" maxlength="6">
            </div>
            <span class="code" id="checkCode" onclick="createCode()"></span>
          </div>
        </section>
        <section>
          <div id="eMsg" style="color: red; height: 40px; line-height: 40px; font-size: 15px; margin-bottom: -20px; margin-left: 45px;"></div>
        </section>
        <!-- 登录按钮 -->
        <section>
          <input class="loginbtn" style="margin-top: 25px;" name="submit" accesskey="l" value="" tabindex="5" type="button" onclick="sysLogin();">
        </section>
      </div>
    </div>
    <div id='div_foot' style="display: none;">
      <span>技术支持:国家海洋信息中心</span>
    </div>
  </form>
  <script>
    var code;
    function createCode() {
@@ -75,149 +88,37 @@
        checkCode.innerHTML = code;
      }
    }
    // 2019-03-28 去掉 by XiaoQi
    function validateCode() {
      var inputCode = document.getElementById("inputCode").value;
      if (inputCode.length <= 0) {
        alert("请输入验证码!");
      }
      else if (inputCode.toUpperCase() != code.toUpperCase()) {
        alert("验证码输入有误!");
        createCode();
      }
      else {
        alert("验证码正确!");
      }
    }
  </script>
</head>
<body style="background-color: #0059cf; overflow-y: hidden !important;">
  <form method="post" id="fm1" class="fm-v clearfix">
    <div class="loginheader" style='display: none;'>
      <span class="loginname">单点登录</span>
      <img class="devline" src="../images/login/loginline.png" /><span class="lognameE">Log in</span>
    </div>
    <div id="topBg" style="background-color: #1a65c9; height: 30%; display: none;"></div>
    <div id='div_middle' class="loginmain">
      <div id='div_loginTitle' class="logintitle" style="display: none;"></div>
      <div id="topBgColor" style="background-color: #1a65c9; height: 19%; display: none;"></div>
      <div id='div_loginBox' class="logintable">
        <div id="loginBox_Title" style="height: 60px; line-height: 60px;">
          <span style="color: #fff; font-size: 50px; font-family: initial; font-weight: 700;">用户登录</span>
        </div>
        <!-- 用户名 -->
        <div class="loginid" style='width: 400px; margin-right: 50px; margin-top: 45px; border-bottom: 1px solid #fff;'>
          <label for="username"></label>
          <input class="required" id="username" placeholder="请输入用户名" size="25" tabindex="1"
            type="text" accesskey="n"
            autocomplete="off" name="username" value="" />
        </div>
        <!-- 密码 -->
        <section>
          <div class="loginpwd" style='width: 400px; margin-right: 20px; margin-top: 30px; border-bottom: 1px solid #fff;'>
            <label for="password"></label>
            <input class="required" placeholder="请输入密码" type="password" id="password" size="25"
              tabindex="2"
              accesskey="p"
              autocomplete="off" name="password" value="" /><span id="capslock-on" style="display: none;">
                <p>
                  <i class="fa fa-exclamation-circle"></i>
                  <span>CAPSLOCK key is turned on!</span>
                </p>
              </span>
          </div>
        </section>
        <section class="row check">
        </section>
        <!-- 验证码 -->
         <div class="loginvalifield" style="margin-top:20px;">
            <div class="loginvalicode">
                <label for="inputCode"></label>
                <input id="inputCode" name="inputCode" class="required" tabindex="3" accesskey="v" type="text" value="" size="35" autocomplete="off">
            </div>
            <span class="code" id="checkCode" onclick="createCode()"></span>
        </div>
        <!-- 登录按钮 -->
        <section>
          <input class="loginbtn" style="margin-top: 25px;" name="submit" accesskey="l" value="" tabindex="5" type="submit">
        </section>
        <section id="otherCarLink" style='font-size: 14px; display: none;'>
          <a style='color: #c1d7fd;' href="downloads/证书安装与添加信任站点.zip" download="证书安装与添加信任站点.zip">证书安装与添加信任站点</a>
        </section>
      </div>
    </div>
    <div id='div_foot' style="display: none;">
      <span>技术支持:国家海洋信息中心</span>
    </div>
  </form>
  <script>
    var leftoffset = 474;
    //禁止在iframe打开
    // 禁止在iframe打开
    function noIframe() {
      if (top.location != self.location) {
        window.top.location = self.location.href.split("?")[0];
      }
    }
    function myfocus() {
      document.getElementById('username').focus();
    }
    window.onload = function () {
      noIframe();
      createCode();
      //winResize();
      autoResize();
      $(window).on("resize", autoResize);
      myfocus();
    }
    function winResize() {
      $(window).on("resize", function () {
        var div_obj = document.getElementById("div_middle");
        //宽度自适应
        //loginbox
        var fullWidth = document.body.offsetWidth;
        var div_loginBox = document.getElementById("div_loginBox");
        var boxWidth = div_loginBox.offsetWidth;
        var myWidth = div_obj.offsetWidth;
        //if (fullWidth > 1920) {
        //    fullWidth = 1920;
        //}
        div_obj.style.width = fullWidth + "px";
        div_loginBox.style.left = ((fullWidth - boxWidth) / 2 + leftoffset) + "px";
        //logintitle
        var div_loginTitle = document.getElementById("div_loginTitle");
        var titleWidth = div_loginTitle.offsetWidth;
        div_loginTitle.style.left = (fullWidth - titleWidth) / 2 + "px";
      })
    }
    function autoResize() {
      var div_obj = document.getElementById("div_middle");
      // 宽度自适应
      //宽度自适应
      var fullWidth = document.body.offsetWidth;
      var div_loginBox = document.getElementById("div_loginBox");
      var boxWidth = div_loginBox.offsetWidth;
      var myWidth = div_obj.offsetWidth;
      //if (fullWidth > 1920) {
      //    fullWidth = 1920;
      //}
      //if (fullWidth > 1920) { fullWidth = 1920; }
      var winWidht = window.innerWidth;
      var winHeight = window.innerHeight - 100;
      var bgHeight = 1080;
      winWidht += 150;
      if (winWidht >= 1920) {
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1920/bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "800px");
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1920/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "800px");
        $("#div_middle").css("height", "980px");
        $(".logintable").css("margin-top", "170px");
        div_loginBox.style.left = ((fullWidth - 410) / 2 + 474) + "px";
        bgHeight = 980; //1080
      } else if (winWidht >= 1600) {
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1600/bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "800px");
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1600/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "800px");
        $("#loginBox_Title span").css("font-size", "40px");
        $(".loginid").css("margin-top", "35px").css("height", "45px").css("width", "350px").css("background", "url(../images/NewGJXJlogin/1600/user.png) no-repeat").css("background-position", "3% 40%");
        $(".loginid input").css("width", "306px").css("margin-left", "45px").css("font-size", "18px");
@@ -236,7 +137,7 @@
        bgHeight = 800; //900
        div_loginBox.style.left = ((fullWidth - 360) / 2 + leftoffset) + "px";
      } else if (winWidht >= 1440) {
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1440/bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "810px");
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1440/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "810px");
        $("#loginBox_Title").css("height", "50px").css("line-height", "50px");
        $("#loginBox_Title span").css("font-size", "36px");
        $(".loginid").css("margin-top", "20px").css("height", "45px").css("width", "320px").css("background", "url(../images/NewGJXJlogin/1440/user.png) no-repeat").css("background-position", "3% 40%");
@@ -254,7 +155,7 @@
        bgHeight = 810;
        div_loginBox.style.left = ((fullWidth - 320) / 2 + leftoffset) + "px";
      } else if (winWidht >= 1366) {
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1366/bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "668px");
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1366/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "668px");
        $("#loginBox_Title").css("height", "50px").css("line-height", "50px");
        $("#loginBox_Title span").css("font-size", "32px");
        $(".loginid").css("margin-top", "35px").css("height", "40px").css("width", "300px").css("background", "url(../images/NewGJXJlogin/1366/user.png) no-repeat").css("background-position", "3% 50%");
@@ -274,7 +175,7 @@
        div_loginBox.style.left = ((fullWidth - 300) / 2 + leftoffset) + "px";
      } else {
        //fullWidth = 1280;
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1280/bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "620px");
        $("#div_middle").css("background", "url(../images/NewGJXJlogin/1280/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "620px");
        $("#loginBox_Title").css("height", "50px").css("line-height", "50px");
        $("#loginBox_Title span").css("font-size", "32px");
        $(".loginid").css("margin-top", "27px").css("height", "40px").css("width", "280px").css("background", "url(../images/NewGJXJlogin/1280/user.png) no-repeat").css("background-position", "3% 50%");
@@ -308,106 +209,156 @@
      var div_loginTitle = document.getElementById("div_loginTitle");
      var titleWidth = div_loginTitle.offsetWidth;
      div_loginTitle.style.left = (fullWidth - titleWidth) / 2 + "px";
    }
      //根据参数自动替换标题、背景图片
      var search = window.location.search;
      if (search != "" && search.indexOf("=") > -1) {
        search = decodeURIComponent(search);
        var value = search.split('=')[1];
        if (value.length > 0) {
          var startNum = value.indexOf("//");
          value = value.substring(startNum + 2, value.length);
          var endNum = value.indexOf("/");
          if (endNum > -1) {
            value = value.substring(0, endNum);
          }
          var k = value.indexOf(":");
          if (k > -1) {
            value = value.substring(0, k);
          }
          var host = value;
          if (false) {//host == "10.3.1.37"
            $("body").css("overflow", "auto");
            leftoffset = 375;
            $("body").css("background-color", "#0eade0");
            $("#topBg").show();
            $("#div_loginTitle").show();
            $("#topBgColor").show();
            $("#loginBox_Title").hide();
            $("#carLink").hide();
            $("#otherCarLink").show();
            $(".loginid").css("margin-top", "20px").css("height", "40px").css("width", "279px").css("border-radius", "6px").css("background", "url(../images/GJXJlogin/icon_01.png) no-repeat").css("background-color", "#4987F4").css("background-position", "3% 50%").css("border-bottom", "none");
            $(".loginid input").css("width", "245px").css("margin-left", "33px").css("background-color", "#4987F4").css("color", "#c1d7fd").css("font-size", "14px");
            $(".loginpwd").css("margin-top", "20px").css("height", "40px").css("width", "279px").css("border-radius", "6px").css("background", "url(../images/GJXJlogin/icon_02.png) no-repeat").css("background-color", "#4987F4").css("background-position", "3% 50%").css("border-bottom", "none");
            $(".loginpwd input").css("width", "245px").css("margin-left", "33px").css("background-color", "#4987F4").css("color", "#c1d7fd").css("font-size", "14px");
            $(".loginvalicode").css("height", "40px").css("width", "210px").css("border-radius", "6px").css("background", "url(../images/GJXJlogin/icon_03.png) no-repeat").css("background-color", "#4987F4").css("background-position", "6% 50%");
            $(".loginvalicode input").css("width", "142px").css("margin-left", "37px").css("background-color", "#4987F4").css("color", "#c1d7fd").css("font-size", "14px");
            $(".loginvalifield").css("margin-top", "20px").css("width", "280px").css("border-bottom", "none");
            $("#checkCode").css("height", "40px").css("line-height", "40px");
            $(".loginbtn").css("background", "url(../images/GJXJlogin/login_btn.png) no-repeat").css("margin-top", "15px").css("height", "50px");
            titleWidth = div_loginTitle.offsetWidth;
            $(".logintable").css("margin-top", "170px").css("width", "280px").css("height", "426px");
            div_loginTitle.style.left = (fullWidth - titleWidth) / 2 + "px";
            div_loginBox.style.left = ((fullWidth - 280) / 2 + leftoffset) + "px";
            $("#div_loginTitle").css("background", "url(../images/GJXJlogin/" + host + "_tit.png) no-repeat");
            $("#div_middle").css("background", "url(../images/GJXJlogin/" + host + "_bg.jpg) no-repeat");
            $("#div_middle").css("background-repeat", "no-repeat");
            $("#div_middle").css("background-position", "50% 110%");
            $("#div_middle").css("height", "863px");
            $("#checkCode").css("width", "94px");
            $("#checkCode").css("height", "40px");
            $("#topBgColor").css("background-color", "#3FD0FD");
            $("body").css("background-color", "#31b4ff");
            $("#div_foot").show();
            $("#div_foot").css("background-color", "#31b4ff");
          }
        }
      }
    window.onload = function () {
      noIframe();
      createCode();
      autoResize();
      getPublicKey();
      $(window).on("resize", autoResize);
      document.getElementById('username').focus();
    }
  </script>
  <script>
    var i = "登录中..."
    //表单提交
    $("#fm1").submit(function () {
      //验证用户名与密码
    function getPublicKey() {
      $.get("getPublicKey", function (rs) {
        if (rs && rs.code == 200) {
          window.encrypt = new JSEncrypt();
          encrypt.setPublicKey(rs.result);
        }
      });
    }
    function sysValidate() {
      // 验证用户名与密码
      var theUsername = document.getElementById("username").value;
      if (theUsername.length <= 0) {
        alert("请输入用户名!");
        $("#eMsg").html("提示:请输入用户名!");
        $("#username").focus();
        return false;
      }
      var thePassword = document.getElementById("password").value;
      if (thePassword.length <= 0) {
        alert("请输入密码!");
        $("#eMsg").html("提示:请输入密码!");
        $("#password").focus();
        return false;
      }
      //验证验证码(2019-03-28去掉 by XiaoQi)
      /*if (!isValid(thePassword)) {
        $("#eMsg").html("提示:密码为8-20位包含字母、数字和特殊字符!");
        $("#password").focus();
        return false;
      }*/
      // 验证验证码
      var inputCode = document.getElementById("inputCode").value;
      if (inputCode.length <= 0) {
        alert("请输入验证码!");
        $("#eMsg").html("提示:请输入验证码!");
        $("#inputCode").focus();
        return false;
      }
      else if (inputCode.toUpperCase() != code.toUpperCase()) {
        alert("验证码输入有误!");
      if (inputCode.toUpperCase() != code.toUpperCase()) {
        $("#eMsg").html("提示:验证码输入有误!");
        $("#inputCode").val("").focus();
        createCode();
        return false;
      }
      //$("#uName").val(encrypt.encrypt(theUsername));
      //$("#uPwd").val(encrypt.encrypt(thePassword));
      //$("#uName").val(Base64.encode(theUsername));
      $("#uName").val(theUsername);
      $("#uPwd").val(Base64.encode(thePassword));
      $(":submit").attr("disabled", true);
      $(":submit").attr("value", i);
      return true;
    });
    }
    function myLoginSubmit() {
      var theSubmit = document.getElementById("misagh");
      theSubmit.submit();
    window.isBusy = false;
    function sysLogin() {
      if (isBusy || !sysValidate()) {
        return;
      }
      isBusy = true;
      var username = $.trim($("#username").val());
      var password = $("#password").val();
      var service = getQueryStr("service");
      var data = {
        "uid": encrypt.encrypt(username),
        "pwd": encrypt.encrypt(password)
      };
      $.ajax({
        url: "login",
        type: "POST",
        data: JSON.stringify(data),
        dataType: "json", // html、json、jsonp、script、text
        contentType: "application/json", // "application/json", "application/x-www-form-urlencoded",
        success: function (rs) {
          isBusy = false;
          if (!rs || rs.code != 200) {
            createCode();
            var msg = rs && rs.msg ? rs.msg : "登录失败!";
            $("#eMsg").html(msg);
            return;
          }
          var service = getQueryStr("service");
          if (service) {
            service += (service.indexOf("?") > -1 ? "&" : "?") + "token=" + rs.result.token;
            location.href = service;
            return;
          }
          location.href = location.href.replace("/sign/toLogin", "/sign/toIndex");
        },
        error: function (e) {
          isBusy = false;
          console.error(e);
          alert("登录出错,请联系管理员!");
        }
      });
    }
    function ajax(url, type, data, dataType, contentType, fn, efn) {
      $.ajax({
        url: url,
        type: type,
        data: data,
        dataType: dataType || "json", // html、json、jsonp、script、text
        contentType: contentType || "application/json", // "application/x-www-form-urlencoded"
        success: function (data) {
          fn(data);
        },
        error: function (e) {
          console.error(e);
          fn();
        }
      });
    }
    // 获取URL参数
    function getQueryStr(name) {
      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
      var r = window.location.search.substr(1).match(reg);
      if (r != null) {
        return decodeURI(r[2]);
      }
      return null;
    }
    document.onkeydown = function (e) {
      var ev = window.event || e;
      var code = ev.keyCode || ev.which || ev.charCode;
      if (code == 13) {
        sysLogin();
      }
    }
    // 密码是否合规
    function isValid(pwd) {
      if (pwd) {
        var regex = new RegExp('^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\W!@#$%^&*`~()\\-_+=,.?;<>]{16,30}$');
        return regex.test(pwd)
      }
      return false;
    }
  </script>
</body>