header.js
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$(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;
}