var cookieName=getCookie('admin_username'); var cookiePass=getCookie('admin_password'); var cookieRememberMe=getCookie('admin_rememberMe'); function getCookie(name){ //获取cookie字符串 var strCookie=document.cookie; //将多cookie切割为多个名/值对 var arrCookie=strCookie.split("; "); var value=""; //遍历cookie数组,处理每个cookie对 for(var i=0;i0) return b.focus(), void login.showTip("邮箱格式不正确", b.nextElementSibling); if ("" == c.value.trim()) return c.focus(), void login.showTip("密码不能为空", c.parentNode.querySelector(".error-tip")); b.nextElementSibling.innerHTML = "", c.parentNode.querySelector(".error-tip").innerHTML = ""; if (verycode!=null){ if ("" == verycode.value.trim()) return verycode.focus(), void login.showTip("验证码为空!请输入验证码!", verycode.nextElementSibling.nextElementSibling); verycode.parentNode.querySelector(".error-tip").innerHTML = ""; } // var d = document.getElementsByClassName("logo-dot")[0]; // d.style.display = "inline-block", a.getElementById("username").value = b.value.trim(), a.getElementById("password").value = c.value.trim(); //document.getElementById("loginform").submit() var encrypt = new JSEncrypt(); encrypt.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz7TFpyBMV/JiHHPOVvi44zNvt6vqzTuj1Hn6InKqW5bbq2fatOJbCoCPm3xUaWaaOyai+EiRERGRBOPnOEds0bMvfIQ4+iVc+To/f2FPaK8eTBhUGHnwHpSVbgnfnTRtbvfRyf4SzzamnIKwFr9iBeW6HegGVxOGx7f1J0xSlgvYldU4hhuWohQDXdcG0iL+1XwJJrmDTixLJHEIPxtygQVMp8jYCMha6NK5eTNoxD0WVqIppFgR9rCjF+pZECXZmIi4iHtCFZY3VVs5paJ1OIJkNVAq/IMtwtRRb8NyztCrhTmM9/tWebG0etYuVtBOlvC4ZBniKNC8kJ/pmtuhYQIDAQAB"); var encyptUserName= encrypt.encrypt(b.value.trim()); var encyptUserPass=encrypt.encrypt(c.value.trim()); $.ajax({ type: "post", url: ctx + "login", xhrFields: { withCredentials: true }, data: { "username": encyptUserName, "password": encyptUserPass, "validateCode" : verycode!=null?verycode.value:"", "rememberMe": rememberMe }, success: function(r) { // d.style.display = "none"; if (r.code == 0) { location.href = ctx + 'index'; } else { $.modal.closeLoading(); $('.imgcode').click(); $(".code").val(""); $.modal.msg(r.msg); } } }); }, forget: function() { var a = document.getElementById("login_email"), b = document.getElementById("error-tip"); var ok_tip=document.getElementById("success-tip"); if ("" == a.value.trim()) return a.focus(), void login.showTip("邮箱不能为空", b); if (!/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/.test(a.value.trim())) return a.focus(), void login.showTip("邮箱格式不正确", b); var c = document.getElementsByClassName("logo-dot")[0]; c.style.display = "inline-block", ok_tip.style.display = "none"; b.innerHTML = ""; $.ajax({ url: "/reset", type: "post", data: { email: a.value.trim() }, success: function(json) { json=JSON.parse(json); //alert(JSON.stringify(json)); if(json.type=="success"){ document.getElementById("signin_btn").style.backgroundColor="#ababab"; document.getElementById("signin_btn").removeAttribute('onclick'); ok_tip.innerHTML = "已经发送重置密码邮件,有效时间60分钟,请查收"; ok_tip.style.display = "block", c.style.display = "none"; }else{ b .style.display = "block", b .innerHTML = json.content; a.focus(); c.style.display = "none"; } /* "error" == b.type ? (a.nextElementSibling.innerHTML = json.content, a.focus()) : "success" == b.result && (a.nextElementSibling.innerHTML = "已经发送重置密码邮件,有效时间30分钟,请查收"), a.nextElementSibling.style.display = "block", c.style.display = "none", */ } }), login.weixin.loaded = !0 }, /*注册*/ signup: function() { var a = document, b = a.getElementById("login_email"), c = a.getElementById("login_password"), d = a.getElementById("login_fullname"); if ("" == b.value.trim()) return b.focus(), void login.showTip("邮箱不能为空", b.nextElementSibling); if (!/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/.test(b.value.trim())) return b.focus(), void login.showTip("邮箱格式不正确", b.nextElementSibling); if ($.inArray($.trim(b.value), login.tempmails) >= 0) return b.focus(), void login.showTip("此类型邮箱暂不支持", b.nextElementSibling); if ("" == c.value.trim()) return c.focus(), void login.showTip("密码不能为空", c.nextElementSibling); if ("" == d.value.trim()) return d.focus(), void login.showTip("昵称不能为空", d.nextElementSibling); if (d.value.length > 15) return d.focus(), void login.showTip("昵称最大长度为15位", d.nextElementSibling); a.getElementById("login_email").value = b.value.trim(), a.getElementById("login_password").value = c.value.trim(), a.getElementById("login_fullname").value = d.value.trim(), b.nextElementSibling.innerHTML = "", c.nextElementSibling.innerHTML = "", d.nextElementSibling.innerHTML = ""; var e = document.getElementsByClassName("logo-dot")[0]; e.style.display = "inline-block", document.getElementById("signup_form").submit() }, bind: function() { var a = $("#account"), b = $("#password"), c = "^.{6,24}$", d = document.getElementById("account"), e = document.getElementById("password"); if ("" == $.trim(a.val())|| "" == $.trim(b.val())) { if ("" == $.trim(a.val())) { a.focus(); var d = document.getElementById("account"); return login.showTip("请输入账户", d.nextElementSibling), !1 } if ("" == $.trim(b.val())) return b.focus(), login.showTip("请输入密码", e.nextElementSibling), !1 } else { if ("" == $.trim(a.val()) || $.trim(a.val()).length<3 || "" == $.trim(b.val())) return a.focus(), login.showTip("账户格式不正确", d.nextElementSibling), !1; if (!$.trim(b.val()).match(c)) return b.focus(), login.showTip("密码格式错误", e.nextElementSibling), !1; a.val($.trim(a.val())), b.val($.trim(b.val())), $("#signin_bind_form").submit();//提交绑定用户表单 } }, renderBg: function() { var a = document.getElementById("bg-canvas"), b = document.documentElement.clientWidth, c = document.documentElement.clientHeight; a.width = b, a.height = c; var d = a.getContext("2d"); d.strokeStyle = "#f6f6f6", d.lineWidth = 1, d.beginPath(), d.translate(.5, .5); for (var e = 20; e <= c; e += 20) d.moveTo(0, e), d.lineTo(b, e); for (var e = 20; e <= b; e += 20) d.moveTo(e, 0), d.lineTo(e, c); d.closePath(), d.stroke() }, }; login.init();