$(function () { var iWith = document.body.clientWidth;//window.screen.availWidth;//document.body.clientWidth; var curUrl = document.location.href; console.log(iWith); //if (iWith > 1080) if (IsPcOpen()) { var oriStr = 'wap.sdpress.com.cn'; if (curUrl.indexOf(oriStr) > -1) { document.location.href = curUrl.replace(oriStr, 'www.sdpress.com.cn'); } } else { var oriStr = 'www.sdpress.com.cn'; if (curUrl.indexOf(oriStr) > -1) { document.location.href = curUrl.replace(oriStr, 'wap.sdpress.com.cn'); } } }); //判断是否是PC设备,true是,false不是 function IsPcOpen() { let userAgentInfo = navigator.userAgent; let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPod', 'iPad', 'micromessenger']; let flag = true; for (let i = 0; i < Agents.length; i++) { if (userAgentInfo.indexOf(Agents[i]) > -1) { flag = false; break; } } if (window.screen.width >= 1100) { flag = true; } return flag; } var headerjs = { showflower: function () { var wwidth = $(window).width(); if (wwidth >= 1500) { $("#headerbox .flower").show(); } else { $("#headerbox .flower").hide(); } }, addNav: function () { $("#header-nav .nav").each(function () { var nav = $(this).attr("nav"); var txt = ""; $(this).html(txt); var now = $(this).attr("now"); if (now == 1) { $(this).children(".nav-nei").css({ top: "0" }); } }); }, searchContent: "请输入搜索关键词", searchShow: function (i) { switch (i) { case 1: var val = $("#header-search .search").val(); if (val == "") { //$("#header-search .search").val(this.searchContent); } break; case 2: $("#header-search .search").val(""); break; case 3: if (val == "") { $("#header-search .search").val(this.searchContent); } break; } }, toUrl: function (nav) { var url = $(nav).attr("url"); var newwin = $(nav).attr("newwin"); if (newwin == 0) { window.location.href = url; } else { window.open(url); } }, doSearch: function () { var moduleId = ""; var newsType = ""; var title = $("#header-search .search").val(); if (title.length < 1) { alert(this.searchContent); return; } getQeuryUrl("NewsSearchUrl", moduleId + "$" + newsType + "$" + "0" + "$" + title); } }; $(window).resize(function () { headerjs.showflower(); }); $(document).ready(function () { headerjs.showflower(); headerjs.addNav(); headerjs.searchShow(3); $("#header-nav .nav").mouseover(function () { var now = $(this).attr("now"); if (now == 0) { $(this).children(".nav-nei").animate({ top: "0" }, 200); } }).mouseout(function () { var now = $(this).attr("now"); if (now == 0) { $(this).children(".nav-nei").animate({ top: "-108px" }, 100); } }); $("#header-nav .nav").click(function () { headerjs.toUrl(this); }); $("#header-search .search").keyup(function (e) { if (e.keyCode == 13) { headerjs.doSearch(); } else { headerjs.searchShow(1); }; }).click(function () { headerjs.searchShow(2) }); $("#header-search .search").mouseover(function () { var val = $("#header-search .search").val(); if (val == headerjs.searchContent) { $("#header-search .search").val(""); } $("#header-search .search").focus().select(); }).blur(function () { var val = $("#header-search .search").val(); val = val.replace(/(^\s*)|(\s*$)/g, ""); if (val == "") { $("#header-search .search").val(headerjs.searchContent); } }).keyup(function (e) { if (e.keyCode == 13) { headerjs.doSearch(); } }); //$(window).resize(function () { // document.location.href=document.location.href; //}); //顶部滚动banner $('#top-banner').bxSlider({ adaptiveHeight: false, startSlides: 0, auto: true, pause: 6000, captions: true }); //$('#service-banner').bxSlider({ // //auto: true, // //pause: 3000, // //mode: 'fade', // // preloadImages: all, // slideWidth: 260, // minSlides: 2, // maxSlides: 4, // moveSlides: 1, // slideMargin: 10, // captions: true, // tickerHover: true //}); $(".bxslider li").hover(function () { $(this).find(".bx-caption").show(); }, function () { $(this).find(".bx-caption").hide(); }); $("#service-banner .bx-caption").hide(); $("#header-search .searchbox .s3").click(function () { headerjs.doSearch(); }); }); function ToSearchGoodsPage() { var moduleId = $("#book-search .modules").val(); var goodsType = ""; var pinpai = $("#book-search .pinpai").val(); var goodsName = $("#book-search .searchtext").val(); getQeuryUrl("GoodsSearchUrl", moduleId + "$" + goodsType + "$" + pinpai + "$" + "$" + goodsName); } function toSearchPinPaiData(pinpai) { getQeuryUrl("GoodsSearchUrl", "" + "$" + "" + "$" + pinpai + "$" + "$" + ""); } function getQeuryUrl(aciton, queryinfo) { //获取下一页数据 $(".btnSearch").removeClass("show").addClass("hidden"); $.ajax({ type: "post", //此时,所有data数据,都默认加到url里 dataType: "html", data: "Query=" + queryinfo, url: "/Controls/Tools/Search.ashx?action=" + aciton + "¶m=" + new Date().getTime(), success: function (d) { var result = $(d).find(".result").text(); switch (result) { case '-1': alert($(d).find(".returnval").text()); break; case '1': document.location.href = $(d).find(".returnval").text(); break; default: //alert($(d).find(".returnval").text()); break; } $(".btnSearch").removeClass("hidden").addClass("show"); }, error: function (XMLHttpRequest, textStatus, errorThrown) { $(".btnSearch").removeClass("hidden").addClass("show"); if (errorThrown) { alert(textStatus + ":" + errorThrown); } } }); }