header.js 3.25 KB
$(function () {
    newsCenterData();
    if (getItem('myCookie') && getItem('myCookie').userid) {
        fetchNewsData(getItem('myCookie').userid, 5);
    }
    $('.head-time').html(getDateWeek());
    // 设置导航首页跳转地址
    if ($(".navigation_crumbs").length > 0 && getItem('indexUrl')) {
        $('.layui-breadcrumb a').eq(0).attr('href',getItem('indexUrl'))
    }
})
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 href="/staticViews/sysnews-center.html">'
                    li += '<p class="newsDetail ellipsis">' + result.data[i].content + '</p>'
                    li += '<div class="newsDetail-time"><span>' + result.data[i].addTime + '</span>'
                    li += '<span class="read">我知道了</span></div>'
                    li += '</a>'
                    li += '</dd>'
                    sysNewsList.append(li);
                }
            }
        }
    });
}
function getDateWeek() {
    todayDate = new Date();
    date = todayDate.getDate();
    month = todayDate.getMonth() + 1;
    year = todayDate.getYear();
    var dateweek = "";
    if (navigator.appName == "Netscape") {
        dateweek = (1900 + year) + "年" + month + "月" + date + "日 ";
    }
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        dateweek = year + "年" + month + "月" + date + "日 ";
    }
    switch (todayDate.getDay()) {
        case 0: dateweek += "星期日"; break;
        case 1: dateweek += "星期一"; break;
        case 2: dateweek += "星期二"; break;
        case 3: dateweek += "星期三"; break;
        case 4: dateweek += "星期四"; break;
        case 5: dateweek += "星期五"; break;
        case 6: dateweek += "星期六"; break;
    }
    return dateweek;
}