var masterinfo = { mainiscroll:'', parallaxlist:[], pcani:[], scrolldatas:{}, loadstr:true, counterstr:true, pagenumber:1, countdown:60, windowheight:$(window).height(), //初始化 init:function(){ //wap端禁用 if(masterinfo.mobile()){ var navli = $('.nav_a'); $.each(navli, function() { if($(this).children('.mobilenav').length!=0){ $(this).children('a').attr('href','javascript:void(0)'); } }); } //鼠标 if($('.cursor').length!=0){ masterinfo.cursorfollow(); masterinfo.cursorhover('.mousefollow'); } //头部背景色 $('#initial').data('type')==2 || masterinfo.mobile()?!$('.header').is('.onbg')?$('.header').addclass('onbg'):'':''; //详情分享 if($('#newsshare').length!=0){ $('#newsshare').share({sites: ['qzone', 'qq', 'weibo','wechat']}); } //去除初始过度 $('.transition_none').removeclass('transition_none'); this.imgpreload(); //返回顶部 $("#backtop").click(function(){ if($('.header').data('name')==24){ masterinfo.contact_swiper.slideto(0, 1000, false); }else{ masterinfo.mainiscroll.scrollto(0,0,0,iscroll.utils.ease.back); masterinfo.parallaxlist.foreach(function (el) { el.el.style.transform = "translatey(0px)"; }); if($('.product_nav').length==0){ $('.header').data('name')==''?$('.header').removeclass('onwhite'):''; $('.header').addclass('onshow'); } if($('#contact_bg').length!=0){ $('#contact_bg')[0].style.transform = "translatey(0px)"; } } }); //about左右对齐 if($('.aboutbrief_datas').length!=0 && !masterinfo.mobile()){ var firstli = $('.aboutbrief_datas').children('.aboutbrief_datas_item:first-child')[0].getboundingclientrect().width, lastli = $('.aboutbrief_datas').children('.aboutbrief_datas_item:last-child')[0].getboundingclientrect().width ,firsticon = $('.aboutbrief_datas').children('.aboutbrief_datas_item:first-child').children('div')[0].getboundingclientrect().width ,lasticon = $('.aboutbrief_datas').children('.aboutbrief_datas_item:last-child').children('div')[0].getboundingclientrect().width; $('.aboutbrief_datas').css({'margin-left':'-'+(firstli/2-firsticon/2)+'px','margin-right':'-'+(lastli/2-lasticon/2)+'px'}); } //about发展历程 if($('#course_info').length!=0){ var course_info = new swiper ('#course_info', { speed:500, effect:'fade', autoheight: true, breakpoints: { 992:{ autoheight: false, }, }, fadeeffect:{ crossfade:true, }, navigation: { nextel: '.course_switch_next', prevel: '.course_switch_prev', }, thumbs: { swiper:{ speed:500, el:'#coursetap', freemode: true, slidesperview:3, watchslidesvisibility:false, //resistanceratio: 0, breakpoints: { 992:{ slidesperview:6, }, 768: { slidesperview:4, }, } }, autoscrolloffset:1, }, on:{ init: function(){ $('.coursetap_line').width($('#coursetap').find('.swiper-slide').first().width() * $('#coursetap').find('.swiper-slide').length); }, slidechangetransitionstart: function(){ $('#coursetap').find('.swiper-slide').eq(this.activeindex).nextall().removeclass('ontap'); $('#coursetap').find('.swiper-slide').eq(this.activeindex).prevall().addclass('ontap'); $('.coursetap_line>s').width($('#coursetap').find('.swiper-slide').first().width() * this.activeindex); } } }); } //用户服务>常见问题 if($(".problem_item").length!=0){ var ontime; $(document).on('click','.problem_item>a',function(){ if($(this).is('.on')){ $(this).removeclass('on').children('.problem_item_info').height(0); }else{ $(this).addclass('on').children('.problem_item_info').height($(this).children('.problem_item_info').children('div').outerheight()) .parents('.problem_item').siblings().children('a').removeclass('on').children('.problem_item_info').height(0); } if(!masterinfo.mobile()){ cleartimeout(ontime); ontime = settimeout(function(){ masterinfo.mainiscroll.refresh(); },400); } }); } //地图创建 if($('#gaodemap').length!=0){ $.getscript("https://webapi.amap.com/maps?v=1.4.15&key=dedfdb033dd70e7c4c13a2445450b733",function(){ //地图描点 var map = new amap.map("gaodemap", { zoom: 15, center: [104.171219,30.682646], resizeenable: true }); var mapspot = ''; var marker = new amap.marker({ position: [104.171219,30.682646], content: mapspot, offset: new amap.pixel(-13, -30) }); map.add(marker); }); $('.contactcity_map').hover(function(){ $('#main>.main_roll').bind('mousewheel', function(event, delta) {return false;}); },function(){ $('#main>.main_roll').unbind('mousewheel'); }); } //滚动制定位置 if($('#scrolltab').length!=0){ $(document).on('click','#scrolltab .ontab',function(){ var id = $(this).data('id'); masterinfo.mainiscroll.scrolltoelement($('#'+id).get(0),0); masterinfo.scrolldatas.scrolly = math.abs(masterinfo.mainiscroll.y); masterinfo.ani(masterinfo.scrolldatas); }); } //专题按摩头 if($('#massage_list').length!=0 && !masterinfo.mobile()){ var massage_list = new swiper ('#massage_list', { speed:350, centerinsufficientslides:true, centeredslidesbounds: true, breakpoints: { 1440:{ slidesperview:6, }, 1200:{ slidesperview:5, }, 992:{ slidesperview:4, }, } }); } //pc导航二级 if(!masterinfo.mobile()){ var hovertime; $('.nav_a').hover(function(){ var is = $(this); cleartimeout(hovertime); hovertime = settimeout(function(){ if(is.children('.pcnav').length!=0){ $('.header_mask').addclass('on'); }else{ $('.header_mask').removeclass('on'); } if($('#initial').data('type') == 1 && masterinfo.scrolldatas.scrolly < 80){ $('.header').addclass('onbg'); } is.removeclass('hovernav').find('.pcnavtap_item,.pcnavcnt_list').removeclass('on'); is.addclass('hovernav').siblings().removeclass('hovernav'); is.find('.pcnavtap_item:first-child,.pcnavcnt_list:first-child').addclass('on'); },280); },function(){ var is = $(this); cleartimeout(hovertime); hovertime = settimeout(function(){ $('.header_mask').removeclass('on'); if($('#initial').data('type') == 1 && masterinfo.scrolldatas.scrolly < 80){ $('.header').removeclass('onbg'); } is.removeclass('hovernav').find('.pcnavtap_item,.pcnavcnt_list').removeclass('on'); },280); }); $('.pcnavtap>.pcnavtap_item').hover(function(){ var is = $(this); is.addclass('on').siblings().removeclass('on'); if(is.parents('.pcnav_info').children('.pcnavcnt').length!=0){ is.parents('.pcnav_info').find('.pcnavcnt_list').eq(is.index()).addclass('on').siblings().removeclass('on'); } }); }else{ //menu $(document).on('click','#menu_btn',function(){ if($('.header').is('.mobilenavstyle')){ $('.header').removeclass('mobilenavstyle'); }else{ $('.header').addclass('mobilenavstyle'); } }); //mobile导航展开 $(document).on('click','.nav_a>a',function(){ var is = $(this); if(is.parent().children('.mobilenav').length!=0){ var pcnavht = is.parent().children('.mobilenav').children('.mobilenav_info').outerheight(); if(is.parent().is('.on')){ is.parent().removeclass('on'); is.parent().children('.mobilenav').height(0); }else{ is.parent().addclass('on').siblings().removeclass('on'); is.parent().children('.mobilenav').height(pcnavht).parent().siblings().children('.mobilenav').height(0); } } }); $(document).on('click','.mobilenav_item>a',function(){ var is = $(this); if(is.parent().children('.mobilenavcnt').length!=0){ var mobilenavht = is.parent().children('.mobilenavcnt').children('.mobilenavcnt_list').outerheight(); if(is.parent().is('.on')){ is.parent().removeclass('on'); is.parent().children('.mobilenavcnt').height(0); }else{ is.parent().addclass('on').siblings().removeclass('on'); is.parent().children('.mobilenavcnt').height(mobilenavht).parent().siblings().children('.mobilenavcnt').height(0); } var pcnavht = 0; pcnavht = 38 * is.parents('.mobilenav_info').children('.mobilenav_item').length + 30; if(is.parent().is('.on')){ is.parents('.mobilenav').height(pcnavht + mobilenavht) }else{ is.parents('.mobilenav').height(pcnavht) } } }); } //底部二维码弹出 $(document).on('click','.footercontact_follow>.follow_item>a',function(){ if($(this).parent().is('.on')){ $(this).parent().removeclass('on'); }else{ $(this).parent().addclass('on').siblings().removeclass('on'); } }); //点击空白处触发 $(document).click(function(event){ var _con = $('.footercontact_follow>.follow_item>a'); if(!_con.is(event.target) && _con.has(event.target).length === 0){ _con.parent().is('.on')?$('.footercontact_follow>.follow_item').removeclass('on'):''; } }); //产品切换 $('.product_switch>.master_tab_item').hover(function(){ var is = $(this),ontime; is.addclass('on').siblings().removeclass('on'); if(is.parents('.product_switch').siblings('.product_box').children('.product_list').length!=0){ is.parents('.product_switch').siblings('.product_box').children('.product_list').eq(is.index()).addclass('on').siblings().removeclass('on'); ontime = settimeout(function(){ masterinfo.mainiscroll.refresh(); },0); } }); //鼠标视觉差 if($('.mouselayer').length!=0 && !masterinfo.mobile()){ $(document).mousemove(function(e){ this.queryselectorall('.mouselayer').foreach(index => { const speed = index.getattribute('data-speed'); const x = (window.innerwidth - e.pagex*speed)/100; const y = (window.innerheight - e.pagey*speed)/100; tweenlite.to(index,.5,{x:x,y:y,ease:sine.easeout}); }); }); } //门店切换 $(document).on('click','#city_tab .city_tab_btn',function(){ var is = $(this),ontime; is.parent().addclass('on').siblings().removeclass('on'); $('#city_list').children('.city_list_item').eq(is.parent().index()).addclass('on').siblings().removeclass('on'); if(!masterinfo.mobile()){ cleartimeout(ontime); ontime = settimeout(function(){ masterinfo.mainiscroll.refresh(); },400); } }); //地图关闭 $(document).on('click','.storemap_close>a',function(){ $('.storemap_mask,.storemap').removeclass('on'); }); //地图打开 $.getscript("https://webapi.amap.com/maps?v=1.4.15&key=dedfdb033dd70e7c4c13a2445450b733",function(){ $(document).on('click','.city_open',function(){ var pos = $(this).data('city'),name = $(this).data('name'); if(pos == '0.0' || pos == ''){ alert('地址错误'); }else{ pos = [pos.split(',')[0],pos.split(',')[1]]; //地图描点 var map = new amap.map("storemap_city", { zoom: 15, center:pos, resizeenable: true }); var mapspot = ''; var marker = new amap.marker({ position:pos, content: mapspot, offset: new amap.pixel(-13, -30) }); map.add(marker); $('.storemap_name').text(name); $('.storemap_mask,.storemap').addclass('on'); } }); }); //视频播放 $(".videocover").click(function(){ $("#videoplay").get(0).play(); $("#videoplay").show(); $(this).hide(); }); //视频轮播 if($('#video_list').length!=0){ var video_list = new swiper ('#video_list', { speed:350, slidesperview:2, grabcursor:true, breakpoints:{ 768:{ speed:700, slidesperview:4, } }, scrollbar: { el:'.video_scrollbar', }, freemode:true, }); } }, //监听mobile mobile:function(){ var useragentinfo = navigator.useragent; var mobileagents = [ "android", "iphone", "symbianos", "windows phone", "ipad","ipod"]; var mobile_flag = false; for (var v = 0; v < mobileagents.length; v++) { if (useragentinfo.indexof(mobileagents[v]) > 0) { mobile_flag = true; break; } } var screen_width = window.screen.width; if(screen_width <= 992){ mobile_flag = true; } return mobile_flag; }, //计数器 counters:function(){ var move = $(".counters"); $.each(move, function(i,k) { var is = $(this),numbers = {score:0},istime = $(this).data('time')?$(this).data('time'):3,isnumbermax = $(this).data('numbermax'); tweenlite.to(numbers,istime,{ score:isnumbermax, onupdate:function(){ is.text(parseint(numbers.score)); }, }); }); }, //地址栏参数 geturlparms:function(name){ var reg = new regexp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r!=null) return unescape(r[2]); return null; }, ani:function(datas){ if(!masterinfo.mobile()){ if(masterinfo.pcani.length!=0){ masterinfo.pcani.foreach(function (el) { datas.scrolly > (el.offsettop - masterinfo.windowheight)+100 && el.trigger == 0?(el.el.classlist.add('animated'),el.trigger = 1):''; }); } if(masterinfo.parallaxlist.length!=0){ masterinfo.parallaxlist.foreach(function (el) { var direction = (el.offsettop - datas.scrolly) * el.el.getattribute('data-speed'); el.el.style.transform = el.el.style.webkittransform = "translatey(" + direction + "px)"; }); } if(datas.scrolly!=datas.soltop){ if(datas.scrolly >= datas.soltop){ $('.header').is('.onshow')?$('.header').removeclass('onshow'):''; }else{ if($('#initial').data('type')==1){ if(datas.scrolly >= 80){ !$('.header').is('.onbg')?$('.header').addclass('onbg'):''; }else{ $('.header').is('.onbg')?$('.header').removeclass('onbg'):''; } } !$('.header').is('.onshow')?$('.header').addclass('onshow'):''; } datas.soltop = datas.scrolly; } if($('#drift_obj').length!=0){ if(datas.scrolly + 120 >= datas.drifttop){ if((datas.scrolly + 80 - datas.drifttop)<=$('#drift_move').outerheight() - $('#drift_obj>div').outerheight()){ $('#drift_obj')[0].style.transform = $('#drift_obj')[0].style.webkittransform = "translatey(" + (datas.scrolly + 120 - datas.drifttop) + "px)"; } }else{ $('#drift_obj').removeattr('style'); } } } if($('.counters').length!=0 && masterinfo.counterstr == true){ if(datas.scrolly >= (datas.counterstop - masterinfo.windowheight)){ masterinfo.counterstr = false; masterinfo.counters(); } } }, imgpreload:function(){ var imgnum = 0,images = []; function preloadimg() { var imgs = document.images; for (var i = 0; i < imgs.length; i++) { images.push(imgs[i].src); } var cssimages = getallbgimages(); for (var j = 0; j < cssimages.length; j++) { images.push(cssimages[j]); } $.imgpreload(images,{ each:function () { // var status = $(this).data('loaded')?'success':'error'; // if (status == "success") { // var num = math.round((parsefloat(++imgnum) / images.length).tofixed(2) * 100); // $('.guide_load').children('.guide_line').width(num+'%').next('.guide_number').text(num+'%'); // } }, all:function () { masterinfo.hbanner(); masterinfo.scrolldatas.soltop = 0; $('#drift_move').length!=0?masterinfo.scrolldatas.drifttop = $('#drift_move').offset().top:''; $('.counters').length!=0?masterinfo.scrolldatas.counterstop = $('.counters').eq(0).offset().top:''; if(!masterinfo.mobile()){ $(".ani").each(function () { masterinfo.pcani.push({ trigger:0, offsettop: $(this).offset().top, el: $(this).get(0) }); }); $(".parallax").each(function () { masterinfo.parallaxlist.push({ offsettop: $(this).offset().top, el: $(this).get(0) }); }); if($('.cursor').length!=0){ masterinfo.cursorfollow(); masterinfo.cursorhover('.mousefollow'); } if($('.grid_item_img').length!=0){ array.from(document.queryselectorall('.grid_item_img')).foreach((el) => { const imgs = array.from(el.queryselectorall('img')); new hovereffect({ parent: el, intensity: el.dataset.intensity || undefined, speedin: el.dataset.speedin || undefined, speedout: el.dataset.speedout || undefined, easing: el.dataset.easing || undefined, hover: el.dataset.hover || undefined, image1: imgs[0].getattribute('src'), image2: imgs[1].getattribute('src'), displacementimage: el.dataset.displacement }); }); } masterinfo.mainiscroll = new iscroll("#main",{ mousewheel: true,scrollbars: "custom",interactivescrollbars: true,probetype:2,disablepointer: true,scrolly:true,scrollx: false, }); //初始化动画 masterinfo.scrolldatas.scrolly = math.abs(masterinfo.mainiscroll.y); masterinfo.mainiscroll.on('scroll', function () { masterinfo.scrolldatas.scrolly = math.abs(masterinfo.mainiscroll.y); masterinfo.ani(masterinfo.scrolldatas); }); //滚动指定位置 if(masterinfo.geturlparms('ql')){ if(masterinfo.geturlparms('ql')!=5){ masterinfo.geturlparms('ql')==0?(masterinfo.counterstr = false,masterinfo.counters()):''; masterinfo.mainiscroll.scrolltoelement($('#index'+masterinfo.geturlparms('ql')).get(0),0); } } if(masterinfo.geturlparms('qr')){ masterinfo.mainiscroll.scrolltoelement($('#product01').get(0),0); } }else{ masterinfo.scrolldatas.scrolly = $(document).scrolltop(); $(document).scroll(function(doc) { masterinfo.scrolldatas.scrolly = $(document).scrolltop(); masterinfo.ani(masterinfo.scrolldatas); }); //滚动指定位置 if(masterinfo.geturlparms('ql')){ if(masterinfo.geturlparms('ql')!=5){ $body = (window.opera) ? (document.compatmode == "css1compat" ? $('html') : $('body')) : $('html,body'); $body.animate({ scrolltop: $('#index'+masterinfo.geturlparms('ql')).offset().top },1000); } } } masterinfo.ani(masterinfo.scrolldatas); //aboutbanner文字ease:power1.easein if($('.aboutbanner_info').length!=0){ tweenmax.staggerfromto('.aboutbanner_info span',1,{x:'50px',opacity:0},{x:0,opacity:1},.1); } } }); } function getallbgimages() { var url, b = [], a = document.getelementsbytagname('*'); a = b.slice.call(a, 0, a.length); while (a.length) { url = document.deepcss(a.shift(), 'background-image'); if (url) url = /url\(['"]?([^")]+)/.exec(url) || []; url = url[1]; if (url && b.indexof(url) == -1) b[b.length] = url; } return b; } document.deepcss = function (who, css) { if (!who || !who.style) return ''; var sty = css.replace(/\-([a-z])/g, function (a, b) { return b.touppercase(); }); if (who.currentstyle) { return who.style[sty] || who.currentstyle[sty] || ''; } var dv = document.defaultview || window; return who.style[sty] || dv.getcomputedstyle(who, "").getpropertyvalue(css) || ''; } array.prototype.indexof = array.prototype.indexof || function (what, index) { index = index || 0; var l = this.length; while (index < l) { if (this[index] === what) return index; ++index; } return -1; } preloadimg(); }, //首页banner hbanner:function(){ if($('.hbanner_swiper').length!=0){ var times = !masterinfo.mobile()?1200:500; var hbanner = new swiper ('.hbanner_swiper', { loop: true, speed:times, parallax: true, autoplay: { delay:5000, disableoninteraction: false }, on:{ slidechangetransitionstart: function(){ $('.hbanner_nav').children('.hbanner_nav_btn').eq(this.realindex).addclass("on").siblings().removeclass("on"); }, } }); $(document).on('click','.hbanner_nav .hbanner_nav_btn',function(){ var is = $(this),index = is.index(); hbanner.slidetoloop(index, times, false); is.addclass('on').siblings().removeclass("on"); }); } }, //鼠标跟随 cursorfollow:function(){ $(document).on('mousemove', function(e) { var clientx = e.clientx, clienty = e.clienty; var scrollleft = $(this).scrollleft(), scrolltop = $(this).scrolltop(); var left = clientx + scrollleft, top = clienty + scrolltop; mytween = tweenlite.to($('.cursor'),.4,{x:left,y:top}); }); $(document).on('mousedown', function(e) { $('.cursor_circle').addclass('on'); }); $(document).on('mouseup', function(e) { $('.cursor_circle').removeclass('on'); }); }, cursorhover: function(el){ if($(el).length!=0){ $(el).hover(function() { $('.cursor').addclass('onani'); },function(){ $('.cursor').removeclass('onani'); }); } }, scrollajax:function(obj){ $.ajax({ type:"get", url:window.location.pathname+'index_'+masterinfo.pagenumber+'.html', datatype:"html", success:function(data){ var htmllist = $(data).find(obj).children('div'); if(htmllist.length!=0){ $(obj).append($(data).find(obj).html()); masterinfo.loadstr = true; }else{ $('.pageload').addclass('not').children('.pageload_state').text('- end -') masterinfo.loadstr = false; } !masterinfo.mobile()?masterinfo.mainiscroll.refresh():''; } }) } } masterinfo.init();