123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- function getParams(url) {
- var theRequest = new Object();
- if (!url)
- url = location.href;
- if (url.indexOf("?") !== -1) {
- var str = url.substr(url.indexOf("?") + 1) + "&";
- var strs = str.split("&");
- for (var i = 0; i < strs.length - 1; i++) {
- var key = strs[i].substring(0, strs[i].indexOf("="));
- var val = strs[i].substring(strs[i].indexOf("=") + 1);
- theRequest[key] = val;
- }
- }
- return theRequest;
- }
- var objUrl = {};
- var url = window.location.href;
- var params = getParams(url);
- if (!$.isEmptyObject(params)) {
- $.each(params, function (key, val) {
- objUrl[key] = val;
- })
- }
- var page = 0;
- var size = 10;
- var thisID = 0;
- function AjaxFn() {
- page = 0;
- page++;
- $.ajax({
- type: 'GET',
- url: '/json/homeform?&page=' + page + '&limit=' + size + '&cid=' + thisID,
- dataType: 'json',
- success: function (data) {
- if (data.code == 200) {
- $('.news_list').append(ModuleWay(data.data))
- }
-
-
-
- },
- error: function (xhr, type) {
-
-
-
- }
- });
-
-
-
-
-
-
-
-
-
- }
- function ModuleWay(conditions) {
- var _html = "";
- $.each(conditions.data, function (key, val) {
- if (val.thumb != null && val.thumb != "" && val.thumb.length == 1 && val.thumb_size == 1) {
- _html += '<div class="plan_one">';
- _html += '<a href="/news/details/' + val.id + '">';
- _html += '<div class="plan_one_title">';
- _html += '<p>' + val.subject + '</p>';
- _html += ' <p> <span class="guis">' + val.source + '</span><span class="data">' + val.open_time + '</span> <span class="see"><img src="/image/see.png" alt="">' + val.clicks + '</span></p>';
- _html += '</div>';
- _html += '<div class="plan_one_img"><img src="' + conditions.url + val.thumb[0] + '" alt=""></div>';
- _html += '</a>';
- _html += '</div>';
- } else if (val.thumb != null && val.thumb != "" && val.thumb.length > 1) {
- _html += '<div class="plan_two">';
- _html += '<a href="/news/details/' + val.id + '">';
- _html += '<div class="plan_two_title">' + val.subject + '</div>';
- _html += '<div class="plan_two_img">';
- _html += '<ul>';
- for (k in val.thumb) {
- _html += '<li><img src="' + conditions.url + val.thumb[k] + '" alt=""></li>';
- }
- _html += '</ul>';
- _html += '</div>';
- _html += '<div class="plan_two_label">' + val.source + '<span class="data">' + val.open_time + '</span> <span class="see"><img src="/image/see.png" alt="">' + val.clicks + '</span></div>';
- _html += '</a>';
- _html += '</div>';
- } else if (val.thumb_size == 2) {
- _html += '<div class="plan_three">';
- _html += '<a href="/news/details/' + val.id + '">';
- _html += '<div class="plan_two_title">' + val.subject + '</div>';
- _html += '<div class="plan_three_img"><img src="' + conditions.url + val.thumb[0] + '" alt=""></div>';
- _html += '<div class="plan_two_label">' + val.source + '<span class="data">' + val.open_time + '</span> <span class="see"><img src="/image/see.png" alt="">' + val.clicks + '</span></div>';
- _html += '</a>';
- _html += '</div>';
- }
- })
- return _html;
- }
- $(function () {
-
- if (typeof objUrl.cid == "string") {
- thisID = objUrl.cid;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(".news_nav ul").on('click', 'li', function () {
- var $this = $(this);
- thisID = $this.find('a').attr('data-id');
- $('.news_list').html("");
-
- page = 0;
- fun();
- })
- console.log(thisID)
- function fun() {
-
- $('.news_list').dropload({
-
- scrollArea: window,
-
- loadDownFn: function (me) {
- page++;
- $('.dropload-down').show();
- $.ajax({
- type: 'GET',
- url: '/json/homeform?&page=' + page + '&limit=' + size + '&cid=' + thisID,
- dataType: 'json',
- success: function (data) {
-
- if (data.code == 200) {
- $('.news_list').append(ModuleWay(data.data))
- } else {
-
- me.lock();
-
- me.noData();
- }
-
-
- setTimeout(function () {
-
-
-
- me.resetload();
- }, 1000);
-
- $('.dropload-down').hide();
- },
- error: function (xhr, type) {
-
-
- me.resetload();
- }
- });
- }
- });
- }
- fun();
- })
|