"use strict"; var indexSlider; $(document).ready(function() { // alert($(window).width() + ',' + $(window).height()); $('[bg]').each(function() { $(this).addClass('coverbg'); $(this).css('background-image', 'url('+$(this).attr('bg')+')'); }); if(window.innerWidth>800){ //global.stock(); } $('.menuToggler').click(function() { if($('.menu .menulist').is(':visible')) { $(this).removeClass('active'); $('.menu .menulist').hide(); }else{ $(this).addClass('active'); $('.menu .menulist').show(); } }); global.header(); if($(window).width()<=800) { $('.header .menu .menulist li > a').click(function() { if($(this).siblings('.sub').length>0 && !$(this).siblings('.sub').hasClass('show')){ $('.header .menu .sub').removeClass('show'); $(this).siblings('.sub').addClass('show'); return false; }else{ $('.header .menu .sub').removeClass('show'); $(this).siblings('.sub').addClass('show'); } }) } // var hash = window.location.hash; if(hash.indexOf('#')>=0) { hash = hash.replace('#',''); $("html,body").animate({ scrollTop: $('.'+hash).offset().top }, 1000); } $('.header .menu .menulist li .sub dd a').click(function() { setTimeout(function(){ var hash = window.location.hash; if(hash.indexOf('#')>=0) { hash = hash.replace('#',''); $("html,body").animate({ scrollTop: $('.'+hash).offset().top }, 1000); } },100) }); $('.download .s1 .container .video .playbtn').click(function() { $('.download .s1 .container .video video').removeAttr('muted'); if(!$('.download .s1 .container .video').hasClass('active')) { $('.download .s1 .container .video').addClass('active'); var video = $('#video')[0]; video.currentTime = 0; video.muted = false; video.volume = 1; video.play(); }else{ $('.download .s1 .container .video').removeClass('active'); var video = $('#video')[0]; video.volume = 0; video.muted = true; video.pause(); } }) }); var index = { banner: function() { var that = this; setTimeout(function() { $('.index').addClass('loaded'); $('.loading').remove(); }, 10e3); $('.videoPop').css({height: $(window).height()}); if($(window).width()<=480&&$('#bannervideo').length>0) { var ts = $('#bannervideo').attr('data-ts'); $('#bannervideo').replaceWith(''); var tsPlayer = new JSMpeg.Player(ts, { canvas: $('#ts')[0], autoplay:true, loop: true, audio: false, progressive: true, disableWebAssembly: true, decodeFirstFrame: true, onEnded: function() { indexSlider.startAuto(); // console.log(1); } }) } $('.index .banner .slider li').css({ height: $(window).height() }); var sliderNums = $('.index .banner .slider li').length; sliderNums = sliderNums<10 ? '0' + sliderNums : sliderNums; indexSlider = $('.index .banner .slider').bxSlider({ controls: false, pager: true, auto: true, mode: 'fade', pause: 10e3, onSliderLoad: function() { $('.banner .counter').text('01 / ' + sliderNums); if($('#bannervideo').length>0) { $('#bannervideo')[0].play(); } if($(window).width()>800) { $('.header,.banner').addClass('darkfont'); } }, onSlideBefore: function ($slideElement, oldIndex, newIndex) { // if(newIndex==0&&$(window).width()>800) { // $('.header,.banner').addClass('darkfont'); // }else{ // $('.header,.banner').removeClass('darkfont'); // } if($slideElement.find('video').length>0) { indexSlider.stopAuto(); $('#bannervideo')[0].currentTime = 0; $('#bannervideo')[0].play(); }else if($slideElement.find('canvas').length>0) { indexSlider.stopAuto(); tsPlayer.play(); }else{ indexSlider.startAuto(); if(tsPlayer) { tsPlayer.stop(); } } var current = newIndex<10 ? '0' + (newIndex+1) : (newIndex+1); $('.banner .counter').text(current + ' / ' + sliderNums); } }); }, s2: function() { var itemNum = $('.index .s2 .item').length; var margin = 82; margin = $(window).width() <= 1440 ? 60 : margin; margin = $(window).width() <= 1280 ? 50 : margin; margin = $(window).width() <= 800 ? 0 : margin; var itemWidth = $('.index .s2 .item').width() + margin; var containerWidth = itemWidth * itemNum + 100; var maxOffset = containerWidth - $('.index .s2 .controls').width(); var current = 0; $('.index .s2 .container').css('width', containerWidth); $('.index .s2 .prev.btn').click(function() { current-=1; current = current<0? 0 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }) $('.index .s2 .next.btn').click(function() { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }) $('.index .s2 .item').mouseenter(function() { var index = $(this).index(); $('.index .s2 .nav li').eq(index).addClass('active').siblings().removeClass('active'); }); $('.index .s2 .item').mouseleave(function() { $('.index .s2 .nav li').removeClass('active'); }); if($(window).width()<=800) { $('.index .s2 .items .container').swipe({ swipeLeft: function(event, direction, distance, duration, fingerCount, fingerData) { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }, swipeRight: function(event, direction, distance, duration, fingerCount, fingerData) { current-=1; current = current<0? 0 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }, // swipe:function(event, direction, distance, duration, fingerCount, fingerData) { // if(direction=='right') { // current-=1; // current = current<0? 0 : current; // index.s2go(current, itemWidth, maxOffset,itemNum); // } // if(direction=='left') { // current+=1; // current = current>itemNum-1? itemNum-1 : current; // index.s2go(current, itemWidth, maxOffset,itemNum); // } // }, excludedElements: "label, button, input, select, textarea, .noSwipe" }) } }, s2go: function(id, itemWidth, maxOffset, itemNum) { var ids = id+1 < 10 ? '0' + (id+1) : id+1; var nums = itemNum < 10 ? '0' + itemNum : itemNum; $('.index .s2 .controls p').text(ids+' / '+nums); $('.index .s2 .nav .current font').text(ids+' / '+nums); var offset = id * itemWidth; if($(window).width()>800) { $('.index .s2 .container').css({ 'transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-o-transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-webkit-transform': 'translateX('+-1*offset+'px) translateY(-50%)' }) }else{ $('.index .s2 .container').css({ 'transform': 'translateX('+-((1*offset)-20)+'px)', '-o-transform': 'translateX('+-((1*offset)-20)+'px)', '-webkit-transform': 'translateX('+-((1*offset)-20)+'px)' }) } }, s3: function() { var itemNum = $('.index .s3 .item').length; var itemWidth = $('.index .s3 .item').outerWidth(); var containerWidth = itemWidth * itemNum + 100; var maxOffset = containerWidth - $('.index .s3 .controls').width(); var current = 0; $('.index .s3 .container .item').css('width', itemWidth); $('.index .s3 .container').css('width', containerWidth); $('.index .s3 .prev.btn').click(function() { current-=1; current = current<0? 0 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }) $('.index .s3 .next.btn').click(function() { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }); if($(window).width()<=800) { $('.index .s3 .items .container').swipe({ swipeLeft: function(event, direction, distance, duration, fingerCount, fingerData) { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }, swipeRight: function(event, direction, distance, duration, fingerCount, fingerData) { current-=1; current = current<0? 0 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }, // swipe:function(event, direction, distance, duration, fingerCount, fingerData) { // if(direction=='right') { // current-=1; // current = current<0? 0 : current; // index.s3go(current, itemWidth, maxOffset,itemNum); // } // if(direction=='left') { // current+=1; // current = current>itemNum-1? itemNum-1 : current; // index.s3go(current, itemWidth, maxOffset,itemNum); // } // }, excludedElements: "label, button, input, select, textarea, .noSwipe" }) } }, s3go: function(id, itemWidth, maxOffset, itemNum) { var ids = id+1 < 10 ? '0' + (id+1) : id+1; var nums = itemNum < 10 ? '0' + itemNum : itemNum; $('.index .s3 .controls p').text(ids+' / '+nums); var offset = id * itemWidth; if($(window).width()>800) { $('.index .s3 .container').css({ 'transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-o-transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-webkit-transform': 'translateX('+-1*offset+'px) translateY(-50%)' }); }else{ $('.index .s3 .container').css({ 'transform': 'translateX('+-(1*offset)+'px)', '-o-transform': 'translateX('+-(1*offset)+'px)', '-webkit-transform': 'translateX('+-(1*offset)+'px)' }); } } } var about = { init:function() { this.s4(); this.s6(); }, s4:function() { $('#charts').forslide({ step: 2, item: '.chart', callback: function() { $('#charts').bxSlider({ auto: true, pause: 10e3, speed: 1e3, controls: false }) } }) }, s6:function() { $('.s6 .tabs a').click(function() { var index = $(this).index(); $(this).addClass('active').siblings().removeClass(); $('.s6 .pages .page').removeClass('active').eq(index).addClass('active'); }) } } var brand = { init:function() { } } var invset = { init:function() { this.s2(); this.s3(); }, s3:function() { var that = this; var current = 0; var itemNum,timeout; $('.s3 .items').forslide({ tagName: 'div', tagClass: 'page', step: 2, callback: function() { $('.s3 .items .page').each(function(i) { $(this).html('
' + $(this).html() +'
'); $('.s3 .pager ul').append('
  • '+i+'
  • '); }) itemNum = $('.s3 .page').length; that.s3goto(0); } }); $('.s3 .btns .btn').click(function() { $(this).hasClass('prev')?current-=1:current+=1; current = current<0?0:current; current = current>itemNum-1?0:current; console.log(current); that.s3goto(current); }) $(window).resize(function() { clearTimeout(timeout); timeout = setTimeout(function() { that.s3goto(current); },.2e3) }); $('.s3 .pager').on('click', 'li', function() { var index = $(this).index(); that.s3goto(index); }) }, s3goto:function(i) { var el = $('.urbandevelop .s3'); var itemWidth = el.find('.page').eq(0).outerWidth(); var itemMargin = 50; var itemNum = el.find('.page').length; var itemOuterWidth = itemWidth + itemMargin * 2; var containerWidth = itemNum * itemOuterWidth; var screenXOffset = ($(window).width() - itemWidth) / 2 - itemMargin; var moveIndex = 0 - i*itemOuterWidth + screenXOffset; el.find('.page').eq(i).addClass('active').siblings().removeClass('active'); $('.s3 .items').css({ 'width': containerWidth, 'transform': 'translateX('+moveIndex+'px)', '-o-transform': 'translateX('+moveIndex+'px)', '-webkit-transform': 'translateX('+moveIndex+'px)' }); el.find('.pager ul li').eq(i).addClass('active').siblings().removeClass(); $('.s3 .current span').text(i<9?'0'+(i+1):i); $('.s3 .current i').text(itemNum<10?'0'+itemNum:itemNum); }, s2:function() { var itemNum = $('.urbandevelop .s2 .item').length; if($(window).width()>480) { var that = this; var current = 0; var interval = 10e3; var timeout; $('.s2 .items .item').each(function(i) { $('.s2 .pager ul').append('
  • '+i+'
  • ') }); // var timer = setInterval(function() { // current+=1; // current = current>itemNum-1?0:current; // that.s2GoNext(current); // },interval); $(window).resize(function() { clearTimeout(timeout); timeout = setTimeout(function() { that.s2GoNext(current); },.2e3) }); $('.s2 .pager').on('click', 'li', function() { var index = $(this).index(); current = index; that.s2GoNext(index); // clearInterval(timer); // timer = setInterval(function() { // current+=1; // current = current>itemNum-1?0:current; // that.s2GoNext(current); // },interval); }); $('.s2 .btns .btn').click(function() { $(this).hasClass('prev')?current-=1:current+=1; current = current<0?0:current; current = current>itemNum-1?0:current; // console.log(current); that.s2GoNext(current); }); $('.s2 .items .item').click(function() { var index = $(this).index(); if(index>current) {current+=1;} if(index'); $('.urbandevelop .s2 .items ul').html(html); us2s = $('.urbandevelop .s2 .items ul').bxSlider({ pager: false, controls: false, adaptiveHeight: true, onSliderLoad: function() { $('.s2 .current2 span').text('01'); $('.s2 .current2 i').text(itemNum<10?'0'+itemNum:itemNum); }, onSlideBefore: function($el, old, newid) { $('.s2 .current2 span').text(newid<9?'0'+(newid+1):newid+1); $('.s2 .current2 i').text(itemNum<10?'0'+itemNum:itemNum); } }); } }); $('.urbandevelop .s2 .btns .btn.prev').click(function() { console.log('1'); us2s.goToPrevSlide(); }); $('.urbandevelop .s2 .btns .btn.next').click(function() { us2s.goToNextSlide(); }); } }, s2GoNext:function(i) { var el = $('.urbandevelop .s2'); var itemWidth = el.find('.item').eq(0).outerWidth(); var itemMargin = 100; itemMargin = $(window).width() <= 1200 ? 50 : itemMargin; itemMargin = $(window).width() <= 860 ? 20 : itemMargin; var itemNum = el.find('.item').length; var itemOuterWidth = itemWidth + itemMargin * 2; var containerWidth = itemNum * itemOuterWidth; var screenXOffset = ($(window).width() - itemWidth) / 2 - itemMargin; var moveIndex = 0 - i*itemOuterWidth + screenXOffset; el.find('.item').css({'width': itemWidth}); el.find('.item').eq(i).addClass('active').siblings().removeClass('active'); el.find('.items').css({ 'width': containerWidth, 'transform': 'translateX('+moveIndex+'px)', '-o-transform': 'translateX('+moveIndex+'px)', '-webkit-transform': 'translateX('+moveIndex+'px)' }); el.find('.pager ul li').eq(i).addClass('active').siblings().removeClass(); $('.s2 .current span').text(i<9?'0'+(i+1):i+1); $('.s2 .current i').text(itemNum<10?'0'+itemNum:itemNum); $('.s2 .current2 span').text(i<9?'0'+(i+1):i+1); $('.s2 .current2 i').text(itemNum<10?'0'+itemNum:itemNum); if($(window).width()>480) { var btnOffset = $('.urbandevelop .s2 .items .item.active').outerWidth()/2; $('.urbandevelop .s2 .btns .btn.prev').css('margin-right', btnOffset - 0); $('.urbandevelop .s2 .btns .btn.next').css('margin-left', btnOffset - 0); $('.urbandevelop .s2 .current').css({ 'right': '50%', 'margin-right': btnOffset + 100 }); $('.urbandevelop .s2 .pager').css({ 'left': '50%', 'margin-left': btnOffset + 100 }); } } } var global = { header:function() { if($('.header').hasClass('fixed')) { $('.header').addClass('sticky') // $(window).scroll(function() { // $(window).scrollTop()>$(window).height()/2?$('.header').addClass('sticky'):$('.header').removeClass('sticky'); // }) $(window).scroll(function() { //$(window).scrollTop()>$(window).height()/2?$('.header').addClass('redline'):$('.header').removeClass('redline'); }) } }, stock:function() { // 获取实时股价信息 var stockinfo = hq_str_sh600057.split(','); var current = stockinfo[3]; var lastDay = stockinfo[2]; var difference = Math.round((current-lastDay)*100)/100; var percentage = Math.round(difference / lastDay * 10000)/100; var turnover = Math.round(parseInt(stockinfo[8]) / 10000)/100; var upordown = difference>0?'+':''; if(lastDay>current) { $('.stock .statu strong').addClass('down'); } $('.stock .statu strong span').text(parseFloat(current).toFixed(2)); $('.stock .statu strong sub').text(upordown+difference + ' ( '+upordown+percentage+'% )'); // 市盈率怎么算的来着 $('.stock .statu p').html('成交量:'+turnover+'万'); $('.stock .trend [h]').click(function() { $(this).addClass('active').siblings('[h]').removeClass('active'); var h = $(this).attr('h'); var link = 'http://image.sinajs.cn/newchart/'+h+'/n/sh600057.gif?v='+new Date().getTime(); $('.stock .trend img').attr('src', link); }) } }