2b565883 by 任超

style:新闻

1 parent ce759704
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
110 </ul> 110 </ul>
111 <!-- 热点聚焦内容 --> 111 <!-- 热点聚焦内容 -->
112 <ul class="hotspot-list item-list"> 112 <ul class="hotspot-list item-list">
113 <li> 113 <li url="/staticImages/default-news.png">
114 <svg class="icon svg-icon" aria-hidden="true"> 114 <svg class="icon svg-icon" aria-hidden="true">
115 <use xlink:href="#iconzuixin"></use> 115 <use xlink:href="#iconzuixin"></use>
116 </svg> 116 </svg>
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
124 </ul> 124 </ul>
125 <!-- 新闻动态内容 --> 125 <!-- 新闻动态内容 -->
126 <ul class="news-information-list item-list"> 126 <ul class="news-information-list item-list">
127 <li> 127 <li url="/staticImages/default-news.png">
128 <svg class="icon svg-icon" aria-hidden="true"> 128 <svg class="icon svg-icon" aria-hidden="true">
129 <use xlink:href="#iconzuixin"></use> 129 <use xlink:href="#iconzuixin"></use>
130 </svg> 130 </svg>
......
...@@ -29,12 +29,24 @@ $(function () { ...@@ -29,12 +29,24 @@ $(function () {
29 addTabs('#index'); 29 addTabs('#index');
30 initData(); 30 initData();
31 recentlyDay = getDate(); 31 recentlyDay = getDate();
32 NewsData();
33 NoticeData(); 32 NoticeData();
34 LawsData(); 33 LawsData();
35 policiesData(); 34 policiesData();
36 }); 35 });
37 function initData() { 36 function initData() {
37 // 新闻模块
38 if ($('.news-module-box .hotspot-list li').eq(0).attr('url')) {
39 $('.news-img').attr('src', $('#ulNews li').eq(0).attr('url'));
40 } else {
41 $('.news-img').attr('src', '/staticImages/default-news.png');
42 }
43 $(document).on("mouseover", ".news-module-box .item-list li", function (e) {
44 if ($(this).attr('url')) {
45 $('.news-img').attr('src', $(this).attr('url'));
46 } else {
47 $('.news-img').attr('src', '/staticImages/default-news.png');
48 }
49 })
38 // 在这里处理置顶的头部 50 // 在这里处理置顶的头部
39 let topTitle = $('.top-title').html(); 51 let topTitle = $('.top-title').html();
40 if (strLength(topTitle) > 7) { 52 if (strLength(topTitle) > 7) {
...@@ -126,57 +138,6 @@ function strLength(str) { ...@@ -126,57 +138,6 @@ function strLength(str) {
126 } 138 }
127 return realLength; 139 return realLength;
128 }; 140 };
129 //加载新闻数据
130 function NewsData() {
131 var ulNews = $("#ulNews");
132 ulNews.empty();
133 var li, publishTime;
134 $.ajax({
135 type: "get", //提交方式
136 url: portal.api_url + "/portal/MhNews/getNewsList",//路径
137 dataType: "json",
138 //数据,这里使用的是Json格式进行传输
139 success: function (result) {//返回数据根据结果进行相应的处理
140 if (result.code == 200 && result.data != null) {
141 if (result.data[0].preViewUrl) {
142 $('.news-img img').attr('src', result.data[0].preViewUrl);
143 } else {
144 $('.news-img img').attr('src', './staticImages/news_demo.jpg');
145 }
146 for (var i = 0; i < result.data.length; i++) {
147 if (i == 6) return;
148 publishTime = CutDate(result.data[i].publishTime);
149 if (result.data[i].preViewUrl) {
150 li = '<li url="' + result.data[i].preViewUrl + '"><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
151 } else {
152 li = '<li><a href="./staticViews/news/' + result.data[i].id + '.html" title="' + result.data[i].headline + '" target="_blank">';
153 }
154 li += '<div class="news_item">';
155 if (recentlyDay.indexOf(publishTime) > -1) {
156 li += '<svg class="icon svg-icon" aria-hidden="true"> <use xlink:href="#iconzuixin"></use> </svg>';
157 }
158 li += result.data[i].headline + '</div>';
159 li += '<span>' + publishTime + '</span></a></li>';
160 ulNews.append(li);
161 }
162 }
163 }
164 });
165
166 if ($('#ulNews li').eq(0).attr('url')) {
167 $('.news-img img').attr('src', $('#ulNews li').eq(0).attr('url'));
168 } else {
169 $('.news-img img').attr('src', './staticImages/news_demo.jpg');
170 }
171 $(document).on("mouseover", "#ulNews li", function (e) {
172 if ($(this).attr('url')) {
173 $('.news-img img').attr('src', $(this).attr('url'));
174 } else {
175 $('.news-img img').attr('src', './staticImages/news_demo.jpg');
176 }
177 })
178 }
179
180 //加载公告数据 141 //加载公告数据
181 function NoticeData() { 142 function NoticeData() {
182 var ulTag = $("#ulNotice"); 143 var ulTag = $("#ulNotice");
......