管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-28 7a6a214cedde6d78058ecbf0eb964e6acb3e97c5
src/main/resources/static/js/login.js
@@ -2,9 +2,9 @@
window.code = "";
// 创建验证码
// 创建验证码
function createCode() {
    var codeLength = 4, code = ""; // 验证码的长度
    var codeLength = 4, code = ""; // 验证码的长度
    var checkCode = document.getElementById("checkCode");
    var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
@@ -17,7 +17,7 @@
    }
}
// 获取公钥
// 获取公钥
function getPublicKey() {
    $.get("getPublicKey", function (rs) {
        if (rs && rs.code == 200) {
@@ -27,36 +27,36 @@
    });
}
// 验证
// 验证
function sysValidate() {
    // 验证用户名与密码
    // 验证用户名与密码
    var theUsername = document.getElementById("username").value;
    if (theUsername.length <= 0) {
        $("#eMsg").html("提示:请输入用户名!");
        $("#eMsg").html("提示:请输入用户名!");
        $("#username").focus();
        return false;
    }
    var thePassword = document.getElementById("password").value;
    if (thePassword.length <= 0) {
        $("#eMsg").html("提示:请输入密码!");
        $("#eMsg").html("提示:请输入密码!");
        $("#password").focus();
        return false;
    }
    /*if (!isValid(thePassword)) {
      $("#eMsg").html("提示:密码为8-20位包含字母、数字和特殊字符!");
      $("#eMsg").html("提示:密码为8-20位包含字母、数字和特殊字符!");
      $("#password").focus();
      return false;
    }*/
    // 验证验证码
    // 验证验证码
    var inputCode = document.getElementById("inputCode").value;
    if (inputCode.length <= 0) {
        $("#eMsg").html("提示:请输入验证码!");
        $("#eMsg").html("提示:请输入验证码!");
        $("#inputCode").focus();
        return false;
    }
    if (inputCode.toUpperCase() != code.toUpperCase()) {
        $("#eMsg").html("提示:验证码输入有误!");
        $("#eMsg").html("提示:验证码输入有误!");
        $("#inputCode").val("").focus();
        createCode();
        return false;
@@ -84,7 +84,7 @@
        isBusy = false;
        if (!rs || rs.code !== 200) {
            createCode();
            var msg = rs && rs.msg ? rs.msg : "登录失败!";
            var msg = rs && rs.msg ? rs.msg : "登录失败!";
            $("#eMsg").html(msg);
            return;
        }
@@ -100,7 +100,7 @@
        location.href = location.href.replace("/sign/toLogin", "/sign/toIndex");
    }, function () {
        isBusy = false;
        alert("登录出错,请联系管理员!");
        alert("登录出错,请联系管理员!");
    });
}
@@ -110,7 +110,7 @@
        url: url,
        type: type,
        data: data,
        dataType: dataType || "json", // html、json、jsonp、script、text
        dataType: dataType || "json", // html、json、jsonp、script、text
        contentType: contentType || "application/json", // "application/x-www-form-urlencoded"
        success: function (data) {
            fn(data);
@@ -122,7 +122,7 @@
    });
}
// 获取URL参数
// 获取URL参数
function getQueryStr(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
@@ -132,7 +132,7 @@
    return null;
}
// 键盘按下事件
// 键盘按下事件
document.onkeydown = function (e) {
    var ev = window.event || e;
    var code = ev.keyCode || ev.which || ev.charCode;
@@ -141,7 +141,7 @@
    }
}
// 密码是否合规
// 密码是否合规
function isValid(pwd) {
    if (!pwd) return false;