﻿//显示登录框或已登录框
function DoLoad() {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/web/LoginService2.asmx/DoWithLogin",
        data: "{ }",
        dataType: 'json',
        success: function(result) {
            if (document.getElementById("login") != null) {
                document.getElementById("login").innerHTML = result.d;
            }
        }
    });
}
//用户登录
function Login() {
    var userName = document.getElementById("txtLoginId").value;
    var password = document.getElementById("txtPwd").value
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/web/LoginService2.asmx/Login",
        data: "{userName:'" + userName + "',password:'" + password + "'}",
        dataType: 'json',
        success: function(result) {
            if (result.d == "success") {
                window.location.href = "/Member/Successful.aspx";
            } else {
                window.location.href = "/Member/Login.aspx";
            }
        }
    });

}
//设置已登录信息
function ReturnLoginInfo() {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/web/LoginService2.asmx/ReturnLoginInfo",
        data: "{ }",
        dataType: 'json',
        success: function(result) {
            if (result.d != "") {
                if (document.getElementById("loginInfo") != null) {
                    document.getElementById("loginInfo").innerHTML = result.d;
                }
            }
        }
    });
}
//页面加载
$(document).ready(function() {
    DoLoad();
    ReturnLoginInfo()
});