﻿function GetShopCartNum() {
    $.ajax(
        {
            url: '/Ajax/Ajax_GetCookies.Aspx?Action=1&Rnd=' + Math.random(),
            type: 'get',
            success: function(xml) {
                $("#shopCartNum").html(xml);
            },
            beforeSend: function() {
                $("#shopCartNum").html("");
            }
        }
        );
}

function GetIsLogin() {
    $.ajax
    (
        {
            url: '/Ajax/Ajax_GetCookies.Aspx?Action=2&Rnd=' + Math.random(),
            type: 'get',
            success: function(xml) {
                axml = new Array();
                axml = xml.split('|');
                if (axml[0].toString() == "true") {
                    var userName = axml[1];
                    if (axml[1].length > 12) {
                        userName = axml[1].substring(0, 12) + "...";
                    }

                    $("#LoginTag").html("<a href=\"http://www.tpy100.com/UserCenter/CustInfo.aspx\"  target=\"_blank\">" + userName + "</a>欢迎您！ <a href=\"http://www.tpy100.com/UserCenter/CustInfo.aspx\"  target=\"_blank\">会员中心</a> <a href=\"http://member.tpy100.com/logout.aspx?PageFrom=http://www.tpy100.com\"  target=\"_blank\">退出登录</a>");
                }
                else {

                    var url = "http://member.tpy100.com/login.aspx?PageFrom=" + location.href;

                    $("#LoginTag").html("<a href=\"" + url + "\">登录</a> <span class=\"topNav_li\">|</span> <a href=\"http://member.tpy100.com/Register.aspx\"  target=\"_blank\">免费注册</a>  <span class=\"topNav_li\">|</span> <a href=\"http://www.tpy100.com/Apply/SubmitLoginName.aspx\"  target=\"_blank\">找回密码</a>");

                    //$("#LoginTag").html("<a href=\"" + url + "\">登录</a> <span class=\"topNav_li\">|</span> <a href=\"http://member.tpy100.com/Register.aspx\"  target=\"_blank\">免费注册</a>  <span class=\"topNav_li\">|</span> <a href=\"http://www.tpy100.com/FindPassward.aspx\"  target=\"_blank\">找回密码</a>  <span class=\"topNav_li\">|</span> <a href=\"http://www.tpy100.com/applyfindpwd.aspx\"  target=\"_blank\">密码申诉</a><span class=\"topNav_li\">|</span> <a href=\"http://www.tpy100.com/Apply/Applycancel.aspx\" title=\"恶意账号申诉\">恶意账号申诉</a> ");

                }
            }
        }
    );

}

function IsLogin() {
//    var f = false;
//    $.ajax
//    (
//        {
//            url: '/Ajax/Ajax_GetCookies.Aspx?Action=2&Rnd=' + Math.random(),
//            type: 'get',
//            success: function(xml) {
//                axml = new Array();
//                axml = xml.split('|');
//                if (axml[0].toString() == "true") {
//                    f = true;
//                }
//                else {
//                    f = false;
//                }
//            }
//        }
//    );
    //    return f;
    if ($.cookie("shopUserInfo") == null) {
        return false;
    }
    else {
        return true;
    }
}
$(function() {
    GetShopCartNum();
    GetIsLogin();
})

