function yanzheng() {
    if (jQuery("#user_pwd1").val() != "" && jQuery("#user_pwd").val() == jQuery("#user_pwd1").val()) {
    } else {
        layer.confirm('俩次输入密码不一致，请重新输入！', { btn: ['确定'] });
        jQuery("#user_pwd").focus();
    }
}

function register() {
    var name = jQuery("#user_name").val();
    var pwd = jQuery("#user_pwd").val();
    var pwd1 = jQuery("#user_pwd1").val();
    var code = jQuery("#code").val();
    if (name == "") {
        layer.confirm('登录名不能为空', { btn: ['确定'] //按钮
        });
        jQuery("#user_name").focus();

        return false;
    } else if (pwd == "") {
        layer.confirm('密码不能为空', { btn: ['确定'] //按钮
        });
        jQuery("#user_pwd").focus();
        return false;
    } else if (pwd1 == "") {
        layer.confirm('确认密码不能为空', { btn: ['确定'] //按钮
        });
        jQuery("#user_pwd1").focus();
        return false;
    } else if (code == "") {
        layer.confirm('验证码不能为空', { btn: ['确定'] //按钮
        });
        jQuery("#code").focus();
        return false;
    } else {
        return true;
    }
}

function Yusername() {
    var un = jQuery("#user_name").val();
    if (un != "") {
        jQuery.get("/Member/YuserName.ashx", { u: un }, function (data) {
            if (data == "True") {
            }
            else {
                layer.confirm('登录账号已存在！', { btn: ['确定'] });
                jQuery("#user_name").focus();
            }
        });
    }
}

function registerForm() {
    jQuery("#form1").ajaxSubmit({
        success: function (rs) {
            if (rs == "0") {
                var userName = jQuery("#user_name").val();
                var userPwd = jQuery("#user_pwd").val();
                var code = jQuery("#code").val();

                var parm = 'action=login&code=' + escape(code) + '&user=' + escape(userName) + '|' + escape(userPwd);
                getAjax('/Frame/Frame.ashx', parm, function (rs) {
                    if (parseInt(rs) == 1) {
                    } else if (parseInt(rs) == 2) {
                        layer.confirm('账户被锁,联系管理员', { btn: ['确定'] });
                        jQuery("#user_name").focus();
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 4) {
                        layer.confirm('账户或密码有错误', { btn: ['确定'] });
                        jQuery("#user_name").focus();
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 6) {
                        layer.confirm('该用户已经登录', { btn: ['确定'] });
                        jQuery("#user_name").focus();
                        CheckingLogin(0);
                        return false;
                    } else if (parseInt(rs) == 3) {
                        setTimeout(Load, 1000);
                    } else {
                        CheckingLogin(0);
                        layer.confirm('服务器连接不上,联系管理员！', { btn: ['确定'] });
                        window.location.href = window.location.href.replace('#', '');
                        return false;
                    }
                });

            }
            else if (rs == "2") {
                layer.confirm('用户名重复,请重新输入！', { btn: ['确定'] });
                jQuery("#user_name").focus();
            } else if (rs == "3") {
                layer.confirm('验证码输入不正确,请重新输入！', { btn: ['确定'] });
                jQuery("#code").focus();
            } else {
                layer.confirm('操作失败,请重试！', { btn: ['确定'] });
                window.location.reload();
            }
        },
        error: function (error) { layer.confirm('操作失败！', { btn: ['确定'] }); },
        dataType: "text",
        url: "/Mall/Sregister.aspx",
        post: "post"
    });
}
function CheckingLogin(id) {
    if (id == 1) {
        jQuery("#RegisterButton").attr("disabled", true);
        jQuery("#RegisterButton").html("注册中");
        layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

    } else {
        layer.closeAll('loading');
        jQuery("#RegisterButton").attr("disabled", false);
        jQuery("#RegisterButton").html("注册");

    }
}
//注册成功到首页
function Load() {
    location.href = "/"
}
function RegisterBtn() {
    if(register()) {
        registerForm();
    }
}

