| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- function resetImage() {
- var obj = document.getElementById("code_img");
- document.getElementById("code_img").src = "Handler/GetCaptchaImage.ashx?" + Math.random() * 100;
- console.log("resetImage");
- }
- function clearMsg() {
- var obj = document.getElementById("lblMsg");
- if (obj != undefined && obj != null) {
- obj.innerHTML = "";
- }
- }
- setTimeout("clearMsg()", 10000);
- $(function () {
- $(document).keydown(function (event) {
- if (event.keyCode == 13) {
- $("#btn").click();
- }
- });
- $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
- $(window).resize(function () {
- $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
- });
- var ct = $("#hCT").val();
- if (ct != "" && parseInt(ct) >= 3) {
- $("#sp_code").show();
- resetImage();
- }
- });
- function loginFn() {
- var user = $("#txtUser").val();
- var pwd = $("#txtPwd").val();
- if (user == "") {
- showMsg("请输入账号!");
- $("#txtUser").focus();
- return;
- }
- if (pwd == "") {
- showMsg("请输入密码!");
- $("#txtPwd").focus();
- return;
- }
- var code = $("#txtCode").val();
- var ct = $("#hCT").val();
- if (ct != "" && parseInt(ct) >= 3 && code == "") {
- showMsg("请输入验证码");
- $("#txtCode").focus();
- return;
- }
- $("#btn").attr("disabled", "disabled");
- postAjax("Handler/login.ashx?", "erp_user_login", "user=" + user + "&pwd=" + pwd + "&code=" + code, function (data) {
- showMsg("<span style=\"color:#0000FF\">登录成功</span>");
- window.location.href = 'index.aspx';
- }, function (data) {
- $("#btn").removeAttr("disabled");
- if (data.indexOf("验证码") != -1) {
- $("#txtCode").val("");
- $("#txtCode").focus();
- showMsg(data);
- resetImage();
- }
- else if (data.indexOf("|") != -1) {
- var dArr = data.split('|');
- showMsg(dArr[1]);
- var c = dArr[0];
- $("#hCT").val(c);
- if (parseInt(c) >= 3) {
- $("#sp_code").show();
- $("#txtCode").val("");
- resetImage();
- }
- } else {
- showMsg(data);
- }
- });
- }
- function postAjax(urlStr, type, queryString, sFn, eFn, hps) {
- if (hps != false) progressShow();
- $.ajax({
- url: urlStr + "t=" + type,
- type: "POST",
- data: queryString,
- datatype: "json",
- success: function (result) {
- if (result == "") {
- alert("操作发生错误!");
- progressHide();
- return;
- }
- var data = $.parseJSON(result);
- if (data.type == "success") {
- progressHide();
- sFn(data.result);
- } else {
- progressHide();
- if (eFn != undefined) eFn(data.result);
- else alert(data.result);
- }
- },
- error: function (data) {
- progressHide();
- alert("操作发生错误!");
- }
- });
- }
- function progressHide() {
- $(".login_msg").empty();
- }
- function progressShow() {
- $(".login_msg").html("登录中...");
- }
- function showMsg(msg) {
- $(".login_msg").html(msg);
- }
|