Commit 63ff6d843ba7e73269860d02041666f003a84778
1 parent
be01f64d
add 首页新增新闻中心
Showing
2 changed files
with
64 additions
and
53 deletions
js/main.js
@@ -178,11 +178,32 @@ | @@ -178,11 +178,32 @@ | ||
178 | }); | 178 | }); |
179 | 179 | ||
180 | /* | 180 | /* |
181 | + @ 首页topbar轮播数据渲染 | ||
182 | + */ | ||
183 | + var mySwiper = new Swiper ('#swiper-container-index', { | ||
184 | + direction: 'horizontal', | ||
185 | + loop: true, | ||
186 | + speed: 500, //设置轮播时长 可以不设置 会有个默认值 | ||
187 | + autoplay: true,//可选选项,自动滑动 | ||
188 | + // 如果需要分页器 | ||
189 | + pagination: { | ||
190 | + el: '.swiper-pagination', | ||
191 | + clickable:true | ||
192 | + }, | ||
193 | + autoplay: { | ||
194 | + disableOnInteraction: false, //点击后继续轮播(这个很重要) | ||
195 | + delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 | ||
196 | + }, | ||
197 | + // 如果需要前进后退按钮 | ||
198 | + | ||
199 | + | ||
200 | + }); | ||
201 | + | ||
202 | + /* | ||
181 | @ chenbiao | 203 | @ chenbiao |
182 | @ 2018-01-23 | 204 | @ 2018-01-23 |
183 | - @ 首页新闻列表 轮播 | 205 | + @ 首页新闻图片轮播数据渲染 |
184 | */ | 206 | */ |
185 | - // 首页新闻图片轮播数据渲染 | ||
186 | function indexImgSlide(){ | 207 | function indexImgSlide(){ |
187 | var indexSlideList = $('.index_slide_list'); | 208 | var indexSlideList = $('.index_slide_list'); |
188 | var imgList= []; | 209 | var imgList= []; |
@@ -195,7 +216,7 @@ | @@ -195,7 +216,7 @@ | ||
195 | $.each(data, function(i, obj){ | 216 | $.each(data, function(i, obj){ |
196 | imgList.push( | 217 | imgList.push( |
197 | '<div class="swiper-slide red-slide">', | 218 | '<div class="swiper-slide red-slide">', |
198 | - '<a href="'+obj.href+'" class="swiper-slide news_a">', | 219 | + '<a data-href="'+obj.href+'" class="swiper-slide news_a">', |
199 | '<div class="news_title">', | 220 | '<div class="news_title">', |
200 | '<p>' + obj.newsTitle + '</p>', | 221 | '<p>' + obj.newsTitle + '</p>', |
201 | '</div>', | 222 | '</div>', |
@@ -248,8 +269,8 @@ | @@ -248,8 +269,8 @@ | ||
248 | $.each(data, function(i, obj){ | 269 | $.each(data, function(i, obj){ |
249 | list.push( | 270 | list.push( |
250 | '<li>', | 271 | '<li>', |
251 | - '<p class="pos-rel">', | ||
252 | - '<a href="'+obj.href+'">' + commonStrandNum.cutString(obj.newsTitle, 26) +'</a>', | 272 | + '<p class="pos-rel red-slide">', |
273 | + '<a data-href="'+obj.href+'">' + commonStrandNum.cutString(obj.newsTitle, 26) +'</a>', | ||
253 | '<span class="pos-abs" style="bottom: 0px;right: 2px;color: rgba(0,0,0,0.5)">'+obj.time+'</span>', | 274 | '<span class="pos-abs" style="bottom: 0px;right: 2px;color: rgba(0,0,0,0.5)">'+obj.time+'</span>', |
254 | '</p>', | 275 | '</p>', |
255 | '</li>' | 276 | '</li>' |
@@ -259,52 +280,40 @@ | @@ -259,52 +280,40 @@ | ||
259 | } | 280 | } |
260 | }) | 281 | }) |
261 | } | 282 | } |
262 | - indexNewsList(); | ||
263 | - | ||
264 | - | ||
265 | - | ||
266 | - var mySwiper = new Swiper ('#swiper-container-index', { | ||
267 | - direction: 'horizontal', | ||
268 | - loop: true, | ||
269 | - speed: 500, //设置轮播时长 可以不设置 会有个默认值 | ||
270 | - autoplay: true,//可选选项,自动滑动 | ||
271 | - // 如果需要分页器 | ||
272 | - pagination: { | ||
273 | - el: '.swiper-pagination', | ||
274 | - clickable:true | ||
275 | - }, | ||
276 | - autoplay: { | ||
277 | - disableOnInteraction: false, //点击后继续轮播(这个很重要) | ||
278 | - delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 | ||
279 | - }, | ||
280 | - // 如果需要前进后退按钮 | ||
281 | - | ||
282 | 283 | ||
283 | - }); | ||
284 | - | ||
285 | - | ||
286 | - | ||
287 | - /* | ||
288 | - @ cb | ||
289 | - @ 2018-01-23 | ||
290 | - @ 切割字符串方法 commonStrandNum.cutString(str, 25) | ||
291 | - */ | 284 | + indexNewsList(); |
292 | 285 | ||
293 | - var commonStrandNum = { | ||
294 | - /* | ||
295 | - @切割字符串 | ||
296 | - @str原字符串 | ||
297 | - @num字符位数 | ||
298 | - */ | ||
299 | - cutString: function (str, num) { | ||
300 | - var _str = ""; | ||
301 | - if (str.length >= num) { | ||
302 | - var strN = str.substring(0, num); | ||
303 | - strN += "..."; | ||
304 | - _str = strN; | ||
305 | - } else { | ||
306 | - _str = str; | ||
307 | - } | ||
308 | - return _str; | ||
309 | - }, | ||
310 | - } | ||
311 | \ No newline at end of file | 286 | \ No newline at end of file |
287 | + /* | ||
288 | + @ chenbiao | ||
289 | + @ 2018-01-23 | ||
290 | + @ 打开新窗口 新闻 | ||
291 | + */ | ||
292 | + $(document).on('click','.red-slide a',function () { | ||
293 | + var link = $(this).attr('data-href'); | ||
294 | + window.open(link) | ||
295 | + }); | ||
296 | + | ||
297 | + /* | ||
298 | + @ chenbiao | ||
299 | + @ 2018-01-23 | ||
300 | + @ 切割字符串方法 commonStrandNum.cutString(str, 25) | ||
301 | + */ | ||
302 | + | ||
303 | + var commonStrandNum = { | ||
304 | + /* | ||
305 | + @切割字符串 | ||
306 | + @str原字符串 | ||
307 | + @num字符位数 | ||
308 | + */ | ||
309 | + cutString: function (str, num) { | ||
310 | + var _str = ""; | ||
311 | + if (str.length >= num) { | ||
312 | + var strN = str.substring(0, num); | ||
313 | + strN += "..."; | ||
314 | + _str = strN; | ||
315 | + } else { | ||
316 | + _str = str; | ||
317 | + } | ||
318 | + return _str; | ||
319 | + }, | ||
320 | + } | ||
312 | \ No newline at end of file | 321 | \ No newline at end of file |