/* requestAnimationFrame鍏煎鍑芥暟 */ (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; } if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); } })(); $(function(){ // 璋冪敤 鐧惧害鍒嗕韩 // window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)]; if (window.navigator.userAgent.indexOf("MSIE")==-1) { weasel(); } mqfix(); // IE8濯掍綋鏌ヨ鏍峰紡寤惰繜鏄剧ず鐨勫鐞� htmlSize(750); // rem缂╂斁鍑芥暟璋冪敤 screenContainer(); // container婊″睆楂樺害璁剧疆 scrollPosfix('pos-fix'); // fixed瀹氫綅鍏冪礌鐨勬í鍚戞粴鍔ㄦ樉绀� scrollShow('.js-scroller','x-show',0); // 婊氬姩瀹氫綅鍏冪礌 goTop('.js-gotop'); // 杩斿洖椤堕儴 // haScroll('.js-ha'); // 鍝堝笇閿氱偣婊氬姩 // sideBarPos('.side-bar',1250,45); // 渚ц竟鏍忓畾浣嶈皟鐢� $('input, textarea').placeholder(); // 璋冪敤placeholder鎻掍欢 $('.other-site .left .ul').mCustomScrollbar(); if(!device().isMobile){ getSubnavPos(); $(window).on('resize', getSubnavPos); } function getSubnavPos(){ if($('.x-header').hasClass('special')) return; $('.nav-lv1 > .nav-item').each(function(){ var $this = $(this); var wwidth = $('.nav-mod').width(); var twidth = $this.width(); var posl = $this.offset().left; var width = 0; if((twidth / 2 + posl) > (wwidth / 2)){ width = (wwidth - (twidth / 2 + posl)) * 2; }else{ width = (twidth / 2 + posl) * 2; } if (!$.support.leadingWhitespace){ if(width >= wwidth){ return setTimeout(getSubnavPos, 200); } } $this.find('.nav-grp').css({'width': width + 'px', 'margin-left': (twidth / 2 + posl) - (width / 2) + 'px'}); }); } // 绉诲姩绔� 鐐瑰嚮 鑿滃崟鎸夐挳 灞曞紑/鏀惰捣 瀵艰埅灞� $('.x-header .menu-btn').on('click',function(){ var hd = $('.x-header'); if(!hd.hasClass('menu-open')){ hd.addClass('menu-open'); if($('.x-header').css('position') === 'fixed'){ unWinScroll(); }else{ $('body, html').animate({scrollTop: 0}, 100, function(){ unWinScroll(); }); } }else{ hd.removeClass('menu-open'); enWinScroll(); } }); // 绉诲姩绔� 鐐瑰嚮 瀵艰埅閾炬帴 鏀惰捣 寮瑰嚭瀵艰埅灞傦紙鐢ㄤ簬瑙e喅鐐瑰嚮閿氱偣瀵艰埅鍦ㄩ〉闈㈡病鍒锋柊鐨勬儏鍐典笅鏀惰捣寮瑰嚭鐨勫鑸眰锛� $('.nav-lv a[href]').on('click',function(){ $('.x-header').removeClass('menu-open'); enWinScroll(); }); // 绉诲姩绔� 鐐瑰嚮 瀵艰埅椤圭殑绠ご 灞曞紑/鏀惰捣 瀛愮骇瀵艰埅 $('.nav-mod .arr').on('click',function(){ var _this = $(this); var par = _this.closest('.nav-item'); if(!par.hasClass('act')){ par.addClass('act').siblings('.nav-item').removeClass('act').children('.nav-lv').slideUp(0); _this.parent().siblings('.nav-lv').slideDown(200); }else{ par.removeClass('act').children('.nav-lv').slideUp(200); } }); // pc绔悳绱� $('.search-trigger').on('click', function(e){ if(!$('.search-box').hasClass('x-show')){ e.stopPropagation(); $('.search-box').addClass('x-show'); } }); $('.search-box').on('click', function(e){ e.stopPropagation(); }); $(document).on('click', function(){ if($('.search-box').hasClass('x-show')){ $('.search-box').removeClass('x-show'); } }); // 鍏抽棴寮圭獥 $('.pop-close, .pop-overlay').on('click', function(e){ e.stopPropagation(); $(this).parents('.pop-mod').removeClass('x-show'); enWinScroll(); if($(this).parents('.pop-mod').find('video').length > 0){ $(this).parents('.pop-mod').find('video')[0].pause().attr("src",''); } if($(this).parents('.pop-mod').find('iframe').length > 0){ $(this).parents('.pop-mod').find('iframe').remove(); } }); // 涓嬫媺妗� $('.select-mod').each(function(){ var obj = $(this); var selectBtn = obj.find('.select-btn'); var selectTit = obj.find('.select-tit'); var selectOpts = obj.find('.select-opts'); var selectQue = obj.find('.squery-list'); var selectIpt = obj.find('.select-input'); var selectNat = obj.find('.select-native'); var val = obj.find('.select-val'); selectOpts.mCustomScrollbar({ mouseWheel:{ preventDefault: true} }); selectQue.mCustomScrollbar(); selectBtn.on('click',function(){ // if(!device().isMobile){ if(!obj.hasClass('sc-show')){ obj.addClass('sc-show'); }else{ obj.removeClass('sc-show'); } // } }); selectTit.on('click',function(){ var _this = $(this); var grp = _this.parents('.select-grp'); if(!grp.hasClass('open')){ grp.addClass('open').siblings('.select-grp').removeClass('open'); selectOpts.mCustomScrollbar("scrollTo", grp ,{ scrollInertia: 0 }); }else{ grp.removeClass('open'); } }); selectNat.on('change',function(){ var _this = $(this); obj.find('.select-item').eq(_this.get(0).selectedIndex).trigger('click'); }); obj.on('click','.select-item',function(){ var _this = $(this); var ptxt = _this.parent().siblings('.select-tit').text(); var text = !ptxt ? _this.text() : ptxt + ' - ' + _this.text(); if(!_this.hasClass('selected')){ obj.find('.select-item').removeClass('selected'); _this.addClass('selected'); obj.removeClass('sc-show'); obj.find('.squery-item').removeClass('selected'); val.text(text); selectIpt.val(text); if(selectNat[0]){ selectNat[0].selectedindex = _this.index(); } if(val.hasClass('placeholder')){ val.removeClass('placeholder'); } } }); obj.on('click','.squery-item',function(){ var _this = $(this); var text = _this.text(); if(!_this.hasClass('selected')){ _this.addClass('selected').siblings().removeClass('selected'); obj.find('.select-item').removeClass('selected'); // obj.removeClass('sq-show'); val.text(text); selectIpt.val(text); if(val.hasClass('placeholder')){ val.removeClass('placeholder'); } } }); if(is_undefined(obj.data('clickup'))){ selectOpts.data("mCS").opt.mouseWheel.preventDefault = false; obj.on('mouseenter',function(){ obj.addClass('hover'); }); obj.on('mouseleave',function(){ obj.removeClass('hover'); }); $(document).on('click',function(){ if(!obj.hasClass('hover')){ obj.removeClass('sc-show'); } }); }else{ obj.on('mouseleave',function(){ obj.removeClass('sc-show'); }); } selectIpt.on('focus',function(){ obj.addClass('sq-show'); }); selectIpt.on('blur',function(){ setTimeout(function(){ obj.removeClass('sq-show'); },300); }); selectIpt.on('click',function(e){ e.stopPropagation(); }); }); // tab鍒囨崲妯″潡 $('.tab-mod').each(function(i){ var _this = $(this); var _bar = _this.find('.tab-bar'); var _term = _bar.find('.tab-term'); var _cont = _this.find('.tab-cont'); var _item = _cont.find('.tab-item'); var event = $(this).data("event"); var ww = $(window).width(); if(event != undefined){ event = ww >= 750 ? event : 'click'; }else{ event = 'click' } if(_bar.find('.cur').length<1){ _term.eq(0).addClass('cur'); } var _cur = _bar.find('.cur'); _item.eq(_cur.index()).addClass('act'); _term.on(event,function(){ var $this = $(this); if(!$this.hasClass('cur')){ $this.addClass('cur').siblings('.tab-term').removeClass('cur'); _item.eq($this.index()).addClass('act').siblings('.tab-item').removeClass('act'); } }); }); /// }); /* Function */ function weasel(){ var obj = $('.x-footer'); var slot = obj.find('.slot'); var track = slot.find('.slot-track'); var item = slot.find('.slot-item'); var width = obj.width(); var length = track.length; var limit = width / length * 5; var timer = null, times = 0, clientX = 0; obj.on('mousemove.move', moveFn); obj.on('mousemove.out', $.debounce(5000, outFn)); function moveFn(ev){ clientX = ev.clientX; cancelAnimationFrame(timer); timer = requestAnimationFrame(animation); times = new Date().valueOf(); } function outFn(){ cancelAnimationFrame(timer); item.removeAttr('style'); } function animation(){ var animationTime = new Date().valueOf(); track.each(function(idx, el){ var _this = $(this); var _item = _this.find('.slot-item'); var middle = offsetL(_this) + _this.width() / 2; var distance = Math.abs(clientX - middle); if(distance > limit) distance = limit; var scale = Math.abs(distance/limit) * 50; var top = _item.position().top; var n = top / slot.height() * 100; var t = (scale - n)/2; n += t; TweenMax.set(_item, {y: n+'%', top: 0}); }); if(animationTime - times < 1000){ timer = requestAnimationFrame(animation); } } function offsetL(obj){ var left = 0; var ol = obj.offset().left; while(obj){ left += ol; obj = null; } return left; } } /* IE8濯掍綋鏌ヨ鏍峰紡寤惰繜鏄剧ず鐨勫鐞� */ function mqfix(){ /*var load = $('
'); $('body').append(load[0]); $(window).on('load',function(){ if ($.support.leadingWhitespace){ load.fadeOut(100, function(){ load.remove(); }); }else{ setTimeout(function(){ load.fadeOut(100, function(){ load.remove(); }); }, 600); } });*/ } /* 杩斿洖椤堕儴 */ function goTop(cls){ // cls-[瀛楃涓瞉 绫诲悕 $(cls).on('click', function(){ $('body, html').stop().animate({scrollTop: 0}, 400 + $(window).scrollTop() * 0.3); }); } /* 鍝堝笇閿氱偣婊氬姩 */ function haScroll(cls){ // cls-[瀛楃涓瞉 绫诲悕锛屼睛娴嬩綔涓洪敋鐐圭殑 A 鍏冪礌鍜� 闈� A 鍏冪礌 cls 鐨勭偣鍑讳簨浠惰Е鍙戦敋鐐硅烦杞紙鐩爣涓� A 鍏冪礌鐨� href 鎴� 闈� A 鍏冪礌 cls 鐨� data-x-href锛夛紝鐩爣鐨� data-x-offset 涓哄亸绉婚噺锛岃礋鍊煎悜涓婂亸绉伙紝姝e€煎悜涓嬪亸绉� var lAnchors = location.hash; var lOffset; $(window).on('load', function(){ if($(lAnchors).length){ lOffset = $(lAnchors).data('x-offset') || 0; $('body, html').stop().animate({scrollTop: $(lAnchors).offset().top - lOffset}, 1); } }); $('a[href^="#"], ' + cls).on('click', function(e){ var cAnchors = $(this).attr('href') || $(this).data('x-href'); if(/#$/.test(cAnchors)) return; var cOffset = $(cAnchors).data('x-offset'); var cOffset = $(cAnchors).data('x-offset') || 0; var target = e.target; if(typeof cOffset === 'string'){ cOffset = $(cOffset).height(); }else if(typeof cOffset === 'number'){ cOffset = cOffset; }else{ cOffset = 0; } if($(cAnchors).length && (target == this ? true : !(/(INPUT|TEXTAREA|BUTTON|SELECT|A)/i).test(target.tagName))){ e.preventDefault(); $('body, html').stop().animate({scrollTop: $(cAnchors).offset().top - cOffset}, 400); } }); } /* rem缂╂斁鍑芥暟 */ function htmlSize(px){ // px-[鏁存暟] 璁捐灏哄 // if(device().isMobile){ foo(); function foo(){ var ww = $(window).width() < 320 ? 320 : $(window).width(); if(ww > px){ $('html').css({'font-size' : '14px'}); }else{ $('html').css({'font-size' : (ww/px)*100 + 'px'}); } } $(window).on('resize', foo); // } } /* 鐧惧害鍦板浘 */ function loadMap(){ var script = document.createElement("script"); script.src = "http://api.map.baidu.com/api?v=3.0&ak=3c3f2a3587ab7a1d7ac9f2b326d66ec8&callback=createMap"; document.body.appendChild(script); } function createMap(){ var bdmap = $('#bdmap'), map = new BMap.Map(bdmap[0]), jData = []; map.centerAndZoom(new BMap.Point(116.404, 39.915), 18); bdmap.data('bdmap', map); // addMapControl(); // 鍚戝湴鍥炬坊鍔犳帶浠� // setMapEvent(); // 璁剧疆鍦板浘浜嬩欢 // setMapStyle(); // 璁剧疆鍦板浘椋庢牸 http://lbsyun.baidu.com/custom/list.htm dataFun(); // 璋冪敤鏌ヨ鍑芥暟 function addMapControl(){ map.addControl(new BMap.NavigationControl()); // 骞崇Щ缂╂斁鎺т欢 } function setMapEvent(){ map.disableDragging(); // 绂佺敤鍦板浘鎷栨嫿(榛樿寮€鍚�) map.enableScrollWheelZoom(); // 寮€鍚粴杞缉鏀�(榛樿绂佺敤) } function setMapStyle(){ map.setMapStyle({style:'midnight'}); // normal銆乨ark銆乵idnight銆乬rayscale銆乭ardedge } function dataFun(){ var dList = bdmap.data('list'), dSelected = (bdmap.data('selected') == undefined || bdmap.data('selected') < 0) ? -1 : bdmap.data('selected'), dInfo = bdmap.data('info'), dShowinfo = bdmap.data('showinfo'), dPoint = bdmap.data('point'), dSearch = bdmap.data('search'); var $list = $('.' + dList), $infos = $('.' + $list.data('infos')), $syncs = $('.' + $list.data('syncs')); jData.push({ par: bdmap, cld: bdmap, idx: 0, info: $('.' + dInfo), point: dPoint, search: dSearch, onoff: true }); if(dList){ $list.children().each(function(idx, ele){ jData.push({ par: $list, cld: $(ele), idx: idx, info: $infos.children().eq(idx), point: $(ele).data('point'), search: $(ele).data('search'), onoff: true }); }); if(dSelected >= 0){ $list.children().removeClass('cur').eq(dSelected).addClass('cur'); $syncs.children().removeClass('act').eq(dSelected).addClass('act'); } foo(dSelected+1); $list.children().on('click', function(){ var _this = $(this); var _idx = _this.index(); if(!_this.hasClass('cur')){ $list.children().removeClass('cur').eq(_idx).addClass('cur'); $syncs.children().removeClass('act').eq(_idx).addClass('act'); foo(_idx+1); } }); }else{ foo(0); } function foo(idx){ var _idx = idx; if(jData[_idx].point){ if(jData[_idx].info.length > 0){ addMapOverlay(jData[_idx]); }else{ console.warn('鎸囧畾鍧愭爣妯″紡涓嬪繀椤诲悓鏃舵寚瀹氫俊鎭 (data-info)'); return; } }else if(jData[_idx].search){ serchMap(jData[_idx]); }else{ console.warn('鍧愭爣鐐� 鎴� 鏌ヨ瀛楃涓� (data-point / data-search) 鍧囨湭鎸囧畾'); } } function serchMap(data){ var _data = data; var local = new BMap.LocalSearch(map); if(_data.info.length > 0){ local = new BMap.LocalSearch(map); }else{ local = new BMap.LocalSearch(map, { renderOptions:{ map: map } }); local.setPageCapacity(1); } local.search(_data.search, {forceLocal: false}); if(_data.info.length < 1) return; local.setSearchCompleteCallback(function(ldata){ if(local.getStatus() == BMAP_STATUS_SUCCESS){ if(ldata.getPoi(0) && !_data.point){ _data.point = [ldata.getPoi(0).point.lng, ldata.getPoi(0).point.lat]; addMapOverlay(_data); } } }); } function addMapOverlay(data){ // var myIcon = new BMap.Icon("http://lbsyun.baidu.com/jsdemo/img/fox.gif", new BMap.Size(300,157)); // 鑷畾涔夋爣娉ㄥ浘鏍� // var marker = new BMap.Marker(pt,{icon:myIcon}); // 鏍囨敞鐐� var _data = data; var point = new BMap.Point(_data.point[0], _data.point[1]); var marker = new BMap.Marker(point); var $ele = _data.info.length > 1 ? $('.' + _data.info) : _data.info; var ifcont, opts, infoWindow; if($ele.length > 0){ ifcont = $ele.html(); opts = { width : $ele.width() }; infoWindow = new BMap.InfoWindow(ifcont, opts); marker.addEventListener("click", function(e){ this.openInfoWindow(infoWindow); }); } if(_data.onoff){ _data.onoff = false; map.addOverlay(marker); marker.setAnimation(BMAP_ANIMATION_BOUNCE); // 璺冲姩鐨勫姩鐢� _data.marker = marker; } map.panTo(point); if(_data.par != _data.cld || bdmap.data('showinfo')){ setTimeout(function(){ _data.marker.openInfoWindow(infoWindow); }, 300); } } } } /* 闅忔満姝h礋1 */ function ranPlus(){ var ran = Math.random(); return Math.random()>0.5?1:-1 } /* 鑾峰彇婊氬姩鏉″搴� */ function getScrollBarWidth(){ var rw = 0, wh = 0, bh = 0; wh = $(window).height(); bh = $('body').height(); if(bh > wh){ if(!$('body').data('scrollBarWidth')){ $('body').append(' '); rw = 100-$('.fnScrollBarInner').width(); $('body').data('scrollBarWidth', rw); $('.fnScrollBarWrap').remove(); }else{ rw = $('body').data('scrollBarWidth'); } } return rw; } /* 绂佹绐楀彛婊氬姩 */ function unWinScroll(){ var top = $(window).scrollTop(); $('body').css({'position':'fixed','top':-top + 'px','left':'0px','right':getScrollBarWidth() + 'px'}).data('winScroll',top); } /* 閲婃斁绐楀彛婊氬姩 */ function enWinScroll(){ if(!$('body').data('ostyle')){ $('body').removeAttr('style'); }else{ $('body').attr('style', $('body').data('ostyle')); } $(window).scrollTop($('body').data('winScroll')); } /* 绂佹閫変腑 */ function unSelect(ele){ // ele-[瀛楃涓瞉 鎿嶄綔瀵硅薄锛岄€氬父璁句负body $(ele).attr('unselectable','on').css({ '-moz-user-select':'-moz-none', '-moz-user-select':'none', '-o-user-select':'none', '-khtml-user-select':'none', /* you could also put this in a class */ '-webkit-user-select':'none',/* and add the CSS class here instead */ '-ms-user-select':'none', 'user-select':'none' }).on('selectstart', function(){ return false; }); } /* 閲婃斁閫変腑 */ function enSelect(ele){ // ele-[瀛楃涓瞉 琚姝㈤€変腑鐨勫璞� $(ele).attr('unselectable','off').css({ '-moz-user-select':'text', '-moz-user-select':'text', '-o-user-select':'text', '-khtml-user-select':'text', /* you could also put this in a class */ '-webkit-user-select':'text',/* and add the CSS class here instead */ '-ms-user-select':'text', 'user-select':'text' }).off('selectstart'); } /* 澶氳鏂囨湰鐪佺暐鍙� */ function ellipsis(e,h){ $(e).each(function(){ var $p = $(this); while ($p.outerHeight() > h) { $p.text($p.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "...")); } }); } /* 婊氬姩tab */ function scrollTab(ele){ var scrolltab = $(ele); var scrollitem = scrolltab.find('li'); var myScroll = new IScroll(scrolltab[0], { // momentum: false, mouseWheel: true, scrollX: true, scrollY: false, click: true, tap:true }); scrolltab.on('touchmove',function(e){ e.preventDefault(); }); scrollitem.on('tap',function(){ if(!$(this).hasClass('cur')){ $(this).addClass('cur').siblings().removeClass('cur'); myScroll.scrollToElement(this, 500, true, null, IScroll.utils.ease.circular); } }); } /* 渚ц竟鏍忓畾浣� */ function sideBarPos(ele,wrap,n){ var sBar = $(ele); sBar.css('margin-left',wrap/2+n+'px'); var sWidth = sBar.width()+n; var gWidth = wrap + sWidth*2; rePos(); $(window).on('resize', rePos); function rePos(){ if(sBar.offset().left + sBar.width() < gWidth){ sBar.css({'left':'auto', 'right':0}); }else{ sBar.css({'left':'50%', 'right':'auto'}); } } } /* 妯℃嫙 background-size:contain 绠楁硶 */ function fixContain(ele,node,w,h){ } /* 妯℃嫙 background-size:cover 绠楁硶 */ function fixCover(ele,node,w,h,limit,winw,winh,pos){ // ele-鍏冪礌瀵硅薄锛堢埗绾э級,node-瀛愬厓绱犵被鍨嬶紙涓虹┖榛樿瀛愬厓绱狅級,w-鍏冪礌鍘熷瀹藉害,h-鍏冪礌鍘熷楂樺害,limit-鍏冪礌瀵硅薄鏈€灏忓搴�,winw-璁句负绐楀彛瀹藉害,winh-璁句负绐楀彛楂樺害,pos-鏄惁z缁濆瀹氫綅 var _this=$(ele); if(winw){ _this.css({'width':$(window).width(),'min-width':limit+'px'}); } if(winh){ _this.css('height',$(window).height()); } var per=w/h; var ww=_this.width(); var wh=_this.height(); var pw=wh*per; var ph=ww/per; var cld=null; if(node==''){ cld=_this.children(); }else{ cld=_this.find(node); } if(pos){ cld.css({'position':'absolute','left':'0','top':'0'}); } cld.css({'margin-top':0,'margin-left':0,'max-width':'none','max-height':'none'}); if(ww