var address = "ä¸é™"; var tp = "ä¸é™"; var tp0 = "ä¸é™"; var isAll = true; var name = null; var typeName = "资讯首页"; var pages = 0; var storage = window.sessionStorage; var contentNewsId = storage["contentNewsId"]; var addressActive = storage["addressActive"]; $(function () { UrlSearch(); var type = window.type; var flag = false; if(type!=null){ $("a[class='address']").each(function(index, result){ if($(this).html() == type){ $(this).attr("class", "address active"); flag = true; return false; } }); }else{ window.location.href="../hyxx/"; } if(!flag){ window.location.href="../hyxx/"; } getInfo(type,0); getTotal(type); $(".logo button").click(function () { var content = $("#Sou").val(); var type = $("#selectType").val(); if(content.trim().length<2){ layer.tips("请至少输入两个å—符","#Sou"); }else{ if(type=="供应"){ window.location.href="../spzs/?search="+content; }else if(type=="采è´"){ window.location.href="../syjh/qiugou.htm?search="+content; }else if(type=="ä¼ä¸š"){ window.location.href="../qyml/?search="+content; }else if(type=="资讯"){ window.location.href="../hyxx/informationSearch.html?search="+content; }else if(type=="百科"){ window.location.href="../qyfw/encyclopediaSearch.html?search="+content; } } }); $(".address").click(function(){ window.location.href="informationIndustryNews.html?type="+$(this).html(); }); /*if(storage["url"] == ""){ typeName = "资讯首页"; } else { typeName = storage["url"]; }*/ //getInfo(typeName,0); //getTotal(typeName); //classClick(); }); /** * 分类点击 */ function classClick(){ //ä¿®æ”¹åˆ†ç±»æ ‡é¢˜é¢œè‰² if(addressActive != null && addressActive != undefined && addressActive != ""){ $("a[class='address']").each(function(index, result){ if($(this).html() == addressActive){ $(this).attr("class", "address active") return; } }) } $(".address").click(function(){ typeName = $(this).html(); storage["url"] = $(this).html(); // 修改颜色 $(this).parent().siblings().children().css("color", "#333333"); $(this).css("color", "#ff774d"); $(".list_01").attr("style","display: none"); //èŽ·å–æ•°æ® getInfo(typeName,0); getTotal(typeName); }) } /** * 查询列表 * @param page */ function getInfo(typeName,page) { var data = { "typename":typeName, "page": page }; $.ajax({ url:url+"/news/hyxx/hyxxchaxunfenye", data: data, type: "get", dateType: "json", async: true, success: function success(response, status, xhr) { console.log(response); var result_0 = ""; var result_1 = ""; var result_2 = ""; $.each(response, function (i, list) { /*var content = list.content; if (content != null && content.length > 50) { content = content.slice(0, 50) + "..."; }*/ if(i < 10){ result_0 += "<div>"; result_0 += "<div class='width100 display_inline_block oneLine'><a href='shownews/"+list.newsid+".html' title='"+list.title+"' target='_blank'>"+ifPictureNull(list.picurl)+list.title+"</a></div>"; result_0 += "</div>"; } else if (i >= 10 && i < 22){ result_1 += "<div>"; result_1 += "<div class='width100 display_inline_block oneLine'><a href='shownews/"+list.newsid+".html' title='"+list.title+"' target='_blank'>"+ifPictureNull(list.picurl)+list.title+"</a></div>"; result_1 += "</div>"; } else { result_2 += "<div>"; result_2 += "<div class='width100 display_inline_block oneLine'><a href='shownews/"+list.newsid+".html' title='"+list.title+"' target='_blank'>"+ifPictureNull(list.picurl)+list.title+"</a></div>"; result_2 += "</div>"; } }); if (response.length == 0) { layer.msg('æ— ç¬¦åˆæ¡ä»¶çš„结果ï¼', { icon: 2 }); // $(".list_00").html("<div><table><tr><td>æ— ç¬¦åˆæ¡ä»¶çš„结果</td></tr></table></div>"); $(".list").attr("style","display: none"); $(".page").attr("style","display: none"); $(".list_00").attr("style","display: block"); } else { $("#response_0").empty(); $("#response_1").empty(); $("#response_2").empty(); $("#response_0").html(result_0); $("#response_1").html(result_1); $("#response_2").html(result_2); $(".list").attr("style","display: block"); $(".page").attr("style","display: block"); $(".list_00").attr("style","display: none"); } }, error: function error() { layer.msg('未知错误,请è”系客æœï¼', { icon: 5 }); } }); } /** * 获å–详细内容 */ function getContent(str){ console.log(str) if(str != ''){ $.ajax({ url:url+"/news/hyxx/getById", data: { newsid: str }, type: "get", dateType: "json", async: true, success: function success(response, status, xhr) { console.log(window.document.location.pathname); console.log(response); $(".list").attr("style","display: none"); $(".page").attr("style","display: none"); $(".list_01").attr("style","display: block"); var title = "<h1>"+response[0].title+"</h1>"; $("#content_title").html(title); $(".title_img").attr("src",response[0].picurl); $("#content_content").html(response[0].content); }, error: function error() { layer.msg('未知错误,请è”系客æœï¼', { icon: 5 }); } }); } else { layer.msg("æ— è¯¦ç»†å†…å®¹") } } /** * 判æ–图片是å¦ä¸ºç©º */ function ifPictureNull(str){ if(str == ""){ return ""; } else { return "[图]" } } function getTotal(typeName) { var data = { "typename": typeName }; $.ajax({ url:url+"/news/hyxx/hyxxchaxunfenyecount", data: data, type: "get", dateType: "json", async: true, success: function success(response, status, xhr) { console.log("/news/hyxx/hyxxchaxunfenyecount====>"+ response); pages = response - 0; /** * åŠ è½½åˆ†é¡µæ’ä»¶ */ $("#myPage").sPage({ page: 1, //当å‰é¡µç ,必填 total: pages, //æ•°æ®æ€»æ¡æ•°ï¼Œå¿…å¡« pageSize: 10, //æ¯é¡µæ˜¾ç¤ºå¤šå°‘æ¡æ•°æ®ï¼Œé»˜è®¤10æ¡ showTotal: false, //æ˜¯å¦æ˜¾ç¤ºæ€»æ¡æ•°ï¼Œé»˜è®¤å…³é—:false totalTxt: "å…±{total}æ¡", //æ•°æ®æ€»æ¡æ•°æ–‡å—æè¿°ï¼Œ{total}为å ä½ç¬¦ï¼Œé»˜è®¤"å…±{total}æ¡" noData: true, //æ²¡æœ‰æ•°æ®æ—¶æ˜¯å¦æ˜¾ç¤ºåˆ†é¡µï¼Œé»˜è®¤false䏿˜¾ç¤ºï¼Œtrue显示第一页 showSkip: true, //æ˜¯å¦æ˜¾ç¤ºè·³é¡µï¼Œé»˜è®¤å…³é—:false showPN: true, //æ˜¯å¦æ˜¾ç¤ºä¸Šä¸‹ç¿»é¡µï¼Œé»˜è®¤å¼€å¯ï¼štrue prevPage: "上一页", //ä¸Šç¿»é¡µæ–‡å—æè¿°ï¼Œé»˜è®¤â€œä¸Šä¸€é¡µâ€ nextPage: "下一页", //ä¸‹ç¿»é¡µæ–‡å—æè¿°ï¼Œé»˜è®¤â€œä¸‹ä¸€é¡µâ€ backFun: function backFun(page) { //点击分页按钮回调函数,返回当å‰é¡µç //$("#pNum").text(page); scrollTo(0, 0); if (isAll) { getInfo(typeName,((page - 1) * 10)); } else { getInfo2(page); } } }); }, error: function error() { layer.msg('未知错误,请è”系客æœï¼', { icon: 5 }); } }); } function UrlSearch(){ var str=window.location.href; //å–å¾—æ•´ä¸ªåœ°å€æ var num=str.indexOf("?"); str=str.substr(num+1); //å–å¾—æ‰€æœ‰å‚æ•° stringvar.substr(start [, length ] var arr=str.split("&"); //å„ä¸ªå‚æ•°æ”¾åˆ°æ•°ç»„里 for(var i=0;i < arr.length;i++){ num=arr[i].indexOf("="); if(num>0){ name=arr[i].substring(0,num); value=decodeURI(arr[i].substr(num+1)); this[name]=value; } } }