

///声明常用变量
var PageIndex = 1;
var PageSize = 5;
var Order = "Messige_Date";
var OrderType = "desc";
var status = 1;

///异步查询
function GetEvaluation() {
    var userid = $("#userid").val();
    var para = "action=colle&&uid=" + userid + "&&PageIndex=" + PageIndex + "&&PageSize=" + PageSize + "&&orderfile=" + Order + "&&ordertype=" + OrderType + "&&status=" + status + "&" + Math.random();
    getAjax("/Training/UserMessige/GetMessige.ashx", para, function (data) {
        if (data != "1") {
            var obj = eval('(' + data + ')')
            var Mes = eval('(' + obj.Mes + ')')
            strHtml(Mes);
        } else {
            $("#messigehtml").html("<center style=\"margin-top:15px;\"><img src=\"/Template/default/Images/nodata.gif\"></center>");
        }
    });
}
function strHtml(Mes) {
    //循环所有
    var str = "";
    if (Mes.length > 0) {
        for (var i = 0; i < Mes.length; i++) {
            str += " <div class=\"center_m4\"> <img src=\"/Mall/User_Image.ashx?id=" + Mes[i].Messige_UserID + "\" class=\"avatar fl\"/>";
            str += " <div class=\"avatar_font\" style=\"margin-top:15px;\">" + Mes[i].Messige_UserName + "</div>";
            str += " <div class=\"avatar_font\">" + JsonDate(Mes[i].Messige_Date) + "</div>";
            str += " <div class=\"clear\"></div>";
            var fujian = "";
            if (Mes[i].Messige_FileName != null && Mes[i].Messige_FileName != "" && Mes[i].Messige_FilePoth != "" && Mes[i].Messige_FilePoth != null) {
                //fujian = "<a href=\"" + Mes[i].Messige_FilePoth + "\">" + Mes[i].Messige_FileName + "</a>";
                fujian = Mes[i].Messige_FilePoth;
            }
            str += " <div class=\"avatar_font\">" + Mes[i].Messige_Content + " " + fujian + "</div>";
            str += " <div class=\"clear\"></div>";
            str += " <div class=\"comments\">";
            str += " <div style=\"margin-left:10px;\" > <span class=\"fl\" style=\"color:#6f6f6f;\" > " + JsonDate(Mes[i].CollectDate) + "</span> <a class=\"in1\" href=\"javascript:delcoll('" + Mes[i].Messige_ID + "');\" >删除</a></div>";
            str += " <div class=\"clear\"></div>";
            str += "</div></div>";
        }
    } else {
        str = "<center style=\"margin-top:15px;\"><img src=\"/Template/default/Images/nodata.gif\"></center>";
    }
    $("#messigehtml").html(str);

    var i = 0;
    $("annex").each(function () {
        $(this).attr("id", "aa" + i);
        var fileUrl = $(this).text();
        window.path2html("aa" + i, fileUrl);
        i++;
    });
}


///时间转换日期
function JsonDate(obj) {
    var data = obj;
    var date = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), 10));
    return date.getFullYear() + "-" + (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-" + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " " + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
}

function getAjax(url, parm, callBack) {
    $.ajax({
        type: 'post',
        dataType: "text",
        url: url,
        data: parm,
        cache: false,
        async: false,
        success: function (msg) {
            callBack(msg);
        }
    });
}

$(function () {
    GetEvaluation();
    parent.document.all.main.height = document.body.scrollHeight;
});
//删除我的收藏
function delcoll(mid) {
    if (confirm("是否要删除收藏！")) {
        $.get("/Training/UserMessige/UserMsgCollect.ashx", { action: "del", miid: mid, typeid: 1, r: Math.random() }, function (date) {
            if (date == "100") {
                GetEvaluation();
            } else if (date == "102") {
                alert("操作失败！");
            } else if (date == "103") {
                alert("操作异常！");
            } else {
                alert("系统异常！");
            }
        });
    }
}
