var common={ init: function(){ $(window).scroll(function(){ if($(this).scrollTop() > 60){ $(".back-top").show(); }else{ $(".back-top").hide(); } }); $(".back-top").on("click", function(){ $("body, html").animate({scrollTop:0},300); }); $(".garden-nav-li-tit").on("click", function(){ $(this).toggleClass("active"); $(this).siblings(".garden-nav-pull").toggle(); }); $(".garden-nav-pull-tit").on("click", function(){ $(this).siblings(".garden-nav-pull-a").toggle(); }) }, ind: function(){ $(".ind-top-li").hover(function(){ $(this).addClass("active").siblings().removeClass("active"); var imgSrc = $(this).find("img").attr("src"); $(".ind-top-news-img").find("img").attr("src",imgSrc); var imghref = $(this).find("a").attr("href"); $(".ind-top-news-img").find("a").attr("href",imghref); }); $(".ind-tit").find(".tit").on("click", function(){ var ind = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); $(this).closest(".ind-prod").find(".ind-prod-ul").eq(ind).show().siblings().hide(); }) }, news: function(){ $(".news-top-img-li").eq(0).show(); var htmlTxt = $(".news-top-li").eq(0).html(); var imgLen = $(".news-top-li").length; $(".news-top-num").find(".num").html(imgLen); $(".news-top-p").html(htmlTxt); $(".news-top-li").hover(function(){ var htmlTxt = $(this).html(); var ind = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); $(".news-top-p").html(htmlTxt); $(".news-top-num").find(".page").html(ind+1); $(".news-top-img-li").eq(ind).show().siblings().hide(); }) }, down: function(){ $(".download-nav").find("a").on("click", function(){ $(this).addClass("active").siblings().removeClass("active"); var ind = $(this).index(); $(".download-ul").eq(ind).show().siblings().hide(); }) }, council: function(){ $(".consult-btn").on("click", function(){ $(".shade, .council-form").show(); }); $(".shade").on("click", function(){ $(".shade, .council-form").hide(); }); }, paper: function(){ } } $(function(){ common.init(); $("img").each(function () { if ($(this).attr("src")=="") { $(this).attr("src", "/images/nopic.jpg"); } }); }) function downLink(linkurl) { window.location.href = linkurl; return false; } /*检测浏览器方法 ------------------------------------------------*/ var pageurl = window.location.search; if (pageurl == '?m2w') { addCookie('m2wcookie', '1', 0); } /*if (getCookie('m2wcookie') != '1' && browserRedirect()) { location.href = 'http://m.fjdfxy.com/'; }*/ /*工具类方法 ------------------------------------------------*/ //检测是否移动设备来访 function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { return true; } else { return false; } } //写Cookie function addCookie(objName, objValue, objHours) { var str = objName + "=" + escape(objValue); if (objHours > 0) {//为0时不设定过期时间,浏览器关闭时cookie自动消失 var date = new Date(); var ms = objHours * 3600 * 1000; date.setTime(date.getTime() + ms); str += "; expires=" + date.toGMTString(); } document.cookie = str; } //读Cookie function getCookie(objName) {//获取指定名称的cookie的值 var arrStr = document.cookie.split("; "); for (var i = 0; i < arrStr.length; i++) { var temp = arrStr[i].split("="); if (temp[0] == objName) return unescape(temp[1]); } return ""; }