﻿$(document).ready(function() {
    //判断是否登录
    $.ajax({
        type: "POST",
        contentType: "application/json;charset=utf-8",
        data: "{}",
        dataType: "json",
        url: "webService/userLogin.asmx/yesLog",
        beforeSend: function() {
        $("#waitLog").html("<img src=\"http://img.6789g.com/sy6789g/images/waiting.gif\"/>");

        },
        success: function(msg) {
        $("#waitLog").html("");
            if (msg.d != "no") {
                $("#waitLog").html("");
                $("#tab").html("");
                $("#weluser").html(msg.d + "您好！欢迎来到盛京棋牌&nbsp;&nbsp;<a href=\"#\" onclick=\"exit()\">退出</a>");
            }

        }
    });
    //用户登录
    $("#btnLogin").click(function() {
        clickMain();
    });



});

//用户登录 提交方法
function clickMain() {
    
        if ($("#userName").val() == "") {
            alert("用户名不能为空！");
            return;
        }
        else if ($("#passWord").val() == "") {
            alert("密码不能为空！");
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=utf-8",
            url: "webService/userLogin.asmx/getUser",
            data: "{userName:'" + $("#userName").val() + "',passWord:'" + $("#passWord").val() + "'}",
            dataType: "json",
            beforeSend: function() {
            $("#waitLog").html("<img src=\"http://img.6789g.com/sy6789g/images/waiting.gif\"/>");

            },
            success: function(result) {
                if (result.d == "fengT") {
                    $("#waitLog").html("");
                    alert("您的账号已经被封停，详情请联系客服400-662-2789（仅限手机用户拨打）");
                }
                else {
                    if (result.d != "nologin") {
                        $("#waitLog").html("");
                        $("#tab").html("");
                        $("#weluser").html(result.d + " 您好！欢迎来到盛京棋牌&nbsp;&nbsp;<a href=\"#\" onclick=\"exit()\">退出</a>");

                    }

                    else {
                        $("#waitLog").html("");
                        alert("用户名或密码不正确！");
                    }
                }
                //alert(result.d);


            },
            error: function() {
                alert("出错了！请稍后再试！");
            }
        });
 
  
}





//用户退出
function exit() {
    $.ajax({
        type: "POST",
        contentType: "application/json;charset=utf-8",
        data: "{}",
        dataType: "json",
        url: "webService/userLogin.asmx/exit",

        success: function() {
            location.href = "http://www.6789g.com/index.htm";
        },
        error: function() {
            alert("出错了！请稍后再试！");
        }

    });
}

