123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- function newPage() {
- var obj_2 = {
- obj_box: ".page_1",
- total_item: +window.sessionStorage.getItem("total"), //总共数据
- type: +window.sessionStorage.getItem("newType"),
- per_num: 10, //每页显示数据
- current_page: 1, //当前页
- change_content: function(per_num, current_page) {
- per_num = per_num ? per_num : 10;
- current_page = current_page ? current_page : 1;
- var type = window.sessionStorage.getItem("newType");
- if (type == "undefined") {
- var data = {
- pageNo: current_page
- };
- } else {
- var data = {
- type,
- pageNo: current_page
- };
- }
- $.ajax({
- url: api + "/open/listNews",
- data,
- type: "GET",
- dataType: "json",
- success: function(data) {
- if (data.error && data.error.length) {
- alert("数据加载失败,请刷新页面");
- } else {
- var html = "";
- if (data.data.list.length) {
- for (var i = 0; i < data.data.list.length; i++) {
- var newList = data.data.list[i];
- var content = newList.content.replace(/<.*?>/gi, "");
- html +=
- "<li><a target='_blank' href=" +
- newUrl +
- "?id=" +
- newList.id +
- "><div class=news-item><div><img src=" +
- avatarUploadHost +
- newList.pictureUrl +
- " / ></div><div><h6>" +
- newList.title +
- "</h6><span>" +
- newList.releaseTimeConvert +
- "</span><div>" +
- content +
- "</div></div></div></a></li>";
- }
- window.sessionStorage.setItem("total", data.data.totalCount);
- } else {
- html =
- "<h4 style='text-align:center;margin-top:90px;color:#666' >暂无新闻动态</h4>";
- $(".page_ctrl").css({
- display: "none"
- });
- }
- $(".newslist").html(html);
- }
- }
- });
- }
- };
- //调用分页
- page_ctrl(obj_2);
- }
- function newFn() {
- // var api = window.globalConfig.apiUrl ? window.globalConfig.apiUrl : "http://kede.jishutao.com"
- $(".secondary-menu").on("click", "a", function() {
- $(".secondary-menu ul li").removeClass("active");
- $(this)
- .parent()
- .addClass("active");
- if ($(this).html() == "全部") {
- window.sessionStorage.setItem("newType", undefined);
- } else if ($(this).html() == "科德新闻") {
- window.sessionStorage.setItem("newType", 0);
- } else if ($(this).html() == "行业资讯") {
- window.sessionStorage.setItem("newType", 1);
- }
- var type = window.sessionStorage.getItem("newType");
- if(type != "undefined") {
- var data = {
- type,
- releaseStatus: 1
- }
- }else {
- var data = {
- releaseStatus: 1
- }
- }
- $.ajax({
- method: "get",
- url: api + "/open/listNews",
- data,
- success: function(data) {
- if (data.error && data.error.length) {
- alert("数据加载失败,请刷新页面");
- } else {
- var html = "";
- if(data.data.list.length) {
- for (var i = 0; i < data.data.list.length; i++) {
- var newList = data.data.list[i];
- var content = newList.content.replace(/<.*?>/gi, "");
- html +=
- "<li><a target='_blank' href=" +
- newUrl +
- "?id=" +
- newList.id +
- "><div class=news-item><div><img src=" +
- avatarUploadHost +
- newList.pictureUrl +
- " / ></div><div><h6>" +
- newList.title +
- "</h6><span>" +
- newList.releaseTimeConvert +
- "</span><div>" +
- content +
- "</div></div></div></a></li>";
- }
- window.sessionStorage.setItem("total", data.data.totalCount);
- newPage()
- }else {
- html =
- "<h4 style='text-align:center;margin-top:90px;color:#666' >暂无新闻动态</h4>";
- $(".page_ctrl").css({
- display: "none"
- });
- }
- $(".newslist").html(html);
- }
- }
- });
- });
- $(".secondary-menu > div > ul > li > a")
- .eq(0)
- .click();
- }
- newFn()
|