header.js 2.36 KB
$(function () {
    newsCenterData();
    if (getItem('myCookie') && getItem('myCookie').userid) {
        fetchNewsData(getItem('myCookie').userid, 5);
    }
})
function newsCenterData() {
    $(document).on("mouseover", ".sysNewsList .newsDetail", function (e) {
        $('.sysNewsList .newsDetail').addClass('ellipsis');
        $(this).removeClass('ellipsis');
    })
    $(document).on("mouseout", ".sysNewsList .newsDetail", function (e) {
        $('.sysNewsList .newsDetail').addClass('ellipsis');
    })

    $(document).on("mouseover", ".sysNewsItem .userImage", function (e) {
        $(this).attr('src','/staticImages/sexiaoxi.png');
    })
    $(document).on("mouseout", ".sysNewsItem .userImage", function (e) {
        $(this).attr('src','/staticImages/xiaoxi.png');
    })
    $(document).on("mouseover", ".sysNewsList", function (e) {
        $('.sysNewsItem .userImage').attr('src','/staticImages/sexiaoxi.png');
    })
    $(document).on("mouseout", ".sysNewsList", function (e) {
        $('.sysNewsItem .userImage').attr('src','/staticImages/xiaoxi.png');
    })
}
// 根据用户id及展示数量读取消息提醒
function fetchNewsData(userid, size) {
    var sysNewsList = $("#sysNewsList-con");
    sysNewsList.empty();
    var li;
    $.ajax({
        type: "get",  //提交方式  
        url: portal.api_url + "/portal/messageRemind/getDetailByUserid?userid="+userid+"&size="+size,//路径  
        dataType: "json",
        //数据,这里使用的是Json格式进行传输  
        success: function (result) {//返回数据根据结果进行相应的处理           
            if (result.code == 200 && result.data != null) {
                for (var i = 0; i < result.data.length; i++) {
                    li = '<dd>'
                    li += '<a>'
                    li += '<p class="newsDetail ellipsis">'+result.data[i].content+'</p>'
                    li += '<div class="newsDetail-time"><span>'+result.data[i].addTime+'</span>'
                    if (result.data[i].status == 0) {
                        li += '<span clas="unread" style="color: #ff0000">未读</span></div>'
                    }else {
                        li += '<span class="read">已读</span></div>'
                    }
                    li += '</a>'
                    li += '</dd>'
                    sysNewsList.append(li);
                }
            }
        }
    });
}