/// /// ec.account = { init: function () { ke.ui.render(); document.onkeydown = function (e) { var theEvent = window.event || e; var code = theEvent.keyCode || theEvent.which || theEvent.charCode; if (code == 13) { $('#btn_submit').click(); } }; if (ke.parm("design") != 1) { if (window.top != null && window.top.document.URL != document.URL) { window.top.location = document.URL; }; }; }, seePassword: function (el, box) { var btn = el.find(".ico"); var see = btn.hasClass("ico-eye-close"); btn.toggleClass("ico-eye-close", !see); box.find("input").attr('type', !see ? "password" : "text"); }, setHeight: function () { var hh = $(".header").outerHeight(); var bh = $(".body").height(); var fh = $(".footer").outerHeight(); var boxh = $(".login-box").outerHeight(); var wh = $(window).height(); if (wh > (hh + boxh + fh)) { $(".login-page").height(wh - hh - fh); $(".login-box").css("margin-top", ($(".body").height() - boxh) / 2); } }, login: { validate: function () { var msg = ""; var items = ke.ui.findControls("login", "input"); for (var i = 0; i < items.length; i++) { if (!items[i].validate()) { msg = L.G("请输入") +" " + items[i].skin.title; break; }; }; return msg; }, error: function (r) { var msg = ""; if (r.state == 0) msg = L.G("账号或密码不正确"); else if (r.state == 2) msg = L.G("安全验证失败,请重新验证"); else if (r.state == 3) msg = L.G("抱歉,您输入的账号不存在"); ec.notify(msg, "error") }, confirm: function () { var info = ke.createObject("login"); var msg = this.validate(); var callback = function () { ec.disable("#btn_submit", L.G("正在登录...")); new ec.api("login").post("password", info, function (r) { if (r.state == 1) { var redirect = document.referrer; if (redirect.length > 0 && redirect.indexOf("account") == -1) window.location.href = redirect; else window.location.href = "../user"; } else { ec.enable("#btn_submit", L.G("登录")); ec.account.login.error(r); } }); }; if (msg) ec.notify(msg, "question", 3000); else callback(); }, linkForget: function () { var url = L.route + "/account/forgetpwd"; if (Account.get()!="") url += "?account=" + encodeURIComponent(Account.get()); window.location.href = url; } }, register: { vcode: "", api: new ec.api("register"), countryData: [], init: function (data) { ke.ui.render(); this.inputData = data; ec.account.init(); $("#Account").change(function () { ec.account.register.validateAccount(); }); $("#Password").change(function () { ec.account.register.validatePasswrod(); }); $("#VerifyPassword").change(function () { ec.account.register.checkPasssword(); }); this.renderCountry(); }, renderCountry: function () { if (this.inputData.country) { Country.bindStore(new ke.table().load(ec.utilities.getCountry(), true)); if (this.inputData.province) { Country.change(function () { var country = Country.get(); Province.bindStore(new ke.table().load(ec.utilities.getProvince(country), true)); Province.setTriggerChange("") Province.find(".box").removeClass("illegal"); if (ec.account.register.inputData.city) { City.setTriggerChange(""); City.find(".box").removeClass("illegal"); } }); } if (this.inputData.city) { Province.change(function () { var country = Country.get(); var province = Province.get(); City.bindStore(new ke.table().load(ec.utilities.getCity(country, province), true)); City.setTriggerChange(""); City.find(".box").removeClass("illegal"); }); } var country = L.isEn ? ec.utilities.countrySource[0].ename : ec.utilities.countrySource[0].cname; Country.setTriggerChange(country); } }, getUserInfo: function () { var info = ke.createObject("register"); info.vcode = this.vcode; if (this.inputData.separateFillName) info.RealName = RealName1.get() + (L.isEn ? " " : "") + RealName2.get(); return info; }, validate: function () { var msg = ""; var items = ke.ui.findControls("register", "input"); for (var i = 0; i < items.length; i++) { var d = items[i]; if (!d.validate() && d.skin.id != "Agreement") { msg = d.skin.title.replace("*", "") + L.G(" 是必填项"); break; } else if (!Agreement.get()) msg = L.G("您还没有同意网站使用条款"); }; return msg; }, validateAccount: function () { var el = $("#Account"); var txt = Account.get(); if (txt) { this.api.post("validate/account?account=" + txt, function (r) { if (r == "Email" && ec.account.register.inputData.email) { Email.set(txt); } else if (r == "Phone" && ec.account.register.inputData.phone) { FixedNum.set(txt); } else { ec.utilities.showError1(el, r) } }); } }, validatePasswrod: function () { var el = $("#Password"); var txt = Password.get(); if (txt) { this.api.post("validate/password?password=" + txt, function (r) { if (r) ec.utilities.showError1(el, r); }); }; if (VerifyPassword.get()) { ec.account.register.checkPasssword(); } }, checkPasssword: function () { var el = $("#VerifyPassword"); var txt = VerifyPassword.get(); if (!Password.get()) ec.utilities.showError1($("#Password"), L.G("请输入密码")); else if (txt != Password.get()) ec.utilities.showError1(el, L.G("两次输入的密码不一致,请重新输入")); }, getValidateCode: function () { var el = $("#Account"); var txt = Account.get(); if (txt) { this.api.post("validate/account?account=" + txt, function (r) { if (r != "Email" && r != "Phone") ec.utilities.showError1(el, r); else ec.popup(L.G("输入图形验证码"), L.route + "/vcode", 432, 216); }); } else ec.utilities.showError1(el, L.G("请输入邮箱")); }, validateCallback: function (code) { ec.api.errorEnd = function () { ec.utilities.validateLoading(false); } ec.account.register.vcode = code; ec.hideWindow(); ec.utilities.validateLoading(true); ec.account.register.api.post("getValidateCode", ec.account.register.getUserInfo(), function (r) { ec.utilities.validateMsgBtn(60); }); }, confirm: function () { ec.api.errorEnd = function () { ec.enable($("#btn_submit"), L.G("注册")); } var msg = this.validate(); var callback = function () { ec.disable($("#btn_submit"), L.G("正在注册...")); ec.account.register.api.post("confirm", ec.account.register.getUserInfo(), function (r) { if (r.state == 1) { window.location.href = (r.redirect || "../user"); } else { ec.enable($("#btn_submit"), L.G("注册")); ec.notify(L.G("注册发生异常,请刷新页面后重试"), "error"); } }); }; if (msg) ec.notify(msg, "question"); else callback(); } }, forget: { api: new ec.api("account"), init: function () { ec.account.init(); Password.change(function () { ec.account.forget.validatePasswrod(); }); var account = ke.parm("account"); if (account!="") Account.set(decodeURIComponent(account)); }, validate: function (id) { var msg = ""; var items = ke.ui.findControls(id, "input"); for (var i = 0; i < items.length; i++) { if (!items[i].validate()) { msg = L.G("请输入") + items[i].skin.title.replace("*", ""); break; }; }; return msg; }, validatePasswrod: function () { if (Password.get()) { this.api.post("validate/password?password=" + Password.get(), function (r) { if (r) ec.utilities.showError1($("#Password"), r); }); }; }, validateVCode: function () { var info = ke.createObject("forget_step1"); var msg = this.validate("forget_step1"); var callback = function () { ec.account.forget.api.post("forget/validatevcode", info, function (r) { if (r) { $(".step-box").removeClass("step-active").eq(1).addClass("step-active"); $(".guider li").eq(0).removeClass("active").addClass("finish").find(".num").html(""); $(".guider li").eq(1).addClass("line-act"); $(".guider li").eq(2).addClass("active"); } }); }; if (msg) ec.notify(msg, "question"); else callback(); }, getValidateCode: function () { var info = ke.createObject("forget_step1"); var callback = function () { ec.utilities.validateLoading(true); ec.account.forget.api.post("getValidateCode/forgetpwd", info, function (r) { if (r == true) ec.utilities.validateMsgBtn(60); else { ec.utilities.validateLoading(false); ec.notify(r, "error", 5000); } }); }; if (info.Account) callback(); else ec.utilities.showError1($("#Account"), L.G("请输入您的账号")); }, confirm: function () { var info = ke.createObject("forget"); var msg = this.validate("forget"); if (Password.get() != Checkpwd.get()) msg = L.G("两次输入的密码不一致,请重新输入"); var callback = function () { ec.account.forget.api.post("forgetpwd", info, function (r) { if (!r) { $(".step-box").removeClass("step-active").eq(2).addClass("step-active"); $(".guider li").eq(2).removeClass("active").addClass("finish").find(".num").html(""); $(".guider li").eq(3).addClass("line-act"); $(".guider li").eq(4).addClass("active"); }; }); }; if (msg) ec.notify(msg, "question"); else callback(); } } }