header.js
1.8 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
$(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');
})
}
// 根据用户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);
}
}
}
});
}