var whir = window.whir || {}; $(".bann").owlCarousel({ loop:true, items:1, nav:true, autoplay:true, slideSpeed:2000 }); whir.global = { getNewObj: function (oldObj, newObj) { var ops = oldObj; if (oldObj != undefined) { ops = $.extend(oldObj, newObj); } return ops; }, //窗口变化刷新页面 initSetsize: function(){ window.onresize = function(){ //location=location } }, //导航 initnav: function () { function stopDefault(e) { //阻止默认浏览器动作(W3C) if ( e && e.preventDefault ) e.preventDefault(); //IE中阻止函数器默认动作的方式 else window.event.returnValue = false; return false; } var header = $(".header"), header_H = header.outerHeight(true); //设置导航按钮上下居中 if(dw <= 1024){ var navBtn = $(".header .nav-btn"); var navBtn_H = navBtn.height(); navBtn.css("padding-top",($(".header .logo").height() - navBtn_H)/2); } //导航关闭/展开 var navBtn = $(".nav-btn"); var body = $("body"); var nav = $(".mainnav"); var navUl = nav.find(".ul"); navBtn.click(function(event){ event.stopPropagation(); if(!body.hasClass("menu-open")){ body.addClass("menu-open"); return false; } else{ body.removeClass("menu-open"); return false; } }); //点击空白处回收导航 $(document).click(function (event) { body.removeClass("menu-open"); }); navUl.click(function (event) { event.stopPropagation(); }); $(window).scroll(function(){ //往下滚动回收导航 body.removeClass("menu-open"); //设置顶部固定 var scrollValue=$(window).scrollTop(); $(".h-header").show().height(header_H); scrollValue > 0 ? setclass() : removeset(); }); function setclass(){ header.addClass("header-fixed") } function removeset(){ header.removeClass("header-fixed"); $(".h-header").hide(); } //导航 $(".mainnav li").each(function(){ //选中 // var a = $(this).find("a"), // a_W = a.find("em").width(), // a_H = a.find("em").height(); // a.css({"width":a_W,"height":a_H}); var id = $(this).attr("data-id"); if(id == "nav" + navID){ $(this).addClass("on"); } }) //首页点击导航滚动 if(navID == 1){ window.onload = function(){ $(".mainnav li").not(".nav4,.nav5").each(function(){ var urlID = $(this).attr("data-url"); var offset = $("#" + urlID).offset(); //获取页面高度 //console.log("id:" + urlID + "|||" + offset.top) $(this).click(function(e){ stopDefault(e); $("html,body").animate({scrollTop:offset.top - header_H},500); $(this).addClass("on"); $(this).siblings().removeClass("on"); }); }); $(window).scroll(function() { var top = $(window).scrollTop(); $(".homepages .homepage").each(function(){ var itemsTop = $(this).offset().top; var id = $(this).attr("id"); if(top >= itemsTop - header_H){ $(".mainnav li[data-url='" + id + "']").addClass("on").siblings().removeClass("on"); }else{ return false; } }); }); } } }, //底部 initBottom: function(){ //设置高度 if(dw >= 1024){ // $(".footer1 .contact,.footer1 .codeimg-list,.footer1 .btlink-list .ul").height($(".footer1 .container").height() - 40); } }, //首页 initHome: function(){ //banner $(".homeban").owlCarousel({ loop:true, items:1, nav:true, autoplay:true }); //news $(".homepage3 .imgbox1 .itemcont").owlCarousel({ loop:true, items:1, nav:true, autoplay:true }); //case $(".homepage2 .boxlist .box").each(function(n){ if(dw >= 1024){ $div = null; $(".li-item",this).each(function(i){ if ( i % 6 == 0) { $div = $( '
' ); $div.appendTo($(".homepage2 .boxlist .box").eq(n)); } $(this).appendTo($div); }); } }); var owl = $(".homepage2 .boxlist .box"); owl.owlCarousel({ loop:true, dots:true, nav:false, autoplay:true, autoHeight:true, onInitialized:owlload, responsive:{ 0:{ items:1 }, 640:{ items:2, margin:15 }, 1024:{ items:1 } } }); function owlload(){ //$(".homepage2 .boxlist .box").eq(0).show().siblings().hide(); $(".homepage2 .tablist a").eq(0).addClass("active"); $(".homepage2 .boxlist .box").each(function(i){ if(dw >= 1024){ $(this).find(".owl-item").each(function(){ $(this).find(".li-item:nth-child(3n+1)").addClass("li-first"); $(this).find(".li-item:nth-child(3n+2)").addClass("li-mi"); $(this).find(".li-item:nth-child(3n+3)").addClass("li-last"); }); } // $(".homepage2 .boxlist").find('.box'+($(this).index()+ 1)).append("查看更多"); // alert($(this).index()+ 1); }); $(".homepage2 .tablist a").each(function(i){ $(this).click(function(){ $(this).addClass("active").siblings().removeClass("active"); $(".homepage2 .boxlist .boxshow").eq(i).show().siblings().hide(); }); }); $(".homepage2 .boxlist .boxshow").eq(0).show().siblings().hide(); } //about $(".homepage1 .boxlist .box .btnbox a").click(function(){ $(this) .toggleClass("active") .parents(".box").find(".hidebox").slideToggle("slow"); }); $(".homepage1 .tablist li").eq(0).addClass("active"); $(".homepage1 .tablist li").each(function(i){ $(this).click(function(){ $(this).addClass("active").siblings().removeClass("active"); $(".homepage1 .boxlist .box").hide() .eq(i).show(); if(i == 4){ $(".homepage1 .boxlist .box5").owlCarousel({ loop:true, items:1, nav:true, dots:false, autoplay:true }); } }) }); }, //首页百度地图 initMap: function (Point) { //创建和初始化地图函数: function initMap(){ createMap(Point);//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 addMapOverlay();//向地图添加覆盖物 } function createMap(Point) { Point = Point.replace(" ", ""); map = new BMap.Map("map"); if (Point!=undefined &Point.indexOf(",") > 0) { var list = Point.split(','); map.centerAndZoom(new BMap.Point(list[0]-0, list[1]-0), 18); } else { map.centerAndZoom(new BMap.Point(113.996189, 22.702624), 18); } } function setMapEvent(){ map.enableKeyboard(); map.enableDragging(); map.enableDoubleClickZoom() } function addClickHandler(target,window){ target.addEventListener("click",function(){ target.openInfoWindow(window); }); } function addMapOverlay(){ var markers = [ {content:"
深圳陈列共和设计有限公司
400 - 8602 - 302
",title:"深圳陈列共和设计有限公司",imageOffset: {width:-46,height:-21},position:{lat:22.702624,lng:113.996189}} ]; for(var index = 0; index < markers.length; index++ ){ var point = new BMap.Point(markers[index].position.lng,markers[index].position.lat); var marker = new BMap.Marker(point,{icon:new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png",new BMap.Size(20,25),{ imageOffset: new BMap.Size(markers[index].imageOffset.width,markers[index].imageOffset.height) })}); var label = new BMap.Label(markers[index].title,{offset: new BMap.Size(25,5)}); var opts = { width: 200, title: markers[index].title, enableMessage: false }; var infoWindow = new BMap.InfoWindow(markers[index].content,opts); marker.setLabel(label); addClickHandler(marker,infoWindow); map.addOverlay(marker); }; } //向地图添加控件 function addMapControl(){ var scaleControl = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}); scaleControl.setUnit(BMAP_UNIT_IMPERIAL); map.addControl(scaleControl); var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:3}); map.addControl(navControl); } var map; initMap(); }, //视频 initVideo: function(){ if(dw >= 1024){ $(".video li").each(function(){ $(".item",this).click(function(){ }); }); } } } $(document).ready(function(){ $(".homepage2 .boxlist .box").each(function(){ var href=$(".homepage2 .boxlist").find('.box'+($(this).index()+ 1)).find(".li-item ").eq(0).find("figure a").attr("scr") $(".homepage2 .boxlist").find('.box'+($(this).index()+ 1)).append("Read More"); }) })