|
@@ -8,36 +8,59 @@ $(function () {
|
8
|
8
|
page: 1,
|
9
|
9
|
size: 9,
|
10
|
10
|
newstitle: "",
|
11
|
|
- total: 0
|
|
11
|
+ total: 0,
|
12
|
12
|
};
|
13
|
13
|
// 加载新闻资讯列表
|
14
|
14
|
function loadNewsList(params) {
|
15
|
15
|
let newsItemHtml = "";
|
16
|
|
- $.each(params.list, function(newsIndex, newsItem) {
|
17
|
|
- newsItemHtml = '<div class="news_list_item"><img class="news_item_img" src="' + $.showImageUrl + newsItem.newspic + '" /><div class="news_item_title">' + newsItem.newstitle + '</div><div class="news_item_stitle">' + $.msToDateString(newsItem.createtime) + '</div></div>';
|
|
16
|
+ $.each(params.list, function (newsIndex, newsItem) {
|
|
17
|
+ newsItemHtml =
|
|
18
|
+ '<div class="news_list_item"><img class="news_item_img" src="' +
|
|
19
|
+ $.showImageUrl +
|
|
20
|
+ newsItem.newspic +
|
|
21
|
+ '" /><div class="news_item_title">' +
|
|
22
|
+ newsItem.newstitle +
|
|
23
|
+ '</div><div class="news_item_stitle">' +
|
|
24
|
+ $.msToDateString(newsItem.createtime * 1000) +
|
|
25
|
+ "</div></div>";
|
18
|
26
|
});
|
19
|
|
- $(".news_list_box").html(newsItem);
|
|
27
|
+ $(".news_list_box").html(newsItemHtml);
|
|
28
|
+ }
|
|
29
|
+ // 加载新闻资讯页码
|
|
30
|
+ function loadNewsPages(params) {
|
|
31
|
+ newsInfo.total = params.total || 0;
|
|
32
|
+ let newsPageHtml = "";
|
|
33
|
+ for (let _page = 0; _page < Math.ceil(params.total / 9); _page++) {
|
|
34
|
+ newsPageHtml +=
|
|
35
|
+ '<div class="news_page_prev"><img src="../img/home/scheme/jiantou_right.png" /></div><div class="news_page_num ' +
|
|
36
|
+ (_page === 0 ? "selected" : "") +
|
|
37
|
+ '">' +
|
|
38
|
+ (_page + 1) +
|
|
39
|
+ '</div><div class="news_page_next"><img src="../img/home/scheme/jiantou_right.png" /></div>';
|
|
40
|
+ }
|
|
41
|
+ $(".news_page_box").html(newsPageHtml);
|
20
|
42
|
}
|
21
|
43
|
// 搜索新闻列表
|
22
|
44
|
function searchList() {
|
23
|
45
|
let _url = $.baseUrl + "n/listc";
|
24
|
46
|
$.ajax({
|
25
|
|
- type: 'POST',
|
|
47
|
+ type: "POST",
|
26
|
48
|
url: _url,
|
27
|
49
|
dataType: "json",
|
28
|
50
|
contentType: "application/json; charset=utf-8",
|
29
|
51
|
data: JSON.stringify({
|
30
|
52
|
page: newsInfo.page,
|
31
|
53
|
size: newsInfo.size,
|
32
|
|
- newstitle: newsInfo.newstitle
|
|
54
|
+ newstitle: newsInfo.newstitle,
|
33
|
55
|
}),
|
34
|
56
|
success: function (data) {
|
35
|
57
|
if (data.code === 0) {
|
36
|
58
|
loadNewsList(data.obj);
|
|
59
|
+ loadNewsPages(data.obj);
|
37
|
60
|
} else {
|
38
|
61
|
alert(data.msg);
|
39
|
62
|
}
|
40
|
|
- }
|
|
63
|
+ },
|
41
|
64
|
});
|
42
|
65
|
}
|
43
|
66
|
// 回车搜索
|
|
@@ -46,7 +69,7 @@ $(function () {
|
46
|
69
|
let theEvent = event || window.event;
|
47
|
70
|
let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
48
|
71
|
let content = theEvent.target.value;
|
49
|
|
- search_helpcomm = content;
|
|
72
|
+ newsInfo.newstitle = content;
|
50
|
73
|
if (code == 13) {
|
51
|
74
|
searchList();
|
52
|
75
|
}
|
|
@@ -54,9 +77,10 @@ $(function () {
|
54
|
77
|
// 输入内容改变
|
55
|
78
|
function searchInputChange(event) {
|
56
|
79
|
let theEvent = event || window.event;
|
57
|
|
- search_helpcomm = theEvent.target.value;
|
|
80
|
+ newsInfo.newstitle = theEvent.target.value;
|
58
|
81
|
}
|
59
|
82
|
$(".news_info #search_help").on("change", searchInputChange);
|
60
|
83
|
$(".news_info #search_help").on("keydown", enterSearch);
|
61
|
84
|
$(".news_info .search_box").click(searchList);
|
62
|
|
-});
|
|
85
|
+ searchList();
|
|
86
|
+});
|