jquery(function () { function initbox() { w_width = jquery(window).width(); w_height = jquery(window).height(); // $('.banner').css('height', w_height); $('.pro-slide,.pro-slide figure,.banner-slide,.banner-slide figure').css('height', w_height); setimgmax($('.pro-slide figure img,.banner-slide figure img'), 1920, 960, w_width, w_height); }; initbox(); jquery(window).resize(function () { initbox(); }); var indexfn = { init:function (){ this.getbanner(); this.getnewstab(); this.getprouct(); this.getyi(); }, getbanner: function() { if(!ismobile){ var activemaxpage = 5; var swiperbox = new swiper('.home-swiper', { speed: 1200, direction: 'vertical', slidesperview: 'auto', loop: false, touchratio: '0', mousewheelcontrol: true, //parallax: true, paginationclickable :true, mousewheelreleaseonedges : true, scrollbarsnaponrelease : true , breakpoints: { //当宽度小于等于320 1024: { mousewheelcontrol: false, }, }, onslideprevstart: function(swiper){ }, ontransitionend : function(e) { console.log(e.activeindex); if(e.activeindex == activemaxpage){ // 是否最后一页 swiperbox.lockswipetonext(); setswiperbottom(e); }else{ swiperbox.unlockswipetonext(); } }, onreachend: function(e){ setswiperbottom(e); }, ontransitionstart: function(e) { if(e.activeindex >= 1){ $(".header").addclass("active"); }else{ $(".header").removeclass("active"); } }, }); function setswiperbottom(e){ swiperbox.setwrappertransition(300); swiperbox.setwrappertranslate(-e.height * (activemaxpage - 1)-$(".footer").outerheight()); } $(".scrolltop").click(function(){ swiperbox.slideto(0, 1000, false); }); } }, getnewstab: function() { $(".real-btn li").click(function(){ $(this).addclass("active").siblings().removeclass("active"); $(".real-item").eq($(this).index()).addclass("show").siblings().removeclass("show"); }); }, getprouct: function(){ var $length1 = $(".pro-slide").length; var productswiper = new swiper('.product-swiper', { autoplay: 4500, speed: 1000, slidesperview: 1, parallax: true, loop: true, touchratio: '0.5', autoheight: true, oninit: function(swiper){ $(".pro-numble span").text('0'+$length1); }, onslidechangestart: function(swiper){ $(".pro-numble b").text('0'+(swiper.realindex + 1)); $(".product-tab-list li").eq(swiper.realindex).addclass("active").siblings().removeclass("active"); } }); $(".product-tab-list li").click(function(){ $(this).addclass("active").siblings().removeclass("active"); productswiper.slideto($(this).index() + 1, 800, false); }); }, getyi: function(){ var _this = this; _loaded(); function _loaded(){ var _waterdroptime=10; settimeout(function () { // var box = $('.banner-box')[0]; var wid = 1920; var hei = 960; var spriteimages = box.queryselectorall('.slide-item__image'); var spriteimagessrc = []; var texts = []; for (var i = 0; i < spriteimages.length; i++) { var img = spriteimages[i]; // set the texts you want to display to each slide // in a sibling element of your image and edit accordingly if (img.nextelementsibling) { texts.push(img.nextelementsibling.innerhtml); } else { texts.push(''); } spriteimagessrc.push(img.getattribute('src')); } if (window.innerwidth < 600) { wid = 750; } var initcanvasslideshow = new canvasslideshow({ sprites: spriteimagessrc, stagewidth: wid, stageheight: hei, parent: box, displacementimage: '/public/images/clouds.jpg', autoplay: true, autoplayspeed: [6, 5], centersprites: false }); var homefn = { clock: function () { var parent = $('.indexbanner'), clock = $('#clock'), msgbox = parent.find('.msg-box'), msg = msgbox.find('ol.msg_1').children('li'), msg_2 = msgbox.find('ol.msg_2').children('li'), next = $('.scene-nav--next'), _cur = $('.scene-nav--cur'), _shi = $('.time-el').find('.shi'), _fen = $('.time-el').find('.fen'), num = clock.find('.time-num'), cir = clock.find('.time-cir'), box = clock.find('.time-move'); var _w = box.width() * window.devicepixelratio + 5, _h = box.height() * window.devicepixelratio + 5, r = _w / 2 - 3; var cv = document.createelement('canvas'), ctx = cv.getcontext('2d'); ctx.imagesmoothingenabled = true; cv.width = _w; cv.height = _h; box.append(cv); var rad = math.pi * 2 / 360, ani = false, isclick = true, index = 1, m1 = 0, m2 = 0, v1 = 0.2, v2 = 1; var once = true; var once2 = true; cir.find('li').on('click', function () { if (ani) return false; var cur = index % 6, len = $(this).index(); _cur.attr('data-nav', len); isclick = false; var a = (cur - len) > 0 ? (6 - (cur - len)) : (len - cur); if (a != 0) { index = index + a; } _shi.addclass('on'); v1 = (v1 * (20 + 5 * a)); v2 = (v2 * (a + 1)); }); //绘制运动圆环 function foregroundcircle(n, m) { ctx.save(); ctx.translate(_w / 2, _h / 2); ctx.strokestyle = 'rgba(255,255,255,1)'; ctx.linewidth = 5; ctx.linecap = "round"; ctx.beginpath(); ctx.arc(0, 0, r, math.pi / 2 + m * rad, math.pi / 2 + n * rad, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针) ctx.stroke(); ctx.closepath(); ctx.restore(); } //6段动画 function move() { m1 += v1; if (once && m1 >= (50 + 60 * (index - 1))) { once = false; _shi.css('transform', 'rotate(' + (60 * index) + 'deg)'); _fen.addclass('on'); } if (m1 >= (60 * index)) { m1 = 60 * index; cir.find('li').eq(index % 6).addclass('on').siblings().removeclass('on'); num.find('li').eq(index % 6).addclass('on').siblings().removeclass('on'); msg.eq(index % 6).addclass('on').siblings().removeclass('on'); msg_2.eq(index % 6).addclass('on').siblings().removeclass('on'); if (isclick) { if (once2) { next.click(); once2 = false; } } else { _cur.click(); } ani = true; m2 += v2; if (m2 >= m1) { m2 = 60 * index; once = true; ani = false; isclick = true; once2 = true; settimeout(function () { _shi.removeclass('on'); _fen.removeclass('on'); }, 500); v1 = 0.2; v2 = 1; index++; } } foregroundcircle(m1, m2); } function drawframe() { window.requestanimationframe(drawframe, cv); ctx.clearrect(0, 0, cv.width, cv.height); move(); } drawframe(); }, items: function () { var _parent = $('.other-pop'); _parent.each(function () { var _item = $(this).find('.items'), _list = _item.find('.box'), next = _list.find('.next'); var arr = ['b1', 'b2', 'b3', 'b4', 'b5'], cur = 0, nextcur = 0, newarr = null, all = _list.length; var _next = function () { nextcur = cur < (all - 1) ? (cur + 1) : 0; _list.eq(nextcur).siblings().removeclass('on'); settimeout(function () { _list.eq(nextcur).addclass('on'); }, 800); switch (nextcur) { case 0: newarr = ['b1', 'b2', 'b3', 'b4', 'b5']; break; case 1: newarr = ['b5', 'b1', 'b2', 'b3', 'b4']; break; case 2: newarr = ['b4', 'b5', 'b1', 'b2', 'b3']; break; case 3: newarr = ['b3', 'b4', 'b5', 'b1', 'b2']; break; case 4: newarr = ['b2', 'b3', 'b4', 'b5', 'b1']; break; } _list.each(function (index) { var _this = $(this); _this.addclass(newarr[index]); _this.removeclass(arr[index]); }); arr = newarr; cur = nextcur; } var _prev = function () { nextcur = cur > 0 ? (cur - 1) : (all - 1); _list.eq(nextcur).siblings().removeclass('on'); settimeout(function () { _list.eq(nextcur).addclass('on'); }, 800); switch (nextcur) { case 0: newarr = ['b1', 'b2', 'b3', 'b4', 'b5']; break; case 1: newarr = ['b5', 'b1', 'b2', 'b3', 'b4']; break; case 2: newarr = ['b4', 'b5', 'b1', 'b2', 'b3']; break; case 3: newarr = ['b3', 'b4', 'b5', 'b1', 'b2']; break; case 4: newarr = ['b2', 'b3', 'b4', 'b5', 'b1']; break; } _list.each(function (index) { var _this = $(this); _this.addclass(newarr[index]); _this.removeclass(arr[index]); }); arr = newarr; cur = nextcur; } next.on('click', function () { _next(); }); window.base.touchmove(_list, _next, _prev); }); }, _play: function () { $('.play').each(function () { var _this = $(this), video = $('#' + _this.attr('data-play')); _this.on('click', function () { _this.addclass('on'); video.addclass('on'); video[0].play(); }); video.on('click', function () { _this.removeclass('on'); video.removeclass('on'); video[0].pause(); }) }); } }; homefn.clock(); homefn.items(); homefn._play(); }, _waterdroptime) } } } indexfn.init(); });