<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="/static/weChat/css/public.css">
    <link rel="stylesheet" href="/static/weChat/css/bai_basic.css">
    <script src="/static/weChat/js/flexible.js"></script>
    <title>登录</title>
</head>
<body>
<div class="bai-head">
    <div class="head-left">
        <a href="/weixin/product/win/list">
            <img src="/static/weChat/images/head-left.png" />
        </a>
    </div>
    <div class="head-register">
        <a href="/weixin/login/register/init">立即注册</a>
    </div>
</div>
<div class="bai-logo">
    <img src="/static/weChat/images/bai-logo.png" />
</div>
<form id="commonLoginForm" action="/weixin/login/login" method="post">
<div class="bai-login ert">
    <div class="bai-phone">
        <input type="text" placeholder="请输入手机号/邮箱号" value="" name="j_username" id="phone_email">
        <p></p>
        <div class="bai-error"></div>
    </div>
    <div class="bai-pwd">
        <input type="password" placeholder="请输入密码" name="j_password" value="" minlength="6" maxlength="20" id="pwd">
        <p></p>
        <div class="bai-error"></div>
    </div>
    <div class="bai-commit">
        <a href="javascript:;" id="submit">登录</a>
    </div>
    <a href="/weixin/login/resetOne" class="forget-pwd">忘记密码</a>
</div>
</form>

</body>
<script src="/static/weChat/js/jquery-1.8.3.min.js"></script>

<script src="/static/weChat/js/basic.js"></script>
<script src="/static/weChat/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weChat/common/layer_mobile/need/right.css">
<script>
    //    是否为空
    function checkWed() {
        if ($('#phone_email').val() == "") {
            $('#phone_email').css({"border-bottom":"1px solid red"}).siblings('p').text('手机号/邮箱号不能为空').css({"display": "block"});
            return phone_email_ok = false;
        }else{
            $('#phone_email').css({"border-bottom":"1px solid #e6e6e6"}).siblings('p').css({"display": "none"});
            return phone_email_ok = true;
        }
    }

    function checkPwd() {
        if ($('#pwd').val() == "") {
            $('#pwd').css({"border-bottom":"1px solid red"}).siblings('p').text('密码不能为空').css({"display": "block"});
            return pwd_ok = false;
        }else{
            $('#pwd').css({"border-bottom":"1px solid #e6e6e6"}).siblings('p').css({"display": "none"});
            return pwd_ok = true;
        }
    }

    $('#submit').click(function () {
        checkWed();
        checkPwd();
        if (phone_email_ok && pwd_ok) {
            $.ajax({
                type: 'POST',
                url: "/weixin/login/login",
                data: $("#commonLoginForm").serialize(),
                dataType:"json",
                async: false,
                success: function(data){
                    if(data.status =="201"){
                        window.location.href=data.redirectUrl;
                    }
                    if(data.status =="200"){
                          window.location.href="/weixin/usercenter/index";
                    }else{
                        layer.open({
                            content: data.msg
                            ,btn: '我知道了'
                        });
                    }
                }
            });
        }
    })

</script>
</html>