<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="RM.Web.Member.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>
    <title><%=RM.Common.DotNetConfig.ConfigHelper.GetAppSettings("CustomerCompanyName")%></title>
<style type="text/css">
body{background:#e5e5e5;}
.boxLogin{ background:url("/Themes/Images/Login/login_bg.gif"); width:422px; height:306px; margin:100px auto; padding-top:145px; padding-left:365px;font-family:微软雅黑; font-weight:bold; color:#777777;}
.sign{border: medium none;width: 70px; height: 28px;border-style: none;background: none; background-image: url("/Themes/images/Login/login_btn.gif" ); cursor: pointer; }
.sign:hover{background-position: 0 -28px;}
.sign_hover{background-position: 0 -28px;}
.load{ color:Red; display:none; }
.signload{border: medium none;width: 70px; height: 28px; border-style: none;background: none; background-image: url("/Themes/images/Login/login_btn_loading.gif" );}
.txt{ border: 1px solid #A8A8A8; padding: 3px 2px 2px 2px; width:187px; height: 25px;line-height: 25px;}
.errorMsg{color:Red; font-size:12px; font-family:宋体; font-weight:normal;}
</style>
</head>
<body>
    <form id="form1" runat="server">
         <div class="boxLogin">
         <table>
         <tr>
         <td colspan="2" style="text-align:right; font-size:6px; font-weight:normal; color:#b4b5b4;">
         Copyright © 2013
         </td>
         </tr>
         <tr><td colspan="2" style="text-align:right">
         账户：<input type="text" id="txtUserName" value="" class="txt"  />
                    
          </td></tr>
         <tr><td  colspan="2" style="text-align:right">密码：<input type="password" onpaste = "return false;" id="txtUserPwd" value="" class="txt" onpaste="return false;"   />
         </td></tr>
         <tr><td>     
            <div class="load">
                    <img src="../Themes/Images/Login/loading.gif" /></div><span id="errorMsg0" class="errorMsg"></span><span id="errorMsg1" class="errorMsg"></span>
            </td>
        <td align="right">
            <input id="Log_Submit" type="button" class="sign" onclick="return CheckUserDataValid();" />
         </td></tr>
       </table>
    </div>
    </form>
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajaxSetup({ cache: false })
        //回车键
        document.onkeydown = function (e) {
            if (!e) e = window.event; //火狐中是 window.event
            if ((e.keyCode || e.which) == 13) {
                var obtnSearch = document.getElementById("Log_Submit")
                obtnSearch.focus(); //让另一个控件获得焦点就等于让文本输入框失去焦点
                obtnSearch.click();
            }
        }
        function LoginBtn() {
            var name = $("#txtUserName").val();
            var pwd = $("#txtUserPwd").val();
            //var code = $("#txtCode").val();
            $("#errorMsg0").html("");
            $("#errorMsg1").html("");
            // $("#errorMsg2").html("");
            if (name == "") {
                $("#txtUserName").focus();
                $("#errorMsg0").html("账户不能为空");
                return false;
            } else if (pwd == "") {
                $("#txtUserPwd").focus();
                $("#errorMsg1").html("密码不能为空");
                return false;
            } else {
                return true;
            }
        }
        /**
        数据验证完整性
        **/
        function CheckUserDataValid() {
            if (!LoginBtn()) {
                return false;
            }
            else {
                CheckingLogin(1);
                var userName = $("#txtUserName").val();
                var userPwd = $("#txtUserPwd").val();
                //var code = $("#txtCode").val();
                var parm = 'action=login&user_Account=' + escape(userName) + '&userPwd=' + escape(userPwd);
                getAjax('Frame.ashx', parm, function (rs) {
                    if (parseInt(rs) == 1) {
                        //$("#txtCode").focus();
                        $("#errorMsg2").html("验证码输入不正确");
                        CheckingLogin(0);
                        //ToggleCode("Verify_codeImag", '/Ajax/Verify_code.ashx');
                        return false;
                    } else if (parseInt(rs) == 2) {
                        $("#txtUserName").focus();
                        $("#errorMsg0").html("账户被锁,联系管理员");
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 4) {
                        $("#txtUserName").focus();
                        $("#errorMsg0").html("账户或密码有错误");
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 6) {
                        $("#txtUserName").focus();
                        $("#errorMsg0").html("该用户已经登录");
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 7) {
                        $("#txtUserName").focus();
                        $("#errorMsg0").html("您的账号已被禁用!");
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 3) {
                        setInterval(Load, 1000);
                    } else {
                        CheckingLogin(0);
                        alert('服务器连接不上,联系管理员！');
                        window.location.href = window.location.href.replace('#', '');
                        return false;
                    }
                });
            }
        }
        //登陆加载
        function Load() {
            window.location.href = 'MemberMain.aspx';
            return false;
        }
        //清空
        function resetInput() {
            $("#txtUserName").focus(); //默认焦点
            $("#txtUserName").val("");
            $("#txtUserPwd").val("");
        }
        function CheckingLogin(id) {
            if (id == 1) {
                $("#Log_Submit").attr("disabled", true)
                $("#Log_Submit").attr("class", "signload");
                $(".load").show();
            } else {
                $("#Log_Submit").attr("disabled", false)
                $("#Log_Submit").attr("class", "sign");
                $(".load").hide();
            }
        }
    </script>
</body>
</html>
