加载更多
    时政要闻
      本周热榜
      汽车
      教育
      家居
      楼市
      视频

      ' + formatDateTimeForHMS(headNewsValue2.newstime * 1000) + ''; $("#scrollBox").append(timesHtml); } }); }); } } }); } sideNews(); // 获取侧边新闻 function sideNews(){ $.ajax({ type:'get', url:'https://www.cqcb.com/api/get_sideNews.php', dataType:'json', success:function(obj){ if(obj.state==1){ // 本周热榜 if(obj.db){ $.each(obj.db,function(sideNewsI,sideNewsValue){ $.each(sideNewsValue,function(sideNewsI2,sideNewsValue2){ // 本周热榜 if(sideNewsI == 'NewNews'){ var hotHtml = ""; var styleHot = "" if(sideNewsI2 == 0){ styleHot = 'style="background: #e70021; color: #fff"'; } if(sideNewsI2 == 1){ styleHot = 'style="background: #FF6514;color: #fff"'; } if(sideNewsI2 == 2){ styleHot = 'style="background: #FCAA27;color: #fff"'; } hotHtml += '

    • ' + ' ' + '
      ' + '
    • '+sideNewsValue2.title+''; } $('#'+sideNewsI+'-img').append(NewsOne); $('#'+sideNewsI+'-text').append(NewsUl); } } // 视频 if(sideNewsI == 'VideoNews'){ var NewsUl1 = ''; NewsUl1 += '
      ' + ' ' + '

      ' + '

      '+sideNewsValue2.title+'' + ' ' + ' '; $('#video-r').append(NewsUl1); } }); }); } } } }); } function rTopAd() { $.ajax({ type: "GET", url: 'https://mxw.cqwb.com.cn/weixin/json.php?enews=adpcright', dataType : "jsonp", jsonpCallback:"success_jsonpCallbackadpcright", contentType: "application/x-www-form-urlencoded; charset=utf-8", success: function(data){ var rTopAdLen = data.newslist.length; var rTopAd1 = '',rTopAd2 = '',rTopAd3 = '',rTopAd4 = '',rTopAd5='',rTopAdHtml=''; if (rTopAdLen>0) { var obj = data.newslist; $.each(obj,function(j,v){ // PC右侧广告位一 if (v.types==6) { rTopAd1 = '

      '; } // PC右侧底部广告位二 else if (v.types==7) { rTopAd2 = '
      '; } // PC右侧广告位三 else if (v.types==8) { rTopAd3 = '
      '; } // PC右侧广告位四 else if (v.types==9) { rTopAd4 = '
      '; } // PC右侧广告位五 else if (v.types==15) { rTopAd5 = '
      '; } }); rTopAdHtml = rTopAd1+rTopAd2+rTopAd3+rTopAd4+rTopAd5; $("#adRightTop").append(rTopAdHtml); } } }); } rTopAd(); let page = 0; let number = 12; //默认加载条数 $.ajax({ type: "GET", url: 'https://mxw.cqwb.com.cn/weixin/json.php?enews=chanel', dataType : "jsonp", jsonpCallback:"success_jsonpCallback", contentType: "application/x-www-form-urlencoded; charset=utf-8", success: function(data){ var indexNewsList = data; // var indexNewsList = JSON.parse(newsInfo) //console.log(indexNewsList) let length = page * number; let more = indexNewsList.newsList.slice( page * number, (page + 1) * number ); page++; // 页码 if (more.length < number) { $('.loadMore').text('没有更多了'); } more.map((newsItem, newsIndex) => { newsItem.titleurl = urlhttp(newsItem.titleurl); addNews(newsItem, newsIndex + length); }); $('.loadMore').click(function () { let length = page * number; let more = indexNewsList.newsList.slice( page * number, (page + 1) * number ); page++; // 页码 if (more.length < number) { $('.loadMore').text('没有更多了'); } more.map((newsItem, newsIndex) => { newsItem.titleurl = urlhttp(newsItem.titleurl); addNews(newsItem, newsIndex + length); }); }); } }); }) function urlhttp(url){ if(url.substr(0,7).toLowerCase() == "http://" || url.substr(0,8).toLowerCase() == "https://"){ url = url; }else{ url = "https://www.cqcb.com" + url; } return url; } function formatDateTimeForHMS(obj) { if (obj == null) { return null } let date = new Date(obj); let y = 1900 + date.getYear(); let m = "0" + (date.getMonth() + 1); let d = "0" + date.getDate(); let h = "0" + date.getHours(); let mm = "0" + date.getMinutes(); let s = date.getSeconds(); return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length) + " " + h.substring(h.length - 2, h.length) + ":" + mm.substring(mm.length - 2, mm.length); }