index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. (function($){
  2. $.fn.numberRock=function(options){
  3. var defaults={
  4. lastNumber:100,
  5. duration:3000,
  6. easing:'swing' //swing(默认 : 缓冲 : 慢快慢) linear(匀速的)
  7. };
  8. var opts=$.extend({}, defaults, options);
  9. $(this).animate({
  10. num : "numberRock",
  11. },{
  12. duration : opts.duration,
  13. easing : opts.easing,
  14. complete : function(){
  15. // console.log("success");
  16. },
  17. step : function(a,b){
  18. $(this).html(parseInt(b.pos * opts.lastNumber));
  19. }
  20. });
  21. }
  22. })(jQuery);
  23. $(document).ready(function(){
  24. function loadVideo(){
  25. if($(".indexShowVideo").length > 0){
  26. var indexPlayer = videojs('indexVideo');
  27. videojs("indexVideo").ready(function () {
  28. var indexPlayer = this;
  29. indexPlayer.play();
  30. });
  31. }
  32. }
  33. loadVideo();
  34. // videoSize();
  35. // scaleWindow();
  36. indexFullPage();
  37. indexBanner();
  38. videoSwiper();
  39. indexBannerSize();
  40. noticeSlide();
  41. groupSlide();
  42. linkConWidth();
  43. gtBrowser();
  44. if($(".index-banner").length > 0){
  45. var _src = $(".index-banner .swiper-slide-active").find("img").attr('src');
  46. $(".left-nav").css({'background':'url('+_src+') no-repeat'})
  47. function videoSize(){
  48. // var winWidth = $(window).width()+200; //浏览器宽度
  49. // var winHeight = $(window).height()+200; //浏览器高度
  50. var _W = $(".indexShowVideo-con").find(".opcity").width()+100;
  51. var _h = $(".indexShowVideo-con").find(".opcity").height()+100;
  52. $(".indexShowVideo").find("video").css({'width':_W,'height':_h});
  53. $("#indexVideo").css({'width':_W,'height':_h,'margin-top':-_h/2,'margin-left':-_W/2});
  54. }
  55. videoSize();
  56. $(window).resize(function(){
  57. videoSize();
  58. })
  59. }
  60. if($(".videoCenter").length > 0){
  61. var indexPlayer = videojs('video1');
  62. videojs("video1").ready(function () {
  63. var indexPlayer = this;
  64. // this.play();
  65. });
  66. $(".v-wrap").click(function(){
  67. $(".indexShowVideo").fadeOut();
  68. })
  69. }
  70. });
  71. $(window).resize(function(){
  72. indexBannerSize();
  73. linkConWidth();
  74. });
  75. //fullpage
  76. function indexFullPage(){
  77. $("#fullpage").fullpage({
  78. anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'fifthPage','sixPage','seventhPage','eighthPage'],
  79. menu: '#menu',
  80. scrollingSpeed:400,
  81. navigation:true,
  82. navigationPosition:'right',
  83. css3:true,
  84. fitToSection: true,
  85. resize : false,
  86. verticalCentered:false,
  87. onLeave: function(anchorLink, index){
  88. $(".nav-goTop .redLine").height(15*index+'px');
  89. if(index === 1){
  90. $(".nav-goTop .redLine").height(0);
  91. $(".headerCon").addClass("animation");
  92. $("#fullpage .section#section1").css('overflow','inherit')
  93. }else if(index === 6){
  94. var _txt1 = $(".counter1").attr('data-val');
  95. var _txt2 = $(".counter2").attr('data-val');
  96. var _txt3 = $(".counter3").attr('data-val');
  97. var _txt4 = $(".counter4").attr('data-val');
  98. var _txt5 = $(".counter5").attr('data-val');
  99. $(".counter1").numberRock({
  100. lastNumber:_txt1,
  101. duration:2000,
  102. easing:'swing',
  103. });
  104. $(".counter2").numberRock({
  105. lastNumber:_txt2,
  106. duration:2000,
  107. easing:'swing',
  108. });
  109. $(".counter3").numberRock({
  110. lastNumber:_txt3,
  111. duration:2000,
  112. easing:'swing',
  113. });
  114. $(".counter4").numberRock({
  115. lastNumber:_txt4,
  116. duration:2000,
  117. easing:'swing',
  118. });
  119. $(".counter5").numberRock({
  120. lastNumber:_txt5,
  121. duration:2000,
  122. easing:'swing',
  123. });
  124. }else{
  125. $(".headerCon").removeClass("animation");
  126. }
  127. if(index>1){
  128. $(".left-nav").addClass("fixed");
  129. }else{
  130. $(".left-nav").removeClass("fixed");
  131. }
  132. },
  133. afterLoad: function(anchorLink, index){
  134. if(index === 1){
  135. $(".headerCon").addClass("animation");
  136. }else{
  137. $(".headerCon").removeClass("animation");
  138. $("#fullpage .section#section1").css('overflow','hidden')
  139. }
  140. }
  141. });
  142. }
  143. function num(){
  144. $(".counter").each(function(){
  145. $(this).prop('counter',0).animate({
  146. Crs:$(this).text()
  147. },{
  148. duration:2000,
  149. easing:'swing',
  150. step:function(now){
  151. console.log(now)
  152. $(this).text(Math.ceil(now));
  153. }
  154. })
  155. })
  156. }
  157. //首页banner
  158. function indexBanner(){
  159. if($(".index-banner").length > 0){
  160. var swiper = new Swiper ('.index-banner .swiper-container', {
  161. pagination: '.index-banner .pagination',
  162. // nextButton: '.index-banner .arrow-right',
  163. // prevButton: '.index-banner .arrow-left',
  164. paginationClickable :true,
  165. autoHeight: true,
  166. autoplay:5000,
  167. noSwiping : true,
  168. speed:800,
  169. autoplayDisableOnInteraction : false,
  170. loop : true,
  171. onSlideChangeStart: function(swiper){
  172. var _src = $(".index-banner .swiper-slide-active").find("img").attr('src');
  173. // $("body").css('background','rgba(0, 0, 0, 0.6)'+_src);
  174. $(".left-nav").css('background','url('+_src+')')
  175. }
  176. })
  177. $(".index-banner .pagination").find("span").each(function(){
  178. var _index = $(this).index();
  179. $(this).html(_index + 1)
  180. })
  181. $('.index-banner .arrow-left').on('click', function(e){
  182. e.preventDefault()
  183. swiper.swipePrev()
  184. })
  185. $('.index-banner .arrow-right').on('click', function(e){
  186. e.preventDefault()
  187. swiper.swipeNext()
  188. })
  189. }
  190. }
  191. function videoSwiper(){
  192. if($(".videoCenter").length > 0){
  193. // var swiperVideo = new Swiper ('.videoCenter .swiper-container', {
  194. // pagination: '.videoCenter .pagination',
  195. // paginationClickable :true,
  196. // effect : 'cube',
  197. // autoHeight: true,
  198. // noSwiping : true,
  199. // noSwipingClass : 'stop-swiping',
  200. // speed:800,
  201. // paginationBulletRender: function (swiper, index, className) {
  202. // console.log(swiper)
  203. // return '<span class="' + className + '"><i></i>0' + (index + 1) + '</span>';
  204. // },
  205. // onSlideChangeEnd:function(swiper){
  206. // $(".videoCenter .swiper-slide").each(function(e){
  207. // var v_len = $(this).find("video").length;
  208. // for(var i = 0;i<v_len;i++){
  209. // $(this).find("video").get(i).pause(); //把所有停止
  210. // }
  211. // var _video = $(this).find("video.video-js");
  212. // _video.attr('src','');
  213. // $(this).removeClass('active');
  214. //
  215. // })
  216. //
  217. // }
  218. // })
  219. // $(".videoCenter .pagination").find("span").each(function(){
  220. // var _index = $(this).index();
  221. // $(this).html(_index + 1)
  222. // })
  223. // $('.videoCenter .arrow-left').on('click', function(e){
  224. // e.preventDefault()
  225. // swiperVideo.swipePrev()
  226. // })
  227. // $('.videoCenter .arrow-right').on('click', function(e){
  228. // e.preventDefault()
  229. // swiperVideo.swipeNext()
  230. // })
  231. $(".videoCenter .videoCon").each(function(){
  232. var _video = $(this).find("video.video-js");
  233. $(this).find(".v-playBtn").click(function(){
  234. $(this).hide();
  235. $(this).siblings(".video-js").addClass("active");
  236. var _src = $(this).attr('data-src');
  237. _video.attr('autoplay','autoplay');
  238. _video.attr('src',_src);
  239. _video.addClass('vjs-playing');
  240. })
  241. })
  242. }
  243. }
  244. function indexBannerSize(){
  245. var bannerImgObj = $(".dw-cont>img,.indexShowVideo-con>img"); //图片对象
  246. var winWidth = $(window).width(); //浏览器宽度
  247. var winHeight = $(window).height(); //浏览器高度
  248. bannerImgObj.each(function(){
  249. var _this = $(this);
  250. //_this.css({"width":"100%","left":"50%"});
  251. _this.css({"width":"100%"});
  252. getImageSize(_this.attr("src"),function(w,h){
  253. var ratio = w/h; //图片比例
  254. var showH = winWidth/ratio; //图片显示高度
  255. var newW; //新设置的图片宽度
  256. if(showH < winHeight){ //图片显示高度小于窗口高度
  257. newW = winHeight*ratio;
  258. _this.css({"height":"100%","width":newW});
  259. }else{
  260. newW = winWidth;
  261. _this.css({"width":"100%","height":"auto"});
  262. }
  263. //_this.css({"margin-left":"-"+newW/2+"px"});
  264. })
  265. });
  266. }
  267. //获取图片尺寸
  268. function getImageSize(url,callback){
  269. var img = new Image();
  270. img.src = url;
  271. // 如果图片被缓存,则直接返回缓存数据
  272. if(img.complete){
  273. callback(img.width, img.height);
  274. }else{
  275. // 完全加载完毕的事件
  276. img.onload = function(){
  277. callback(img.width, img.height);
  278. }
  279. }
  280. }
  281. function noticeSlide(){
  282. $(".txtScroll-top").slide({titCell:".hd ul",mainCell:".bd ul",autoPage:true,effect:"top",autoPlay:true,vis:1});
  283. }
  284. function groupSlide(){
  285. $(".picMarquee-left1,.picMarquee-left2").slide(
  286. {
  287. mainCell:".bd ul",
  288. autoPlay:true,
  289. effect:"leftMarquee",
  290. easing:"swing",
  291. vis:10,
  292. interTime:30
  293. }
  294. );
  295. $(".picMarquee-right1").slide(
  296. {
  297. mainCell:".bd ul",
  298. autoPlay:true,
  299. effect:"leftMarquee",
  300. easing:"swing",
  301. vis:10,
  302. opp:true,
  303. interTime:30
  304. }
  305. );
  306. imgScroll.rolling({
  307. name:'g1',
  308. width:'293px',
  309. height:'168px',
  310. direction:'left',
  311. speed:30,
  312. addcss:true
  313. });
  314. // $(".tempWrap").each(function(){
  315. // $(this).find("li").hover(function(){
  316. // $(this).find("span").hide();
  317. // $(this).find("img").css('z-index','9')
  318. // },function(){
  319. // $(this).find("span").show();
  320. // $(this).find("img").css('z-index','0')
  321. // })
  322. // })
  323. }
  324. function linkConWidth(){
  325. // var viewWidth=$(window).width();
  326. $(".nav-link").on('mouseenter',function(){
  327. var _width = $(".s1-con").width();
  328. $(".link-slideCon-wrap").width(_width);
  329. })
  330. $(".nav-link").on('mouseleave',function(){
  331. // var _width = $(".s1-con").width();
  332. $(".link-slideCon-wrap").width(0);
  333. })
  334. }
  335. function gtBrowser(){
  336. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  337. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
  338. var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
  339. var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
  340. if(isIE) {
  341. var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  342. reIE.test(userAgent);
  343. var fIEVersion = parseFloat(RegExp["$1"]);
  344. if(fIEVersion == 7) {
  345. console.log(fIEVersion)
  346. } else if(fIEVersion == 8) {
  347. console.log(fIEVersion)
  348. } else if(fIEVersion == 9) {
  349. console.log(fIEVersion)
  350. } else if(fIEVersion == 10) {
  351. console.log(fIEVersion)
  352. } else {
  353. console.log(fIEVersion)//IE版本<=7
  354. }
  355. } else if(isEdge) {
  356. console.log(isEdge)//edge
  357. } else if(isIE11) {
  358. console.log(isIE11) //IE11
  359. }else{
  360. // videoSwiper();
  361. // console.log("不是ie浏览器")//不是ie浏览器
  362. }
  363. }