<?php  
  header("Content-type:text/html;charset=utf-8");
  include("/template/top.php");?>
<?php  
  $username =  $_SESSION["glo_username"];
  if($username){
      echo"<script>alert('您已经登录，无需再次登陆');location.href='/user/index.php';</script>";
      die();
  }
?> 
  <link rel="stylesheet" href="/public/Front/css/common.css" /> 
  <link rel="stylesheet" href="/public/Front/css/login.css" /> 
  <link rel="stylesheet" href="/public/Front/css/service.css" />
  <link rel="stylesheet" href="/public/Front/css/react.css" />
  <script type="text/javascript" src="/public/Front/js/json-eps.js"></script> 
  <script type="text/javascript" charset="utf-8" src="/public/Front/user/user.js"></script></head>
  <body id="page-login">
  <div class="wrap" style="height:700px;"> 
   <?php  include("/template/menu.php");?>
   <div class="full-line"></div>
   <div class="main container page-login">
    <div class="row" style="width: 588px;margin: 0 auto;">
     <div class="login">
      <a href="/"><img src="/public/Front/images/logo.png" width="250" style="margin-left: -25px;"height="70"></a>
      <div class="hint">
       <div class="alert alert-danger alert-dismissable" id="errs" style="display:none;"></div>
      </div>
      <div class="password"> 
       <form id="loginForm">
        <div class="input-group">
         <span class="input-group-addon"><i class="fa fa-user"></i></span>
         <input type="text" name="username" id="username" autocomplete="off" placeholder="用户名或手机号码" class="form-control input-lg" />
        </div>
        <div class="input-group">
         <span class="input-group-addon"><i class="fa fa-lock"></i></span>
         <input type="password" name="password" id="password" placeholder="密码" autocomplete="off" class="form-control input-lg" />
        </div>
        <div class="input-group buttons">
         <button type="button" id="login" class="btn btn-orange">立即登录</button>
         <span><a href="forgot-password.php">忘记密码？</a></span>
        </div>
       </form>
       <div class="space1"></div>
       <h3 class="fast-reg"><a href="register.php" class="register">没有账号？立即注册</a></h3>
      </div>
     </div>
    </div>
   </div>
  </div>
  <?php  include("/template/foot.php");?>
  <script type="text/javascript">
    $(document).ready(
        function() {
            $("body").keydown(function(e) {
                var curKey = e.which;
                if (curKey == 13) {
                    $("#login").click();
                    return false;
                }
            });
            $("#login").click(
                function(e) {
                    if ($("#username").val() == "" || $("#username").val() == "账号名称") {

                        $("#errs").html("请输入用户名");
                        $("#errs").show();
                        return false;
                    }
                    if ($("#password").val() == "" || $("#password").val() == "输入密码") {
                        $("#errs").html("请输入密码");
                        $("#errs").show();
                        return false;
                    }

                    var josnObj = formToJsonObject($("#loginForm")[0]);
                    var isCanLogin = false;
                    var returnVal = $.ajax({
                        url: "/action/login.php?action=login",
                        data: josnObj,
                        type: "POST",
                        async: false,
                        cache: 'false',
                        success: function(msg) {
                            var returnObj = eval('(' + msg + ')');
                            if (!returnObj.failure) {
                                $("#errs").html(returnObj.response);
                                $("#errs").show();
                            } else {
                                fullScreen("/user/index.php");
                            }
                        },
                        error: function(msg) {
                            $("#errs").html('网络异常，请重新提交');
                            $("#errs").show();
                        }
                    });
                    return false;
                })
        });

    function fullScreen(url) {
        location.href = url;
    }
    </script>
 </body>
</html>