$("#sub_category").on("click", "li", function () { var id = $(this).attr("data-id"); $(this).addClass("sub_actived").siblings().removeClass("sub_actived"); loading_data(1,true); }) function loading_data(page,empty) { var type = $(".sub_actived").attr("data-id"); $.ajax({ url: '../api/document.php', type: 'POST', dataType: 'json', data: { page: page, type: type, randomstr: Math.random() }, }).done(function(data) { //分页数据 $("#page_info").find("li").remove(); //先清空历史元素 creat_page_btn(data.page_info, data.page, data.last_page, "page", "page_info"); //列表 if (empty) { $("#rows_all").empty(); //先清空历史元素 } $("#hd_page").val(data.page); var json_list = data.list; if (data.page == data.last_page) { $(".mobile_more_info").hide(); } else { if ($(document).width() <= 750) { $(".mobile_more_info").show(); } } if (json_list) { $.each(json_list, function (n, value) { var tp_list = hdy_template($('#rows_all'), 'tp_list', 'tp_list-' + value.id); if (value.category == "视频" || value.category == "产品视频") { tp_list.find('.icon').show(); this_type = "v"; if (value.openLevel == "1") { tp_list.find(".vip_tips").show(); } tp_list.find('.tp_link').attr({ "href": "video.php?id=" + value.id, "data-login": value.openLevel }); } else { tp_list.find('.icon').hide(); this_type = "d"; tp_list.find('.tp_link').attr({ "href": data.img_path + value.file, "target": "_blank" }); } tp_list.find('.tp_link').attr({ "data-type": this_type }); tp_list.find('.tp_cover').attr({ "src": data.img_path + value.cover, }); if (type == "2") { tp_list.find('.tp_cover').addClass("small_cover"); } tp_list.find('.tp_title').text(value.title); }); } }).fail(function() { show_alert("后端逻辑错误",""); }) }; $("#page").on("click","li",function () { var page = $(this).attr("data-page"); loading_data(page, true); }) $("#rows_all").on("click", "a", function (e) { var type = $(this).attr("data-type"); var needlogin = $(this).attr("data-login"); if (type == "v" && needlogin=="1"){ e.preventDefault(); show_login(); } }) $(".mobile_more_info").click(function () { var page = Math.ceil($("#hd_page").val()); loading_data(page+1,false) }) loading_data(1,true);