From 63ff6d843ba7e73269860d02041666f003a84778 Mon Sep 17 00:00:00 2001 From: chenbiao Date: Wed, 23 Jan 2019 20:11:40 +0800 Subject: [PATCH] add 首页新增新闻中心 --- js/main.js | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------- style.css | 4 +++- 2 files changed, 64 insertions(+), 53 deletions(-) diff --git a/js/main.js b/js/main.js index b1a0a9d..759bff0 100755 --- a/js/main.js +++ b/js/main.js @@ -178,11 +178,32 @@ }); /* + @ 首页topbar轮播数据渲染 + */ + var mySwiper = new Swiper ('#swiper-container-index', { + direction: 'horizontal', + loop: true, + speed: 500, //设置轮播时长 可以不设置 会有个默认值 + autoplay: true,//可选选项,自动滑动 + // 如果需要分页器 + pagination: { + el: '.swiper-pagination', + clickable:true + }, + autoplay: { + disableOnInteraction: false, //点击后继续轮播(这个很重要) + delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 + }, + // 如果需要前进后退按钮 + + + }); + + /* @ chenbiao @ 2018-01-23 - @ 首页新闻列表 轮播 + @ 首页新闻图片轮播数据渲染 */ - // 首页新闻图片轮播数据渲染 function indexImgSlide(){ var indexSlideList = $('.index_slide_list'); var imgList= []; @@ -195,7 +216,7 @@ $.each(data, function(i, obj){ imgList.push( '
', - '', + '', '
', '

' + obj.newsTitle + '

', '
', @@ -248,8 +269,8 @@ $.each(data, function(i, obj){ list.push( '
  • ', - '

    ', - '' + commonStrandNum.cutString(obj.newsTitle, 26) +'', + '

    ', + '' + commonStrandNum.cutString(obj.newsTitle, 26) +'', ''+obj.time+'', '

    ', '
  • ' @@ -259,52 +280,40 @@ } }) } - indexNewsList(); - - - - var mySwiper = new Swiper ('#swiper-container-index', { - direction: 'horizontal', - loop: true, - speed: 500, //设置轮播时长 可以不设置 会有个默认值 - autoplay: true,//可选选项,自动滑动 - // 如果需要分页器 - pagination: { - el: '.swiper-pagination', - clickable:true - }, - autoplay: { - disableOnInteraction: false, //点击后继续轮播(这个很重要) - delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 - }, - // 如果需要前进后退按钮 - - }); - - - - /* - @ cb - @ 2018-01-23 - @ 切割字符串方法 commonStrandNum.cutString(str, 25) - */ + indexNewsList(); - var commonStrandNum = { - /* - @切割字符串 - @str原字符串 - @num字符位数 - */ - cutString: function (str, num) { - var _str = ""; - if (str.length >= num) { - var strN = str.substring(0, num); - strN += "..."; - _str = strN; - } else { - _str = str; - } - return _str; - }, - } \ No newline at end of file + /* + @ chenbiao + @ 2018-01-23 + @ 打开新窗口 新闻 + */ + $(document).on('click','.red-slide a',function () { + var link = $(this).attr('data-href'); + window.open(link) + }); + + /* + @ chenbiao + @ 2018-01-23 + @ 切割字符串方法 commonStrandNum.cutString(str, 25) + */ + + var commonStrandNum = { + /* + @切割字符串 + @str原字符串 + @num字符位数 + */ + cutString: function (str, num) { + var _str = ""; + if (str.length >= num) { + var strN = str.substring(0, num); + strN += "..."; + _str = strN; + } else { + _str = str; + } + return _str; + }, + } \ No newline at end of file diff --git a/style.css b/style.css index 75b1de4..a63374b 100755 --- a/style.css +++ b/style.css @@ -2645,6 +2645,8 @@ a:hover{ background: #fff; } - +.red-slide{ + cursor: pointer; +} -- libgit2 0.21.4