header.js
2.36 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
$(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);
}
}
}
});
}