$(document).ready(ready); //页面锚点 function anchor(selector){ let top = typeof selector === 'number' ? selector : $(selector).offset().top; let navHeight = $("nav").height(); $("html,body").animate({scrollTop:top-navHeight}); } function LoadList(param){ this.page = param.page?param.page:0; this.offset = null; this.length = null; this.url = null; this.id = null; this.write = param.write?param.write:"append"; this.before = param.before?param.before:function(){}; this.after = param.after?param.after:function(){}; this.content = $(param.content); this.trigger = $(param.trigger); this.format = param.format; this.default = param.default; this.state = true; this.noData = param.noData?param.noData:function(){}; this.getData = function (obj='method'){ let _this = this; $.ajax({ type: "post", url: _this.url, data: {page:_this.page,length:_this.length,cid:_this.id,py:_this.offset},//椤电爜锛屾潯鏁� dataType: "json", success: function(data){ _this[obj](data); }, error:function(){ console.log("网络错误!") } }); } this.method = function (data){ let content = document.createDocumentFragment(); let len = data.data.length; if(data.code === 200) { for (let i = 0; i < len; i++) { content.appendChild(this.format(data.data[i])); } this.content[this.write](content); this.after(data); if(data.data.length= tt && _this.state){ _this.state = false; _this.before(); _this.getData(); } wh = tt = th = scrollTop = null; } this.handle(); $(window).on("scroll",this.handle); } this.destroy = function (){ $(window).off("scroll",this.handle); for(var i in this){ delete this[i] } } this.init(); } function NumberScroll(param){ this.box = $(param.selecter); this.init = function (){ this.num = this.box.find(".data"); this.offsetTop = this.box.offset().top; this.height = this.box.height(); this.w_H = window.innerHeight; let _this = this; this.loadScrollNumber = function (){ let top = $(window).scrollTop(); if(_this.offsetTop + _this.height - _this.w_H < top){ _this.num.each(function (){ let self = $(this); let data = self.attr("data-value"); let start = 0; let unit = data/(param.duration/param.timeout); if(Number.isFinite(data*1)){ unit = data<=100?unit.toFixed(1):Math.floor(unit); scrollNumber(); }else{ self.text(data); } function scrollNumber(){ if(start>data){ self.text(data); return ; } self.text(start); start = unit<1?(Math.round(start*100 + unit*100)/100).toFixed(1):start + unit; setTimeout(scrollNumber,param.timeout); } }); _this.destroy(); } } $(window).on("scroll",_this.loadScrollNumber); this.loadScrollNumber(); } this.destroy = function (){ $(window).off("scroll",this.loadScrollNumber); for(var i in this){ delete this[i] } } this.init(); } function ready(){ let scroll = 0; window.sr = ScrollReveal(); sr.reveal(".reveal-rotate",{ duration: 400, easing: "cubic-bezier(0.6,0.2,0.1,1)", mobile: true, opacity: 0, reset: true, delay: 500, rotate: { x: -90, y: 0, z: 0 } }) sr.reveal("#home-video",{ duration: 400, delay: 800, mobile: false, reset: true, afterReset:function (el){ el.classList.add('body-content'); el.classList.add('spacing-bottom'); }, afterReveal:function (el){ el.classList.remove('body-content'); el.classList.remove('spacing-bottom'); } }) if(window.innerWidth < 768){ let page_anchor = $("#page_anchor"); let initial = $("#page_anchor .swiper-slide.active").index(); let anchor = new Swiper('#page_anchor .swiper',{ initialSlide: initial, direction: "vertical", mousewheel: true, centeredSlides: true }) $("#page_anchor_mob .fr").click(function (){ page_anchor.fadeIn(200,"linear",function (){ page_anchor.addClass("active"); }); }) $("#page_anchor>.masking").click(function (){ hide_page_anchor(function (){}); }) anchor.on("slideChange",function (swiper){ setTimeout(()=> { hide_page_anchor(function (){ location.href = swiper.slides[swiper.realIndex].href; }) },500); }) function hide_page_anchor(fn){ page_anchor.removeClass("active"); setTimeout(() => { page_anchor.fadeOut(200,"linear",fn); }, 200) } } //所有选项卡切换 $(".tab-control .tab-option .item:not(.disabled)").mouseenter(function (){ let self = $(this); if(self.hasClass('active'))return ; let ind = self.index(); let control = self.parents(".tab-control"); let content = control.find(".tab-content"); let options = control.find(".tab-option"); content.each(function (){ $(this).find(".item").hide(); $(this).find(".item").eq(ind).fadeIn(300,"linear"); }) options.each(function (){ $(this).find(".item").removeClass("active"); $(this).find(".item").eq(ind).addClass("active") }) }); //开关视频窗口 $(".m-video").click(function (){ let src = $(this).attr("data-src"); let type = $(this).attr("data-type"); let box = $("#panel-content ." + type); let content = $("#panel-content"); if(src !== box.attr("src")){ box.attr("src",src); if(type === "video"){ setTimeout(()=>{ if(box.height() > box.width()){ box.css({height:"100%"}) content.css({height:"80%"}) }else{ box.css({width:"100%"}) content.css({height:"auto"}) } },50); } } content.addClass(type); $("#fade-panel").fadeIn(200); }); $("#fade-panel .close,#panel-bg").click(function (){ $("#panel-content").removeClass('video').removeClass('iframe').removeClass('img'); $("#fade-panel").fadeOut(200); let iframe = $("#fade-panel iframe"); iframe.attr("src",iframe[0].src); $("#fade-panel video")[0].pause(); }) //导航 $("#navbar-button").click(function (){ // $(this).toggleClass("close"); $("#fixed_nav").fadeIn('200','linear',function (){ $(this).addClass("active"); }) }) $("#fixed_nav .close").click(function (){ $("#fixed_nav").removeClass("active"); setTimeout(()=>{ $("#fixed_nav").fadeOut(); },400) }) let nav = $("#nav"); let h = nav.height(); let stick = $("#back-top"); $(window).on("scroll",function (){ let top = $(this).scrollTop(); let nav_method = top <= h ? 'removeClass' : 'addClass'; let nav_method2 = top > h ? 'addClass' : 'removeClass'; let stick_method = (top > this.innerHeight*1.5 && top < scroll) ? "addClass" : "removeClass"; nav[nav_method]("active"); nav[nav_method2]("scroll"); console.log(nav_method) stick[stick_method]("active"); scroll = top; }); }