// JavaScript Document $(function(){ /*------top部分搜索框部分start-----*/ $(".search_mt_lnk").click(function(e) { $(".search_mt_st").toggleClass("search_mt_dis"); }); $(".search_mt_st span").click(function(e) { $(".search_mt_st span").removeClass("search_mt_dis"); $(this).addClass("search_mt_dis"); $(".search_mt_st").addClass("search_mt_dis"); $(".search_mt_lnk span").text($(this).text()); $("#TopClassType").val($(".search_mt_lnk span").text()); }); $(".search_btn").mouseover(function(){ $(".base_Search,.search_mt").css("border-color","#ff5370"); }); $(".search_btn").mouseout(function(){ $(".base_Search,.search_mt").css("border-color","#07a3ea"); }); /*------top部分搜索框部分end-----*/ /*------nav部分start------*/ $(".nav>ul>li").mouseenter(function(){ $(this).children(".nav_disease").fadeIn(300); }) $(".nav>ul>li").mouseleave(function(){ $(this).children(".nav_disease").fadeOut(300); }) /*------nav部分end------*/ /*--------labour部分点击显示/隐藏start-------*/ $(".facility_click").click(function(){ //$(".facility ul").slideToggle(); //$(".facility_click").toggleClass("lobour_on"); $(this).siblings($(".facility ul")).slideToggle(); $(this).toggleClass("lobour_on"); }); /*------labour部分点击显示/隐藏start-----*/ /*---main_mid部分banner切换start------*/ var time=setInterval(banner,5000); var i=0; function marginLeftBan(){ $(".main_mid_banner").css("margin-left",-(i*$(".main_mid_banner>a").width())+"px"); } $(".main_mid ul li").each(function(index, element) { $(this).mouseenter(function(){ $(".main_mid ul li").removeClass("main_mid_on"); $(this).addClass("main_mid_on"); //$(".main_mid_banner>a").eq(index); i=index; marginLeftBan(); }) }) function banner(){ i++; if(i>$(".main_mid_banner>a").length-1){ i=0; } marginLeftBan(); for(var j=0;j<=$(".main_mid_banner>a").length;j++){ $(".main_mid ul li").removeClass("main_mid_on"); } $(".main_mid ul li").eq(i).addClass("main_mid_on"); } $(".main_mid_banner").mouseover(function(x){ clearInterval(time); //x=i; }); $(".main_mid_banner").mouseout(function(y){ time=setInterval(banner,5000); // y=i; }) if($(".banners a").length==1){ clearInterval(time); $(".banner ul").remove(); } /*------main_mid部分banner切换end----*/ /*----doctor部分点击切换start-----*/ $(".main_doctor .doctors_lit").width($(".physician").length*($(".physician").width()+10)+"px"); var n=0; function LeftLit(){ $(".doctors_lit").css("left",-220*n+"px"); } $(".doctor").each(function(index, element) { $(".doctor_prev").click(function(e) { n--; if(n<=0){ n=0; } LeftLit(); }); $(".doctor_next").click(function(e) { n++; if(n>=$(".doctors_lit ul li").length-5){ n=$(".doctors_lit ul li").length-5; } LeftLit(); }); }); /*-----doctor部分点击切换end-----*/ /*-----safe部分选项卡切换start------*/ /*$(".safe").each(function(index, element) { $(".safe .demo_Three_left,.safe .demo_Three_right").mouseenter(function(){ $(".safe .demo_Three_left").toggleClass("gray"); $(".safe .demo_Three_right").toggleClass("blue"); $(".safe_mid_One").toggle(); $(".safe_mid_Two").toggle(); }); });*/ $(".safe").each(function(index, element) { $(".safe .demo_Three_left").mouseenter(function(){ $(".safe .demo_Three_left").addClass("blue"); $(".safe .demo_Three_right").removeClass("blue"); $(".safe_mid_One").css("display","block"); $(".safe_mid_Two").css("display","none"); }); $(".safe .demo_Three_right").mouseenter(function(){ $(".safe .demo_Three_left").removeClass("blue"); $(".safe .demo_Three_right").addClass("blue"); $(".safe_mid_One").css("display","none"); $(".safe_mid_Two").css("display","block"); }); $(".safe .demo_Three_top>a").click(function(e) { if($(".safe .demo_Three_left").hasClass("blue")==true){ location.href="http://www.zybw.com/org.aspx"; }else{ location.href="http://www.zybw.com/Hygiene.aspx"; } }); }); /*-----safe部分选项卡切换end------*/ /*-----company部分选项卡切换start------*/ $(".company").each(function(index, element) { $(".company .demo_Three_left").mouseenter(function(){ $(".company .demo_Three_left").addClass("blue"); $(".company .demo_Three_right").removeClass("blue"); $(".company_mid_One").css("display","block"); $(".company_mid_Two").css("display","none"); }); $(".company .demo_Three_right").mouseenter(function(){ $(".company .demo_Three_left").removeClass("blue"); $(".company .demo_Three_right").addClass("blue"); $(".company_mid_One").css("display","none"); $(".company_mid_Two").css("display","block"); }); $(".company .demo_Three_top>a").click(function(e) { if($(".company .demo_Three_left").hasClass("blue")==true){ location.href="http://www.zybw.com/company.aspx"; }else{ location.href="http://www.zybw.com/company.aspx"; } }); }); /*-----company部分选项卡切换end------*/ /*-----equipment部分选项卡切换start------*/ $(".equipment").each(function(e){ function cut(){//封装切换事件 if($(".equipment_Two").is(":visible")){ $(".equipment .demo_Three_left").css("color","#07a3ea"); $(".equipment .demo_Three_right").css("color","#333"); } else{ $(".equipment .demo_Three_left").css("color","#333"); $(".equipment .demo_Three_right").css("color","#07a3ea"); } $(".equipment_One").fadeToggle(); $(".equipment_Two").fadeToggle(); } $(".equipment .demo_Three_left").mouseenter(function(e) { if($(this).css("color","#07a3ea")){ $(".equipment .demo_Three_left").css("color","#07a3ea"); $(".equipment .demo_Three_right").css("color","#333"); $(".equipment_One").fadeIn(); $(".equipment_Two").fadeOut(); } }); $(".equipment .demo_Three_right").mouseenter(function(e) { if($(this).css("color","#07a3ea")){ $(".equipment .demo_Three_left").css("color","#333"); $(".equipment .demo_Three_right").css("color","#07a3ea"); $(".equipment_One").fadeOut(); $(".equipment_Two").fadeIn(); } }); /*$(".equipment .demo_Three_left,.equipment .demo_Three_right").mouseenter(function(){//鼠标移动切换事件 cut(); })*/ $(".equipment .refresh").click(function(e){//点击切换事件 cut(); }); }); /*-----equipment部分选项卡切换end------*/ /*---------------product部分start----------------*/ $(".product .more").click(function(e) { $(this).siblings($(".product .classity ul")).toggleClass("AutoHeight"); }) /*---------------product部分end----------------*/ /*---------------测试提示start-------------*/ $(".riTop img").click(function(e) { $(".riTopTip").fadeIn(300); window.setTimeout(function(){ $(".riTopTip").fadeOut(300)},60000) }); /*---------------测试提示end-------------*/ }) /*--------------treat无缝连接滚动start----------------*/ var topNum=0; var tim=null; $(function(){ moveImg(); $("#treat_roll").mouseover(function(e) { clearTimeout(tim); }); $("#treat_roll").mouseout(function(e) { tim=setTimeout("moveImg()",30); }); }) function moveImg(){ $("#roll_box").css("top",-topNum+"px"); topNum++; topNum>330?topNum=0:""; tim=setTimeout("moveImg()",30); } /*--------------treat无缝连接滚动end----------------*/ $(document).ready(function(e) { window.setTimeout(function(){ $(".riTopTip").fadeOut(300)},20000) }) /*-----goTop定位start------*/ window.onscroll=function(){ var height=window.scrollY||document.body.scrollTop; var gotop=document.getElementById("base_GoTop"); if(height<100){ gotop.style.display="none"; console.log(height) }else{ gotop.style.display="block"; } } /*-----goTop定位end------*/ /*--------------定位图片----------------*/ function DrawCoverImg(pic, w, h) { //参数 var re_new_size = function(r) { //根据比率重新计算宽度 return { w: pic.width / r, h: pic.height / r }; }; var re_offset = function(n) { //根据新的宽高度返回偏移量 return { off_l: (n.w - w) * 0.5, off_t: (n.h - h) * 0.5 }; }; var re_position = function(o, n) { //重新定位图片 pic.style.cssText = "position:absolute;top:" + -o.off_t + "px;left:" + -o.off_l + "px;width:" + n.w + "px;height:" + n.h + "px;"; }; var execute = function(rate) { //总执行函数 var new_size = re_new_size(rate), offset_new = re_offset(new_size); re_position(offset_new, new_size); }; //判断变量 var rate_of_w = pic.width / w, rate_of_h = pic.height / h, rate; if (rate_of_w >= 1) { //图片宽度大于显示区域宽度 if (rate_of_h >= 1) { //且图片高度大于显示区域高度 rate = Math.min(rate_of_w, rate_of_h); } else { //图片高度小于显示区域 rate = pic.height / h; } } else { //图片宽度小于显示区域宽度 if (rate_of_h >= 1) { //且图片高度大于显示区域高度 rate = pic.width / w; } else { //图片高度小于显示区域高度 rate = Math.min(rate_of_w, rate_of_h); } } //执行入口 execute(rate); } //获取url地址参数 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } //获取url地址参数删除参数 function funcUrlDel(names) { if (typeof(names) == 'string') { names = [names]; } var loca = window.location; var obj = {} var arr = loca.search.substr(1).split("&"); //获取参数转换为object for (var i = 0; i < arr.length; i++) { arr[i] = arr[i].split("="); obj[arr[i][0]] = arr[i][1]; }; //删除指定参数 for (var i = 0; i < names.length; i++) { delete obj[names[i]]; } //重新拼接url var url = loca.origin + loca.pathname + "?" + JSON.stringify(obj).replace(/[\"\{\}]/g, "").replace(/\:/g, "=").replace( /\,/g, "&"); return url; } //js向url中添加参数 function addUrlPara(name, value) { var currentUrl = window.location.href.split('#')[0]; if (/\?/g.test(currentUrl)) { if (/name=[-\w]{4,25}/g.test(currentUrl)) { currentUrl = currentUrl.replace(/name=[-\w]{4,25}/g, name + "=" + value); } else { currentUrl += "&" + name + "=" + value; } } else { currentUrl += "?" + name + "=" + value; } if (window.location.href.split('#')[1]) { window.location.href = currentUrl + '#' + window.location.href.split('#')[1]; } else { window.location.href = currentUrl; } }; //js向url中修改参数paramName为参数,replaceWith为新值 function replaceParamVal(paramName, replaceWith) { var oUrl = this.location.href.toString(); var re = eval('/(' + paramName + '=)([^&]*)/gi'); var nUrl = oUrl.replace(re, paramName + '=' + replaceWith); this.location = nUrl; window.location.href = nUrl } //动态添加参数 function ParameterVal(dome, name) { $(dome).on('click', function() { var ParameterVal = $(this).index(); if (GetQueryString(name) == null) { addUrlPara(name, ParameterVal) //ProjectSub_IDS_0 } else { replaceParamVal(name, ParameterVal) } }); } //动态添加参数(根据id) function ParameterVal_ID(dome, name,replace) { $(dome).on('click', function () { var ParameterVal = $(this).children().attr("id").replace(replace,""); if (GetQueryString(name) == null) { addUrlPara(name, ParameterVal)//ProjectSub_IDS_0 } else { replaceParamVal(name, ParameterVal) } }); }