﻿//会员登录设置
function Login() {

    var validate = new Validate().validate(
		{
		    txtIdentityId: { min: 0, message: "号码不能为空!" },
		    txtPassword: { min: 6, max: 20, message: "密码不能为空, 长度必须在 6~20 之间!" },
		    txtVerifycode: { type: "Int", message: "验证不能为空, 且必须是 4 位数字!" }
		});

		if (validate) {
        var identityid = $.trim($("#txtIdentityId").val());
        var password = $.trim($("#txtPassword").val());
        var verifycode = $("#txtVerifycode").val();

        var user = new User();

        var loginType = $.trim($("#selLoginType").val());

        // 会员登录
        if (loginType == 1) {
            user.DoLoginAccountVip(identityid, password, verifycode, ResetVerifyCode());
        }// 身份号码登录
        else {
            user.login(identityid, password, verifycode, ResetVerifyCode());
        }
    }
}

//重置验证码
function ResetVerifyCode() {
    $("#imgVerifyCode").click();
}



// 查询会员编号，依据会员身份号码
function QueryVipNum() { 
    var validate = new Validate().validate(
	{
	    txtAccountVipIdentity: { min: 0, message: "身份不能为空!" }
	});

	if (validate) {
	    var identityid = $.trim($("#txtAccountVipIdentity").val());

	    $("#divAccountVipNumList").show();
	    $("#divAccountVipNumList").load("/AccountCenter/AccountVipNumList", {identityId : identityid});
	}
}

$(function() {
    // 单击号码输入框, 显示验证码
    $("#txtIdentityId").click(function() {
        new VerifyCode().showLoginCode("#verifycode");
    });
    
    // 设置默认回车事件
    $(":text").keypress(function(e) {
        if (e.which == 13) $("#btnLogin").click();
    });

    // 单击登录按钮提交登录信息
    $("#btnLogin").click(Login);

    // 注册查询会员编号
    $("#btnQueryAccountVipNum").click(QueryVipNum);
});
