2b565883 by 任超

style:新闻

1 parent ce759704
......@@ -110,7 +110,7 @@
</ul>
<!-- 热点聚焦内容 -->
<ul class="hotspot-list item-list">
<li>
<li url="/staticImages/default-news.png">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#iconzuixin"></use>
</svg>
......@@ -124,7 +124,7 @@
</ul>
<!-- 新闻动态内容 -->
<ul class="news-information-list item-list">
<li>
<li url="/staticImages/default-news.png">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#iconzuixin"></use>
</svg>
......
......@@ -29,12 +29,24 @@ $(function () {
addTabs('#index');
initData();
recentlyDay = getDate();
NewsData();
NoticeData();
LawsData();
policiesData();
});
function initData() {
// 新闻模块
if ($('.news-module-box .hotspot-list li').eq(0).attr('url')) {
$('.news-img').attr('src', $('#ulNews li').eq(0).attr('url'));
} else {
$('.news-img').attr('src', '/staticImages/default-news.png');
}
$(document).on("mouseover", ".news-module-box .item-list li", function (e) {
if ($(this).attr('url')) {
$('.news-img').attr('src', $(this).attr('url'));
} else {
$('.news-img').attr('src', '/staticImages/default-news.png');
}
})
// 在这里处理置顶的头部
let topTitle = $('.top-title').html();
if (strLength(topTitle) > 7) {
......@@ -126,57 +138,6 @@ function strLength(str) {
}
return realLength;
};
//加载新闻数据
function NewsData() {
var ulNews = $("#ulNews");
ulNews.empty();
var li, publishTime;
$.ajax({
type: "get", //提交方式
url: portal.api_url + "/portal/MhNews/getNewsList",//路径
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
if (result.data[0].preViewUrl) {
$('.news-img img').attr('src', result.data[0].preViewUrl);
} else {
$('.news-img img').attr('src', './staticImages/news_demo.jpg');
}
for (var i = 0; i < result.data.length; i++) {
if (i == 6) return;
publishTime = CutDate(result.data[i].publishTime);
if (result.data[i].preViewUrl) {
li = '<li url="' + result.data[i].preViewUrl + '"><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
} else {
li = '<li><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
}
li += '<div class="news_item">';
if (recentlyDay.indexOf(publishTime) > -1) {
li += '<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#iconzuixin"></use> </svg>';
}
li += result.data[i].headline + '</div>';
li += '<span>' + publishTime + '</span></a></li>';
ulNews.append(li);
}
}
}
});
if ($('#ulNews li').eq(0).attr('url')) {
$('.news-img img').attr('src', $('#ulNews li').eq(0).attr('url'));
} else {
$('.news-img img').attr('src', './staticImages/news_demo.jpg');
}
$(document).on("mouseover", "#ulNews li", function (e) {
if ($(this).attr('url')) {
$('.news-img img').attr('src', $(this).attr('url'));
} else {
$('.news-img img').attr('src', './staticImages/news_demo.jpg');
}
})
}
//加载公告数据
function NoticeData() {
var ulTag = $("#ulNotice");
......