﻿function iniUser() {

    var IsDebug = false;

    if (IsDebug) { alert("初始化用户"); };

    var oUser = new Object();
    oUser.isLogin = false;
    oUser.username = "";
//    oUser.CFlag = "";

    if (IsDebug) { alert("判断用户cookie LoginTicket 是否存在"); };

    var vCookieInfo = $.cookie("LoginTicket");

    if (vCookieInfo == null) {
        if (IsDebug) { alert("用户cookie LoginTicket 为 null,因此返回未登录"); };
        oUser.isLogin = false;
        oUser.username = "";
//        oUser.CFlag = "";
        return oUser;
    };

    if (IsDebug) { alert("用户cookie LoginTicket 数据存在，数据如下"); };
    if (IsDebug) { alert(vCookieInfo); };

    //提取COOKIE内数据
    var arrayCookieItem = vCookieInfo.split("&");
    if (IsDebug) { alert("Cookie值数量：" + arrayCookieItem.length); };

    var theItem = new Object();
    for (var i = 0; i < arrayCookieItem.length; i++) {
        theItem[arrayCookieItem[i].split("=")[0]] = unescape(arrayCookieItem[i].split("=")[1]);
    }

    oUser.username = theItem['UserName'];
    oUser.isLogin = true;

    oUser.showUserName = function() {
        alert(this.username);
    }

    return oUser;
}
