index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. $(function () {
  2. /*
  3. eg: <div class="wow animate slideInLeft" data-wow-delay="200ms"></div>
  4. 可选参数:
  5. data-wow-duration(动画持续时间)
  6. data-wow-delay(动画延迟时间)
  7. data-wow-offset(元素的位置露出后距离底部多少像素执行)
  8. data-wow-iteration(动画执行次数)
  9. */
  10. var volist = 0;
  11. if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
  12. var wow = new WOW({
  13. boxClass: 'wow', // 需要执行动画的元素的 class
  14. animateClass: 'animated', // animation.css 动画的 class
  15. offset: 0, // 元素的位置露出后距离底部多少像素执行
  16. mobile: true, // 是否在移动设备上执行动画
  17. live: true, // 异步加载的内容是否有效
  18. callback: function (e) {
  19. if ($(e).attr('data-type') == 'volist') {
  20. volist += 100;
  21. $(e).css("animation-delay", volist + 'ms');
  22. }
  23. }
  24. });
  25. wow.init();
  26. }
  27. setTimes();
  28. var timeOuts = null
  29. function setTimes() {
  30. timeOuts = setTimeout(function() {
  31. volist = 0;
  32. }, 150);
  33. }
  34. var st = $(window).scrollTop();
  35. $(window).scroll(function () {
  36. /*滚动时先清除上一个定时器,然后再设置新的定时器,以免出现多个定时器造成混乱*/
  37. clearTimeout(timeOuts);
  38. setTimes();
  39. st = $(window).scrollTop();
  40. });
  41. /*Banner图*/
  42. var Swiper1 = new Swiper('.swiper_in1', {
  43. pagination: '.swiper-pagination',
  44. paginationClickable: true,
  45. nextButton: '.swiper-button-next',
  46. prevButton: '.swiper-button-prev',
  47. observer:true,
  48. observeParents:true,
  49. autoplay:800,
  50. loop:true,
  51. speed:300,
  52. onInit: function (swiper) {
  53. if ($('.swiper_in1 .swiper-slide').eq(swiper.activeIndex).find('video').length == 0) {
  54. swiper.startAutoplay();
  55. } else {
  56. swiper.stopAutoplay();
  57. var video = document.getElementById("my-video");
  58. video.addEventListener('ended', function () {
  59. swiper.slideNext();
  60. swiper.startAutoplay();
  61. });
  62. }
  63. var len = $(".swiper-container.banner .swiper-pagination-bullet").length;
  64. if (len < 2) {
  65. $(".swiper-container.banner .swiper-pagination").hide();
  66. }
  67. },
  68. onSlideChangeStart: function(Swiper1){
  69. // 暂停所有视频
  70. var videos = document.getElementsByTagName('video');
  71. for (var i = videos.length - 1; i >= 0; i--) {
  72. (function(){
  73. var p = i;
  74. videos[p].addEventListener('play',function(){
  75. pauseAll(p);
  76. })
  77. })()
  78. }
  79. function pauseAll(index){
  80. for (var j = videos.length - 1; j >= 0; j--) {
  81. if (j!=index) videos[j].pause();
  82. }
  83. };
  84. // 判断swiper-slide-active是否有视频
  85. if($(".swiper_in1 .swiper-slide-active video").length>0){
  86. // 停止自动切换
  87. Swiper1.stopAutoplay();
  88. // 动态增加id
  89. $(".swiper_in1 .swiper-slide-active video").attr("id","video_01");
  90. var _video=document.getElementById("video_01");
  91. // 播放视频
  92. _video.play();
  93. // 切换后重新播放视频
  94. _video.currentTime = 0;
  95. // 静音
  96. _video.volume = 0;
  97. // 监听视频播放结束0
  98. _video.addEventListener('ended', function () {
  99. Swiper1.slideNext();
  100. //重新开始轮播banner
  101. Swiper1.startAutoplay();
  102. });
  103. }
  104. },
  105. onSlideChangeEnd: function(Swiper1){
  106. //动态移除id
  107. $(".swiper_in1 .swiper-slide-active video").attr("id","");
  108. }
  109. });
  110. });
  111. /*产品分类侧栏*/
  112. $(function(){
  113. $('.pn-list .pn-tit.cursleect').parents('.pn-content').slideDown().prev('.pn-tit').addClass('cur cut');
  114. var retractLeft = $(".pn-list").width();
  115. $('.pn-box').hover(function(){
  116. $('.pn-list').addClass('on')
  117. $('.pn-retract').css("left",retractLeft)
  118. },function(){
  119. $('.pn-list').removeClass('on')
  120. $('.pn-retract').css("left",-retractLeft)
  121. })
  122. $('.pn-retract').hover(function() {
  123. $('.pn-list').removeClass('on');
  124. $('.pn-retract').css("left",-retractLeft)
  125. },function(){
  126. $('.pn-list').addClass('on')
  127. $('.pn-retract').css("left",retractLeft)
  128. })
  129. $('.pn-list li .pn-tit-one').on('click',function(){
  130. var sss = $(this).parent('li').index();
  131. var len = $('.pn-list li').length-1;
  132. if (sss == len) {
  133. var off = $(this).offset().top - ($('.pn-list').height()/2);
  134. $('.pn-list').stop().animate({'scrollTop':off},500);
  135. };
  136. if (!$(this).hasClass('cut')) {
  137. $(this).addClass('cut').parents('li').siblings('li').find('.pn-tit-one').removeClass('cut');
  138. $(this).next('.pn-con-one').slideDown().parents('li').siblings('li').find('.pn-con-one').slideUp()
  139. }else{
  140. $(this).removeClass('cut')
  141. $(this).next('.pn-con-one').slideUp()
  142. }
  143. })
  144. $('.pn-list li .pn-tit-two').on('click',function(){
  145. var sss = $(this).parent('li').index();
  146. var len = $('.pn-list li').length-1;
  147. if (sss == len) {
  148. var off = $(this).offset().top - ($('.pn-list').height()/2);
  149. $('.pn-list').stop().animate({'scrollTop':off},500);
  150. };
  151. if (!$(this).hasClass('cut')) {
  152. $(this).addClass('cut').parents('li').siblings('li').find('.pn-tit-two').removeClass('cut');
  153. $(this).next('.pn-con-two').slideDown().parents('li').siblings('li').find('.pn-con-two').slideUp()
  154. }else{
  155. $(this).removeClass('cut')
  156. $(this).next('.pn-con-two').slideUp()
  157. }
  158. })
  159. $('.pn-list li .pn-tit-three').on('click',function(){
  160. if (!$(this).hasClass('cur')) {
  161. $(this).addClass('cur').siblings('.pn-tit-three').removeClass('cur').parents('li').siblings('li').find('.pn-tit-three').removeClass('cur');
  162. $(this).next('.pn-con-three').slideDown().siblings('.pn-con-three').slideUp().parents('li').siblings('li').find('.pn-con-three').slideUp()
  163. }else{
  164. $(this).removeClass('cur')
  165. $(this).next('.pn-con-three').slideUp()
  166. }
  167. })
  168. });