<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Us.Web.admin.login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8,chrome=1" />
<title><%=AppConfig.sSoftName +"-"+ AppConfig.sSoftCompanyName%></title>
<link href="style/login/images/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/admin/js/jquery/jquery-1.12.3.min.js"></script>

<script type="text/javascript" src="/admin/js/Us.Library.V1.js"></script>


<script type="text/javascript" src="/admin/easyui/aridialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/admin/easyui/aridialog/iframeTools.js"></script>
<script type="text/javascript" src="js/SystemAlert.js"></script>
<script type="text/javascript">
    if (self != top) { top.location = self.location; }
    var sLoginID = '<%=sLoginID %>';
    $(function () {
        AutoHight();
        getSysCode();
        $("#userid").val(sLoginID);
        $("#userid")[0].focus();
        $("#btnsubmit").click(function () { UserLogin(); });
        $("#btnreset").click(function () { UserReset(); });
        //$("#imgcode").attr("src", $("#imgcode").attr("src") + "?");
    });
    $(window).resize(function () {
        //执行代码块
        AutoHight();
    });
    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            console.debug(event.keyCode);
            
            var userid, userpwd, usercode;
            userid = $("#userid").val();
            userpwd = $("#userpwd").val();
            usercode = $("#usercode").val();
            if (userid.length == 0)
            {
                $("#userid")[0].focus();
                return;
            }
            if (userpwd.length == 0) {
                $("#userpwd")[0].focus();
                return;
            }
            if (usercode.length == 0) {
                $("#usercode")[0].focus();
                return;
            }
            if ($("#btnsubmit").is(":focus")) {
                //alert(1)
                //$("#btnsubmit").trigger("click");
                //获得焦点回车的话，可以直接调用click事件了；
            }
            else {
                //alert(2)
                $("#btnsubmit")[0].focus();
            }
            
        }
    });
    function UserLogin()
    {
        var ii = CareffArtAlertCloseAll();
        //关闭弹出层
        if (ii > 0)
        {
            return;
        }
       // alert();
        var userid, userpwd, usercode;
        userid = $("#userid").val();
        userpwd = $("#userpwd").val();
        usercode = $("#usercode").val();
        if (userid == "" || userid.length < 3 || userid.length > 16) {
            UsAlert('登录名称不能为空,请输入您的登录名称！');
            $("#userid")[0].focus();
            return false;
        }
        if (userpwd == "" || userpwd.length < 3 || userpwd.length > 16) {
            UsAlert('请输入密码，密码要求3-16位');
            $("#userpwd")[0].focus();
            return false;
        }
        //alert(usercode.length)
        if (usercode.length != 4) {
            UsAlert('请输验证码,验证码要求4位');
            $("#usercode")[0].focus();
            return false;
        }
    
        var data = JSON.stringify({
            "key": "userlogin",
            "userid": userid,
            "userpwd": userpwd,
            "usercode": usercode,
            "skey": "1"
        });

        //alert(JSON.stringify(data));
        US.HTTP.UsAjaxJSON(US.HTTP.BaseURL, data,
                function (d) {
                    //alert(JSON.stringify(d));
                    if (d.result == 0) {
                        getSysCode();
                        window.open(d.msg,"_self");
                    }
                    else {
                        if (d.result != 1) {
                            getSysCode();
                        }
                        else {
                            $("#userpwd")[0].focus();
                        }
                        UsAlert(d.msg);
                    }
                });
        //alert();
        
    }

    function UserReset() {
        $("#userid").val("");
        $("#userpwd").val("");
        $("#usercode").val("");
    }

    function UsAlert(info)
    {
        //alert(info);
        CareffArtAlertOne(info);
    }

    function AutoHight()
    {
        var h = $(document).height();//窗口高度
        var l = $("#login").height();//内容高度
        var martop = (h - l) / 2;//平分
        if (martop > 200)
        {
            martop = 200;//具体顶部太高也难看，最大值；
        }
        $("#login").css({ "margin-top": martop+"px"});
    }

    function getSysCode()
    {
        var url = US.HTTP.URLAdd("/admin/basic/syscode.aspx");
        $("#imgcode").attr("src", url);
    }
</script>

<%--<script type="text/javascript" src="/admin/js/uslogin.js"></script>--%>
<style type="text/css">
.syscode{margin-top:-3px; width:60px; height:22px;  border:0px;}
</style>
<!--[if IE]>
<style type="text/css">
.syscode{margin-top:3px;}
</style>
<![endif]-->
</head>
<body>
    <%--<div id="loading"><div id="divloading"><img src="/admin/style/default/images/loading.gif" /></div></div>--%>
<form action="#" onsubmit="return false;" method="post">
   <%-- <%=NoAutoInputStr %>--%>
  <div id="login">
    <div id="top">
      <div id="top_left"><img src="style/login/images/login_03.gif" /></div>
      <div id="top_center"></div>
    </div>
    <div id="center">
      <div id="center_left"></div>
      <div id="center_middle">
        <div id="user">
          <label for="userid">登录名称</label>
          <input type="text"  id="userid" name="userid" maxlength="20" class="input input110" />
        </div>
        <div id="password">
          <label for="userpwd">登录密码</label>
          <input type="password"  id="userpwd" name="userpwd" maxlength="20"  class="input input110"/>
          
        </div>
        <div id="check">
          <label for="usercode">验证码　</label>
          <input type="text" id="usercode" name="usercode" maxlength="4"  class="input input46"/>
            <a href="javascript:getSysCode();" title="看不清楚,可以点击更新">
            <img align="absMiddle" id="imgcode" runat="server" class="syscode"/></a></div>
        <div id="btn">
          <table  style=" padding-top:10px;" border="0" cellpadding="0" cellspacing="0" align="center">
            <tr>
              <td align="center" width="80"><input type="submit"  id="btnsubmit" class="inputbtn" value="登录" />
              </td>
              <td align="center" width="80"><input type="reset"  id="btnreset" class="inputbtn" value="清空" /></td>
            </tr>
          </table>
        </div>
      </div>
      <div id="center_right"></div>
    </div>
    <div id="down">
      <div id="down_left">
        <div id="inf"> <span class="inf_text">版权信息</span> <span class="copyright"><%=sCopyRight%></span> </div>
      </div>
      <div id="down_center"></div>
    </div>
      
  </div><asp:Literal ID="litscript" runat="server"></asp:Literal>
</form>
</body>
</html>
