function checklogin() { var inputname = $("#inputname").val(); var password = $("#password").val(); var remember = $("#remember").prop('checked'); if (inputname.length < 2) { $("#inputname").focus(); return; } if (password.length < 2) { $("#password").focus(); return; } if (typeof (CryptoJS) === "undefined") { var loadok= false; var wait = function (dtd) { $.ajax({ type: "GET", cache: true, url: "/pub/js/crypto/crypto-js.js", dataType: "script", async: false, success: function (msg) { dtd.resolve(); }, error: function () { dtd.reject() } }); return dtd.promise(); }; $.Deferred(wait).done(function () { loadok = true; }).fail(function () { loadok = false; }); if (!loadok) { layer.alert('加载登录JS失败'); return; } } var key = CryptoJS.enc.Latin1.parse("2016-qsc+ijn=df-"); var iv = CryptoJS.enc.Latin1.parse("exx=201607281600"); var encrypted = CryptoJS.AES.encrypt(password, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }).toString(); $.ajax({ type: "POST", cache: false, url: "/user/loginajax.aspx?t=login", data: { inputname: inputname, password: encrypted, type: remember ? 1 : 0, frommac: 'pc' }, dataType: "json", async: false, success: function (msg) { var obj = msg; if (!isjson(obj)) { layer.alert("服务器出错,请反馈给管理员。"); return; } getloginmsg(obj); }, error: function (msg) { layer.alert(msg.responseText); } }); } $(document).ready(function () { $.ajax({ type: "POST", cache: false, url: "/user/loginajax.aspx?t=islogin", dataType: "json", async: false, success: function (msg) { checkislogin(msg); } }); $("#inputname").focus(function () { layer.closeAll('tips'); }); $("#password").focus(function () { }); }); flags = true; $(document).ready( function() { $("input").keyup( function () { if (flags) { layer.closeAll('tips'); } flags = true; } ); //$("#loginform").attr("tabindex", 0); $("#loginform").keydown(function (e) { if (e.which == 13) { enterdown(); } }); } ); function enterdown() { flags = false; if ($("#inputname").val().length <= 1) { $("#inputname").focus(); } else if ($("#password").val().length < 1) { $("#password").focus(); } else { $("#checkbutton").click(); } } function checkislogin(msg) { var obj = msg; if (!isjson(obj)) return; setislogin(obj); } function isjson(obj) { var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; return isjson; } function loginout() { $.ajax({ type: "POST", cache: false, url: "/user/loginajax.aspx?t=loginout", dataType: "html", async: false, success: function (msg) { if (msg == "1") { setloginout();} }, error: function (msg) { layer.alert(msg.responseText); } }); } function getcookies(cookiname) { if (cookiname && cookiname != '') { return getCookie(cookiname); } else { return "";} }