@{
    Layout = "~/Areas/Member/Views/_LoginLayoutPage.cshtml";
    ViewBag.Title = "账户登录";
    string loginType = ViewBag.LoginType;
}

<div class="container">
    <div class="loginBox">
        <div class="row header">
            <div class="col-md-6 col-xs-6">
                <a href="/">返回首页</a>
            </div>
            <div class="col-md-6 col-xs-6 text-right">
                没有账户？<a href="@Url.ActionUrl("Index","Reg")">去注册</a>
            </div>
        </div>
        <div class="content-box">
            <div class="media logo-media"></div>
            <div class="login-sign">会员登录</div>
            <div id="LoginBox">
                <form method="post" id="loginForm" data-validate-params="tipsStyle:3">
                    <div class="validate-all-tips-box"></div>
                    <div class="form-group">
                        <div class="controls ">
                            <input type="text" id="username" name="username" class="form-control" maxlength="50" placeholder="@ViewBag.PlaceHolder" data-validate="dataType:'*',nullMsg:'请填写登录账号'">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="controls">
                            <input type="password" id="password" name="password" class="form-control" maxlength="50" placeholder="登录密码" data-validate="dataType:'password',nullMsg:'请填写登录密码'">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    @if (ViewBag.VerificationCode == "1")
                    {
                        <div class="form-group">
                            <div class="controls">
                                <div class="input-group">
                                    <input type="text" id="_VerificationCode" name="_VerificationCode" class="form-control" maxlength="4" placeholder="输入右侧的验证码" data-validate="dataType:'*',minLength:4,minLengthErrorMsg:'验证码最少4个字符',nullMsg:'请填写验证码',checkUrl:'/E/VerificationCode/Validate',checkError:'验证码填写错误'">
                                    <span class="input-group-btn">
                                        <a class="btn btn-default btn-verificationCodeImg"><img id="verificationCodeImg" src="/E/VerificationCode/?width=100&height=39" class="ui-verificationCodeImage" /></a>
                                    </span>
                                </div>
                                <span class="help-block" id="_ValidateTips__VerificationCode"></span>
                            </div>
                        </div>

                    }
                    <div class="form-group">
                        <div class="row">
                            <div class="col-md-6 col-xs-6">
                                <span><input id="cookies" type="checkbox" name="cookies" value="1"></span>
                                <label for="cookies" class="font-weight-normal">&nbsp;记住我的登录信息</label>
                            </div>
                            <div class="col-md-6 col-xs-6 text-right">
                                <a href="@Url.ActionUrl("Index","FindPassword")">忘记密码?</a>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="controls controls-submit">
                            <button type="button" class="btn  btn-primary btn-lg col-xs-12 col-md-12  ui-pagePost" data-custom-params="url:'@Url.ActionUrl("Index")',callBack:'LoginSuccess',failCallBack:'FailCallBack',successMsg:''">登录</button>
                        </div>
                    </div>

                    <div class="form-group quickLogin  hidden">
                        <h5>使用合作账户登录</h5>
                        <div>
                            <a href="#" class="quick-login-icon qq-icon" title="QQ登录"></a>
                            <a href="#" class="quick-login-icon weixin-icon" title="微信登录"></a>
                        </div>
                    </div>
                    @Html.AntiForgeryToken()
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    if (self != top) { top.location = self.location; }
    var open =@ViewBag.Open;
    var $form = $("#loginForm");
    var $verificationCode = $("#_VerificationCode");
    var $loginBox = $("#LoginBox");
    //保存登录信息到本地
    function SaveInfo()
    {
        if ($("#cookies").prop("checked")) {
            var serializerStr = $form .SerializeJson();
            serializerStr = JsonToString(serializerStr);
            SetLocalStorage("LoginUserInfo", serializerStr);
        }
        else
        {
           RemoveLocalStorage("LoginUserInfo");
        }
    }
    //初始化
    function Init()
    {
        var serializerStr = GetLocalStorage("LoginUserInfo");
        $form.FormBind({}, serializerStr);
        $verificationCode.val("");
        if (open == 0) {
            $loginBox.text("对不起，网站登录已经关闭！");
        }
    }
    Init();

   function LoginSuccess()
    {
            layer.msg('登录成功...', {
                icon: 16,
                time: 200000, //200秒
                shade: 0.01
       });
            SaveInfo();
            var to = Request("to");
            if (to == "") {
                to="@Url.ActionUrl("Index","Default")";
            }
            top.location.href =to;
    }
    var $tipsBox = $(".validate-all-tips-box");
    var $verificationCodeImg = $("#verificationCodeImg");

    function FailCallBack(data)
    {
       $tipsBox.text(data.Msg);
    }
</script>
