index.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import 'bootstrap/dist/js/bootstrap.js';
  2. import 'css/newMenu/public.css';
  3. import 'css/newMenu/header.css'
  4. import 'css/newMenu/index.css';
  5. import 'css/inded.css';
  6. import 'js/public.js';
  7. (function(){
  8. "use strict";
  9. init();
  10. function init(){
  11. banner();
  12. };
  13. navTop();
  14. function navTop() {
  15. $(window).scroll(function(){
  16. var scrolltop=$(document).scrollTop();
  17. $('.topNav')[scrolltop>0?'addClass':'removeClass']('navFix');
  18. // videoAuto();
  19. });
  20. }
  21. //轮播
  22. function banner(){
  23. $('#myCarousel').carousel({
  24. interval: 4000
  25. })
  26. };
  27. //搜索框上面栏目的选择
  28. $(".jumpType li").click(function(){
  29. $(this).addClass("active");
  30. $(this).siblings().removeClass("active");
  31. })
  32. //搜索功能
  33. $(".searchImg").click(function(){
  34. var key=$('.demandSearch').val();
  35. sessionStorage.setItem("name",key);
  36. window.open(globalConfig.context + `/portal/search.html`);
  37. })
  38. function task(){
  39. if($(".brands>div>img:nth-child(1)").hasClass("active")){
  40. $(".brands>div>img:nth-child(3)").css("opacity","0");
  41. $(".brands>div>img").removeClass("bni").removeClass("ani").removeClass("active");
  42. $(".brands>div>img:nth-child(2)").addClass("ani").addClass("active");
  43. }else if($(".brands>div>img:nth-child(2)").hasClass("active")){
  44. $(".brands>div>img:nth-child(1)").css("opacity","0");
  45. $(".brands>div>img").removeClass("bni").removeClass("ani").removeClass("active");
  46. $(".brands>div>img:nth-child(3)").addClass("ani").addClass("active");
  47. }else if($(".brands>div>img:nth-child(3)").hasClass("active")){
  48. $(".brands>div>img:nth-child(2)").css("opacity","0");
  49. $(".brands>div>img").removeClass("bni").removeClass("ani").removeClass("active");
  50. $(".brands>div>img:nth-child(1)").addClass("ani").addClass("active");
  51. }
  52. }
  53. setInterval(task,4000);
  54. //初始悬浮窗口处理
  55. initModel();
  56. function initModel(){
  57. if(!sessionStorage['initVal']){ //为true时显示了一次
  58. $('.initModel').addClass('active');
  59. }
  60. sessionStorage['initVal']=true;
  61. $('.initModel .glyphicon-remove').click(function(){
  62. $(this).parents('.initModel').removeClass('active');
  63. })
  64. if($('.initModel').hasClass('active')){
  65. setTimeout(()=>{
  66. $('.initModel .glyphicon-remove').trigger('click');
  67. },10000)
  68. }
  69. };
  70. //视频自动播放处理
  71. let status=true;
  72. var myVideo=document.getElementById("video1");
  73. function videoAuto(){
  74. let videoH = $('.wield_cont')[0],
  75. clentH = videoH.getBoundingClientRect();
  76. if(clentH.top < (document.documentElement.clientHeight+200)){
  77. if(status){ //只自动播放一次
  78. myVideo.play();
  79. status=false;
  80. }
  81. }
  82. }
  83. //防止下载
  84. $('#video1').hover(function(){
  85. document.oncontextmenu=function(e){
  86. return false
  87. }
  88. },function(){
  89. document.oncontextmenu=function(e){
  90. }
  91. })
  92. }())