$(function () { wowint(); findtel(); phonetargetself(); nav(); search(); newsslider(); notice(); brand(); wowdelay(".index_top ul",$('.index_top ul li').length,"0.2"); wowdelay(".index_bottom ul",$('.index_bottom ul li').length,"0.2"); wowdelay(".index_innovate ul",$('.index_innovate ul li').length,"0.2"); wowdelay(".index_news ul",$('.index_news ul li').length,"0.2"); wowdelay(".home_01 ul",$('.home_01 ul li').length,"0.2"); wowdelay(".review_video ul",$('.review_video ul li').length,"0.2"); beehive(); if($(window).width()>767){ scolltext(".life_news .news_media_insert"); scolltext(".review_scoll01"); scolltext(".type_p"); scolltext(".type_div .type_edit"); } if($(window).width()>767){ scolltext(".opinion_p"); } if($(window).width()>1024){ scolltext(".brand_logo"); } $(window).resize(); $(window).scroll(function () { if ($(this).scrolltop() > 0) { $('body').addclass('scrollheader'); } else { $('body').removeclass('scrollheader'); } }); if($(window).width()>1024){ $(document).on("click",".language dt",function(e){ e.preventdefault() e.stoppropagation() $(this).siblings().stop().slidetoggle(); $('.search_btn').removeclass('on'); $('.search_box').removeclass('on'); }) $(document).click(function () { $(".language dd").stop().slideup(); $(".f_link dt").removeclass("on"); }) }else{ } $(document).on("click",".f_link dt",function(e){ e.preventdefault(); e.stoppropagation(); $(this).siblings("dd").slidetoggle(); $(this).toggleclass("on"); }) $(document).click(function () { $(".f_link dd").slideup(); }) }) function nav(){ if($(window).width()>1024){ $(".nav li").hover(function(){ $(this).find(".nav_list").stop().slidedown(); $(this).siblings().find(".nav_list").stop().slideup() },function(){ $(this).find(".nav_list").stop().slideup() }) $(document).on("click", ".nav_phone_btn", function () { $(this).parents("body").toggleclass("menu-open"); }); $(".nav_phone_btn").hover(function(){ $("body").addclass("menu-open"); },function(){ }) $(document).on("click",".nav_p p",function(e){ $(".nav_list").hide(); }) $(".nav").hover(function(){ $(".header").addclass("submenu_show"); },function(){ $(".header").removeclass("submenu_show"); }); $(".noslide").mouseover(function(){ $(".bg_hover").addclass("on") }) $(".noslide").mouseout(function(){ $(".bg_hover").removeclass("on") }) }else{ $(".nav_phone_btn").click(function(){ $(this).toggleclass("visible_nav"); $("body").toggleclass("navbody"); $(".nav>ul>li").removeclass("cur"); }) $(document).on("click",".nav_p p",function(e){ $(".nav_phone_btn").removeclass("visible_nav"); $("body").removeclass("navbody"); $(".nav>ul>li").removeclass("cur"); }) } $(".nav>ul>li>span").click(function(){ $(this).parent("li").addclass("cur"); }) $(".return_a").click(function(){ $(this).parents("li").removeclass("cur"); }) if($(window).width()<1025){ $(".header_box").on('touchmove',function(event){ event.preventdefault(); event.stoppropagation(); }) } } function search() { $(document).on("click",".search_btn",function(e){ e.preventdefault() e.stoppropagation() $(this).toggleclass('on') $(this).siblings('.search_box').toggleclass('on'); $("body").removeclass("navbody"); }) $(document).on("click",".search_box",function(e){ e.preventdefault() e.stoppropagation() }) } function wowint(){ if (!(/msie [6|7|8|9]/i.test(navigator.useragent))){ var wow = new wow({ boxclass: 'wow', animateclass: 'animated', offset: 100, mobile: false, live: true }); wow.init(); }; } function wowdelay(box,row,delaytime){ $(box).children().each(function(index){ for(var i = 0;i1024) { var condition = /^tel\:([0-9\-]+)|tel\:\+([0-9\-]+)$/; if(context==undefined){ context=$(document); } $('a',context).each(function(index, el) { var target=$(this); var href=target.attr('href'); if (condition.test(href)) { target.addclass('tel_link'); target.on('click',function(event){ event.preventdefault(); }) } }); } } /*ie9的placeholder包含密码框的兼容*/ $(function() { // 如果不支持placeholder,用jquery来完成 if(!issupportplaceholder()) { // 遍历所有input对象, 除了密码框 $('input').not("input[type='password']").each( function() { var self = $(this); var val = self.attr("placeholder"); input(self, val); } ); /**//* 对password框的特殊处理 * 1.创建一个text框 * 2.获取焦点和失去焦点的时候切换 */ $('input[type="password"]').each( function(i) { var pwdfield = $(this); var pwdval = pwdfield.attr('placeholder'); var pwdid = pwdfield.attr('id'); // 重命名该input的id为原id后跟1 pwdfield.after(''); var pwdplaceholder = $('#' + pwdid + ''+i+''); pwdplaceholder.show(); pwdfield.hide(); pwdplaceholder.focus(function(){ pwdplaceholder.hide(); pwdfield.show(); pwdfield.focus(); }); pwdfield.blur(function(){ if(pwdfield.val() == '') { pwdplaceholder.show(); pwdfield.hide(); } }); } ); } }); // 判断浏览器是否支持placeholder属性 function issupportplaceholder() { var input = document.createelement('input'); return 'placeholder' in input; } // jquery替换placeholder的处理 function input(obj, val) { var $input = obj; var val = val; $input.attr({value:val}); $input.focus(function() { if ($input.val() == val) { $(this).attr({value:""}); } }).blur(function() { if ($input.val() == "") { $(this).attr({value:val}); } }); } //end function scolltext(obj){ if($(obj).length>0){ $(obj).mcustomscrollbar({ mousewheelpixels:500, autodraggerlength:false, advanced: { autoscrollonfocus: "" } }); } } function beehive(){ // 01 settimeout(function () { $('.ecology_tab li').eq(0).click(); }, 200); $(document).on("click",".ecology_tab li",function(){ $(this).addclass("on").siblings().removeclass("on"); var url = $(this).data("src"); if(url == ""){ return false; }else{ caseajax(".pub_cont",url) } }) // 02 $(document).on("click",".pub_list li.cur",function(){ $(".pub_blank_50,.pub_tac").removeclass("cur"); $(".pub_blank_50,.pub_tac").stop().fadein(); var url = $(this).data("src"); if(url == ""){ return false; }else{ caseajax(".pub_ajax",url) } }) $(document).on("click",".pub_close,.pub_blank_50",function(){ $(".pub_blank_50,.pub_tac").fadeout(); $(".pub_ajax").html(""); }) // 03品牌 settimeout(function () { $('.brand_tab li').eq(0).click(); }, 200); $(document).on("click",".brand_tab li",function(){ $(this).addclass("on").siblings().removeclass("on"); var url = $(this).data("src"); if(url == ""){ return false; }else{ caseajax(".brand_region",url) } }) } function notice(){ $(document).on("click",".guide_tab li",function(){ $(this).addclass("on").siblings().removeclass("on"); $(".guide_iteam ul").eq($(this).index()).show().siblings().hide(); }) // 01 settimeout(function () { $('.notice_tab li').eq(0).click(); }, 200); $(document).on("click",".notice_tab li",function(){ $(this).addclass("on").siblings().removeclass("on"); var url = $(this).data("src"); if(url == ""){ return false; }else{ caseajax(".notice_table",url) } }) } function caseajax(str,url){ if (url.indexof('?') == -1) { url += '?tm=' + math.random(); } else { url += '&tm=' + math.random(); } $.ajax({ url:url, success:function(msg){ $(str).html(""); $(str).append(msg); imgratio(); if($(".pub_edit").length>0){ scolltext(".pub_edit"); } if($(window).width()>1024){ scolltext(".brand_logo>div"); } $(".pub_list li").addclass("cur"); $(".pub_list li.noalert").removeclass("cur"); } }); } function newsslider(){ if($(".review_slider li").length>1){ try{ var newsswiper = new swiper('.review_slider .swiper-container', { slidesperview: 1,//设置slider容器能够同时显示的slides数量(carousel模式) slidespergroup: 1,//在carousel mode下定义slides的数量多少为一组。 spacebetween: 0,//slide之间的距离(单位px)。 prevbutton:'.review_slider .swiper-button-prev', nextbutton:'.review_slider .swiper-button-next', speed:1000, loop:true, }) }catch(e){ //todo handle the exception } $(".s_but").show(); } } function brand(){ if($(".brand_banner li").length>1){ try{ var newsswiper = new swiper('.brand_banner .swiper-container', { slidesperview: 1,//设置slider容器能够同时显示的slides数量(carousel模式) slidespergroup: 1,//在carousel mode下定义slides的数量多少为一组。 spacebetween: 0,//slide之间的距离(单位px)。 prevbutton:'.brand_banner .swiper-button-prev', nextbutton:'.brand_banner .swiper-button-next', speed:1000, loop:true, autoplaydisableoninteraction : false, pagination: '.brand_banner .swiper-pagination', paginationclickable :true, }) }catch(e){ //todo handle the exception } $(".s_but").show(); } } $(function(){ enterfunction('.header_search .tf_search','.header_search .btn_search'); enterfunction('.news_search .tf_search','.news_search .btn_search'); enterfunction('.search_input .tf_search','.search_input .btn_search'); $('.btn_search').click(function () { var search_str = $.trim($(this).parent().find('.tf_search').val()); if(search_str === '' || search_str == '请输入关键字'){ layer.msg("请输入搜索内容!"); return; } window.location = "/news_search/searchkey/" + encodeuricomponent(search_str) + ".html"; }); function enterfunction(elementinput, elementbtn) { $(document).on('keydown',elementinput,function (e) { var curkey = e.which; if (curkey == 13) { $(elementbtn).click() } }) } });