var indexTool = { updatePlatform: function () { var $W = $(window).width(); if($W<1024){ $(".body_home").removeClass("showdiv") } var isMobile = /android|iphone|ipad|ipod/g.test(window.navigator.userAgent.toLowerCase()) || $(window).width() <= 1024; var isMac = /mac os x/g.test(window.navigator.userAgent.toLowerCase()); if (isMobile) { $("body").addClass("mobile").removeClass("pc"); } else { $("body").addClass("pc").removeClass("mobile"); } }, //首页动画 indexMoveFn: function (that) { if ($(".ejbody_b").hasClass("showdiv")) { setTimeout(function () { // $(".indexnewsOut").attr("data-faded", true); $(".indexnewsOut").addClass("show") }, 350) } var selector = $(".show-in, .fade-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-right, .fade-in-down"); try { if (that && that.length != 0) selector.each(function () { var _this4 = $(this); setTimeout(function () { that.find(_this4).addClass("show") }, 250) }) } catch (error) { console.log(error) } } } $(function () { $(".indexProductList .item .iconBox").each(function(){ var _this = $(this); _this.on("click",function(){ var $W = $(window).width(); if($W<750){ if(_this.parents(".item").hasClass("active")){ _this.parents(".item").removeClass("active") }else{ $(".indexProductList .item").removeClass("active"); _this.parents(".item").addClass("active") } } }) }) var $W = $(window).width(); if($W<1024){ $(".body_home").removeClass("showdiv") } $(window).on("resize", indexTool.updatePlatform); indexTool.updatePlatform() //华润电子股票 window.crcHqInfo = JSON.parse(JSON.stringify(crcHq)); console.log("crcHqInfo",crcHqInfo); var crmstock = { stock:function(tar){ if(!Object.getOwnPropertyNames || !Object.keys){ Object.keys = Object.getOwnPropertyNames = function(temp){ var A = []; for(var key in temp){ A.push(key); } return A; } } //forEach 鏂规硶 if ( !Array.prototype.forEach ) { Array.prototype.forEach = function forEach( callback, thisArg ) { var T, k; if ( this == null ) { throw new TypeError( "this is null or not defined" ); } var O = Object(this); var len = O.length >>> 0; if ( typeof callback !== "function" ) { throw new TypeError( callback + " is not a function" ); } if ( arguments.length > 1 ) { T = thisArg; } k = 0; while( k < len ) { var kValue; if ( k in O ) { kValue = O[ k ]; callback.call( T, kValue, k, O ); } k++; } }; } if (crcHqInfo != null && typeof crcHqInfo != 'undefinded') { console.log("cccc",crcHqInfo); if($(".stockLef1") && $(".stockLef1").length!=0){ $("#stock-name").html(crcHqInfo[0].stockCode); $("#stock-price").html(crcHqInfo[0].currentPrice); $("#stock-open").html(crcHqInfo[0].openToday); $("#stock-yesterday").html(crcHqInfo[0].closeYesterday); $("#stock-rise").html(crcHqInfo[0].rise+'%'); $("#stock-change").html(crcHqInfo[0].change); if(crcHqInfo[0].openToday==0){ $("#stock-open,.crm-news-stock-sub").hide(); } $("#stock-cjl").html(crcHqInfo[0].volume/10000); $("#stock-cje").html(crcHqInfo[0].turnover/10000); $("#stock-low").html(crcHqInfo[0].floorPrice); $("#stock-high").html(crcHqInfo[0].topPrice); var time = (crcHqInfo[0].stockDate).replace(/\//g,"-"); time = time + ' ' +crcHqInfo[0].stockTime; $("#stock-time").html(time); // var allStock = ($("#stock-zsz").attr("data-num")*(crcHqInfo[0].closeYesterday)).toFixed(2); var allStock = ($("#stock-zsz").attr("data-num")*(crcHqInfo[0].currentPrice)).toFixed(2); $("#stock-zsz").html(allStock); if(1*(crcHqInfo[0].change)>0){ $("#stock-rise,#stock-change,#stock-price,.stockPrice span").css("color","#e60012"); $(".stockPercentage .up").show() $(".stockPercentage .down").hide() } else{ $("#stock-rise,#stock-change,#stock-price,.stockPrice span").css("color","#25CC6D"); $(".stockPercentage .up").hide() $(".stockPercentage .down").show() } if(1*(crcHqInfo[0].change)<0){ $("#stock-price").addClass("green"); } else{ $("#stock-price").addClass("red"); } } } else { //stockInfoNode.hqtime.html('鏁版嵁鍔犺浇澶辫触!').addClass("load-error"); } } } function myinit(){ crmstock.stock($(".wdzStock")); } myinit(); //主力产品 $(".indexItem1 .searchTab .item").click(function () { $(this).addClass("active").siblings().removeClass("active"); var index = $(this).index(); console.log(index) $(".indexProductList_out").hide().eq(index).show(); }) //应用领域 var mAppListBoxSwiper = new Swiper(".mAppListBoxSwiper", { slidesPerView: "auto", spaceBetween: 16, // loop:true, breakpoints:{ 640: { slidesPerView: "auto", spaceBetween: 16, }, 750: { slidesPerView:3.5, spaceBetween: 20 }, 880: { slidesPerView:4.5, spaceBetween: 30 }, 980: { slidesPerView:5.5, spaceBetween: 40 } } }); $(".indexItem2 .indexAppTab .item").click(function () { // var _$ww = $(window).width(),appBg; // if(_$ww>880){ // appBg = $(this).attr('data-bg') // }else{ // appBg = $(this).attr('data-bg2') || $(this).attr('data-bg') // } // $(this).addClass("active").siblings().removeClass("active"); // var index = $(this).index(); // $(".indexAppContainer .item").hide().eq(index).show(); // $(".indexItem2 .wdzApplication .list_in").hide().eq(index).show(); // $(".indexItem2").css("background-image", "url("+ appBg +")") var bg1 = $(this).attr('data-bg') var bg2 = $(this).attr('data-bg2') || $(this).attr('data-bg') var index = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); appFn(bg1,bg2, index) }) $(".mAppListBox .swiper-slide").click(function () { var bg1 = $(this).attr('data-bg') var bg2 = $(this).attr('data-bg2') || $(this).attr('data-bg') var index = $(this).attr('data-n') $(this).addClass("active").siblings().removeClass("active"); appFn(bg1,bg2, index) }) function appFn(bg1,bg2, index){ console.log("bg1",bg1,bg2,index) var _$ww = $(window).width(),appBg; if(_$ww>880){ appBg = bg1 }else{ appBg = bg2 } $(".indexAppContainer .item").hide().eq(index).show(); $(".indexItem2 .wdzApplication .list_in").hide().eq(index).show(); $(".indexItem2").css("background-image", "url("+ appBg +")") } //index banner var indexBannerSwiper = new Swiper('.ejIndexBanner .swiper-container', { pagination: { // type : 'custom', el: '.swiper-pagination', // renderBullet: function (index, className) { // return '' + (index + 1) + ''; // }, }, autoplay: { delay: 8000, stopOnLastSlide: false, disableOnInteraction: true, }, on: { init: function (swiper) { var videoUrl = $(".ejIndexBanner .swiper-container .swiper-slide-active").find(".indexBg").attr("data-video2") if (videoUrl && videoUrl.length != "" && $W > 750) { $(".ejIndexBanner .swiper-container .swiper-slide-active .indexVideoBox video").attr("src", videoUrl).get(0).play() } }, transitionEnd: function (current, total) { if ($W > 750) { $(".ejIndexBanner .swiper-container .swiper-slide .indexVideoBox video").attr("src", "") var videoUrl = $(".ejIndexBanner .swiper-container .swiper-slide-active").find(".indexBg").attr("data-video2") if (videoUrl && videoUrl.length != "") { $(".ejIndexBanner .swiper-container .swiper-slide-active .indexVideoBox video").attr("src", videoUrl).get(0).play() } } }, } }); $('.video-play').click(function (e) { var vUrl = $(this).attr("data-url") var vImg = $(this).attr("data-poster") // var video = $(".indexbanner_video") var video = $(".videopup_videoBox video") video.attr("src", "") console.log("vUrl", vUrl) if (vUrl && vUrl != "") { $(".videoPup").addClass("active") if ($W > 750) { $(".ejIndexBanner .swiper-container .swiper-slide-active .indexVideoBox video").get(0).pause() $(".ejIndexBanner .swiper-container .swiper-slide-active .indexVideoBox video").get(0).currentTime = 0; } // video.pause() playVideo({ "vUrl": vUrl, "vImg": vImg }); } }); $('.closeVideoPup').click(function (e) { closeBannerVideoFn() }) // 监听键盘按下事件 document.addEventListener('keydown', function (e) { // 检查按键是否为ESC if (e.key === "Escape" || e.keyCode === 27) { closeBannerVideoFn() } }); function closeBannerVideoFn() { if ($(".videoPup").hasClass("active")) { $(".videoPup").removeClass("active") indexBannerSwiper.autoplay.start() $(".videopup_videoBox video").attr("src", "").attr("poster", "") if ($W > 750) { var videoUrl = $(".ejIndexBanner .swiper-container .swiper-slide-active").find(".indexBg").attr("data-video2") $(".ejIndexBanner .swiper-container .swiper-slide-active .indexVideoBox video").attr("src", videoUrl).get(0).play() } } } function playVideo(data) { indexBannerSwiper.autoplay.stop() $(".videopup_videoBox video").attr("src", data.vUrl).attr("poster", data.vImg) } var galleryThumbs = new Swiper('.mSearchTab .swiper-container', { spaceBetween: 40, slidesPerView: "auto", on:{ click:function(){ var _index = this.clickedIndex; $(".mSearchTab .item").removeClass("active"); $(".mSearchTab .swiper-container .swiper-slide").eq(_index).find(".item").addClass("active"); $(".indexProductListOut .indexProductList_out").hide().eq(_index).show(); } } }); // item3 var galleryThumbs_3 = new Swiper('.indexItem3 .gallery-thumbs', { spaceBetween: 20, slidesPerView: "auto", freeMode: true, watchSlidesVisibility: true, watchSlidesProgress: true, breakpoints: { 768: { //当屏幕宽度大于等于768 spaceBetween: 20, slidesPerView: 4, }, 1280: { //当屏幕宽度大于等于1280 spaceBetween: 48, slidesPerView: 'auto' }, 1380: { //当屏幕宽度大于等于1280 spaceBetween: 68, slidesPerView: 'auto' }, 1480: { //当屏幕宽度大于等于1280 spaceBetween: 88, slidesPerView: 'auto' } } }); var galleryTop_3 = new Swiper('.indexItem3 .gallery-top', { centeredSlides: true, // slidesPerView: 'auto', // loop: true, // allowTouchMove: false, // autoplay: { // delay: 5000, // stopOnLastSlide: false, // // disableOnInteraction: true, // disableOnInteraction: false, // }, spaceBetween: 10, navigation: { nextEl: '.sw_next', prevEl: '.sw_prev', }, thumbs: { swiper: galleryThumbs_3 } }); var galleryTop_3_1 = new Swiper('.indexItem3 .gallery-top2', { slidesPerView: "auto", centeredSlides: true, loop: true, spaceBetween: 10, navigation: { nextEl: '.sw_next', prevEl: '.sw_prev', }, thumbs: { swiper: galleryThumbs_3 } }); var galleryTop_3_2 = new Swiper('.indexItem3 .gallery-top3', { slidesPerView: 1, centeredSlides: true, loop: true, loopAdditionalSlides:2, spaceBetween: 20, autoplay: { // delay: 10000, delay: 8000000, stopOnLastSlide: false, // disableOnInteraction: true, disableOnInteraction: false, }, navigation: { nextEl: '.sw_next', prevEl: '.sw_prev', }, thumbs: { swiper: galleryThumbs_3 }, breakpoints: { 640: { //当屏幕宽度大于等于768 slidesPerView: 1, spaceBetween: 80, }, 750: { //当屏幕宽度大于等于768 spaceBetween: 100, }, 880: { //当屏幕宽度大于等于768 spaceBetween: 160, }, 980: { //当屏幕宽度大于等于768 spaceBetween: 220, }, 1280: { //当屏幕宽度大于等于1280 spaceBetween: 220, } } }); var indexNewsList = new Swiper('.indexNewsList .swiper-container', { slidesPerView: 3, spaceBetween: 60, navigation: { nextEl: '.news_next', prevEl: '.news_prev', }, scrollbar: { el: '.swiper-scrollbar', // hide: true, } }); var startX,startY; $(".body_home").on("touchstart", function (e) { var $W = $(window).width(); if($W<1024){ return } // $(".m_collect .m_item_in").removeClass("itemMove") if (e.cancelable) { // 判断默认行为是否已经被禁用 if (!e.defaultPrevented) { // e.preventDefault(); } } startX = e.originalEvent.changedTouches[0].pageX, startY = e.originalEvent.changedTouches[0].pageY; }) $(this).on("touchend", function (e) { var $W = $(window).width(); if($W<1024){ return } // 判断默认行为是否可以被禁用 if (e.cancelable) { // 判断默认行为是否已经被禁用 if (!e.defaultPrevented) { // e.preventDefault(); } } moveEndX = e.originalEvent.changedTouches[0].pageX, moveEndY = e.originalEvent.changedTouches[0].pageY, X = moveEndX - startX, Y = moveEndY - startY; console.log("xy", X, Y) if (Y > 0) { console.log("down") var $W = $(window).width(); if($W<1024){ return false; } if ($(".ejbody_b").scrollTop() <= 0) { $(".body_home").addClass("showdiv"); $(".ejbody_b").removeClass("showdiv"); } } else if (Y < -100) { $(".bb").click(); console.log("up") } else { console.log("0000") } }) $(".body_home").mousewheel(function (event, delta, deltaX, deltaY) { if (delta < 0) { // var $W = $(window).width(); // if($W<1024){ // return false; // } $(".bb").click(); $(".ejbody_b").addClass("showdiv"); } indexTool.indexMoveFn() }); $(".ejbody_b").mousewheel(function (event, delta, deltaX, deltaY) { var $W = $(window).width(); if($W>1024){ if (delta > 0 && $(".ejbody_b").scrollTop() == 0) { $(".body_home").addClass("showdiv"); $(".ejbody_b").removeClass("showdiv"); } } }); $(".bb").click(function () { $(".ejbody_b").addClass("showdiv"); $(".header").addClass("mobile"); setTimeout(function () { $(".body_home").removeClass("showdiv"); $(".home5").addClass("showdiv"); }, 500); }) $(".ejbody_b").scroll(function () { var $W = $(window).width(); if($W<1024){ return false; } $(".indexItem").each(function (index, element) { var e = $(this); var fix = parseInt(e.attr("fix")); if (!fix && fix != 0) { fix = $(window).height() * 6 * 0.1; } else { fix = $(window).height() * fix * 0.1; } if ($(window).scrollTop() >= $(e).offset().top - fix) { if (!$(e).hasClass("showdiv")) { $(e).addClass("showdiv"); if ($(this).hasClass("indexItem4")) { $("*[count-up-to-p]").each(function () { $(this).html($(this).attr("count-up-to-p")); try { if ($(this).data("countup")) { $(this).data("countup").pauseResume(); } window.counterUp["default"](this, { duration: 1500, delay: 50 }); } catch (error) { console.log(error) } }); } indexTool.indexMoveFn($(e)) } } else { if ($(e).hasClass("showdiv")) { $(e).removeClass("showdiv"); } } }); }); // 首页主力产品搜索 $(".productSearchBtn a").off().on("click",function(){ var keyword = $(".indexproductSearchBox_in .inputBox input").val(); if(keyword.trim()==""){ return false; } $(this).attr("href", $(this).attr("data-url") + '?keyword='+encodeURI($.trim(keyword))); $(".indexproductSearchBox_in .inputBox input").val(""); // var _Url = $(this).attr("data-url") + '?keyword='+encodeURI($.trim(keyword)) window.open($(this).attr("href")); }) // $(".body_home .indexTopHeader").hover(function(){ // var $W = $(window).width(); // if($W>980){ // if(!$(".ejbody_b").hasClass("showdiv")){ // setTimeout(function(){ // $(".body_home").removeClass("showdiv"); // },2) // } // } // },function(){ // if($W>980){ // if(!$(".ejbody_b").hasClass("showdiv")){ // setTimeout(function(){ // $(".body_home").addClass("showdiv"); // },2) // } // } // }) // $(".proMenuBox").hover(function(){ // if(!$(".ejbody_b").hasClass("showdiv")){ // setTimeout(function(){ // $(".body_home").removeClass("showdiv"); // },2) // } // },function(){ // if(!$(".ejbody_b").hasClass("showdiv")){ // setTimeout(function(){ // $(".body_home").addClass("showdiv"); // },2) // } // }) $(".proMenuBox").hover(function(){ setTimeout(function(){ $(".body_home").removeClass("showdiv"); },2) },function(){ var $W2 = $(window).width(); if($W2>1024){ if(!$(".body_home").hasClass("whitePage")){ setTimeout(function(){ $(".body_home").addClass("showdiv"); },2) } } }) })