$(window).on("load",function(){ //获取页面url后面的参数 var number = function(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i button:first").attr("data-name")); var that = this; $(".footer-btn > button").on("click",function(){ that.InitialDefaultDisplay($(this).attr("data-name")); }); $(".o-slider-header img").on("pointerdown",function(e){ e.preventDefault(); }) }; HotContent.prototype.InitialDefaultDisplay = function(id){ $("."+id).show().siblings().hide(); $('[data-name='+id+']').addClass("active").siblings().removeClass("active"); if($("."+id).find("video").length < 1){ if($("."+id).siblings().find("video").length > 0)$("."+id).siblings().find("video")[0].pause(); $(".playPause").addClass("fa-play").removeClass("fa-pause"); } }; HotContent.prototype.createElements = function(data,classname){ var contioner = $(".contioner"); function createChildrenElements(){ var children = []; switch (classname) { case this.wrap.images: data.forEach(function(currentValue){ children.push('图片') ; }) break; case this.wrap.video: data.forEach(function(currentValue){ children.push(videoEle(currentValue.url,currentValue.img)); }) break; case this.wrap.model: data.forEach(function(currentValue){ children.push(''); }) break; case this.wrap.iframe: data.forEach(function(currentValue){ children.push(''); }) break; } return children; } function videoEle(src,img){ if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ return '
\
\ \ \ \
\
\
\
\
\
\ 0:00 / 0:00\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\ \
\
'; }else{ return '' } } function singleElement(){ var SE = createChildrenElements.call(this); contioner.append('
'+SE+'
').css("height",this.screenHeight); this.Zoom(classname); }; function doubleElement(){ var DE = createChildrenElements.call(this); var _doubleElement = this.generateElements().mainElements(classname,this.generateElements(data,DE).multiElement()); contioner.append(_doubleElement).css("height",this.screenHeight); this.build(classname); this.Zoom(classname); }; if(data.length > 1) { doubleElement.call(this,classname); } else { singleElement.call(this,classname); } }; HotContent.prototype.generateElements = function(data,ele){ function combination(SingleOriginal){ if(!data) return; return '
\
\
' +SingleOriginal+ '
\
\
'; } return { mainElements : function(classname,children){ return '
\
\
' +children+ '
\
\
'; }, multiElement : function(){ var _multiElement = ""; for (var i = 0; i < data.length; i++) { _multiElement += combination(ele[i]); } return _multiElement; } }; }; //启动轮播 HotContent.prototype.build = function(id) { var screenHeight = this.screenHeight; $('#pbSlider-'+id).pbTouchSlider({ slider_Wrap: '#pbSliderWrap-'+id, slider_Threshold: 10, slider_Speed:600, slider_Ease:'ease-out', slider_Drag : true, slider_Arrows: { enabled : true }, slider_Dots: { class :'.o-slider-pagination', enabled : true, preview : false }, slider_Breakpoints: { default: { height: screenHeight }, tablet: { height: screenHeight, media: 1024 }, smartphone: { height: screenHeight, media: 768 } } }); }; // 启动图片的放大缩小 HotContent.prototype.Zoom = function(classname) { if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ if(classname != "wrap-img") return; $("."+classname).find(".o-slider-header").each(function(){ new RTP.PinchZoom(this, {}); }) } }; HotContent.prototype.footer = function() { $(".footer").append(this.footerCreateEle()); }; HotContent.prototype.footerCreateEle = function() { var num = number("m"); var lang = number("lang"); var footerH3 = this.data[num].text ? lang == "en" ? this.data[num].text.EH.title : this.data[num].text.CH.title : ""; var footerBtn = ''; var btnIcon = { "img":["img-icon","图片"], "video":["video-icon","视频"], "model":["model-icon","3D"], "iframe":["iframe-icon","网页"] }; function btnBuild(id,classname,text){ return '' } function footerText(data){ if(!data) return ""; var text = ''; var record = lang == "en" ? data.EH : data.CH ; record.content.forEach(function(currentValue) { text += "

"+currentValue+"

"; }); return text; } this.data[num].model ? footerBtn += btnBuild(this.wrap.model,btnIcon.model[0],btnIcon.model[1]) : ''; this.data[num].video ? footerBtn += btnBuild(this.wrap.video,btnIcon.video[0],btnIcon.video[1]) : ''; this.data[num].iframe ? footerBtn += btnBuild(this.wrap.iframe,btnIcon.iframe[0],btnIcon.iframe[1]): ''; this.data[num].images ? footerBtn += btnBuild(this.wrap.images,btnIcon.img[0],btnIcon.img[1]) : ''; return '\ '; } HotContent.prototype.onlyType = function() { var footerBtn = $(".footer-btn"); if(footerBtn.children().length > 1 ) return; footerBtn.hide(); if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ if(!this.data[number("m")].text ){ $(".contioner").css("height",$(document.body).height() * 0.96); } $(".footer-btn").hide(); } } new HotContent("https://super.4dage.com/data/"+number("id")+"/hot/js/data2.js"); //new HotContent("http://192.168.0.41:8080/SuperTwo/data/"+number("id")+"/hot/js/data2.js"); })