$(function(){ // $(".h-menu").css("color","#333") function setPcM(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { $("body").addClass("mobile").removeClass("pc") }else{ $("body").addClass("pc").removeClass("mobile") } } setPcM() $(window).resize(function(){ setPcM() }) var bodyTop = $(window).scrollTop() var notScroll = false $(".h-menu").on("click",function(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { setMenu() } }) $(".h-menu").on("mouseenter",function(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { return } setMenu() }) function setMenu(){ var menu = $(".h-menu") if(menu.hasClass("active")){ closeHeader() }else{ showHeader() } } function closeHeader(){ var menu = $(".h-menu") $("header").removeClass("show-menu") menu.removeClass("active") $(".h-box").removeClass("show") menu.text("鑿滃崟") setHeader() notScroll = false if($("#forBug").length){ $("#forBug")[0].pause() } $(".a-video").each(function(){ $(this).attr("src",$(this).attr("data-url")) $(this).removeClass("hide") }) } function showHeader(){ var menu = $(".h-menu") $("header").addClass("show-menu") menu.addClass("active") $(".h-box").addClass("show") menu.text("鍏抽棴") $("header").removeClass("white") bodyTop = $(window).scrollTop() notScroll = true if($("#forBug").length){ $("#forBug")[0].pause() } $(".a-video").each(function(){ this.pause() $(this).attr("data-url",$(this).attr("src")) $(this).attr("src","") $(this).addClass("hide") }) } var hh = $(window).height() $(window).scroll(function(e){ if(notScroll){ $(window).scrollTop(bodyTop) } setAni() setHeader() }) function setAni(){ var a = $(this).scrollTop() $(".teaser,.lter,.rter").each(function(){ var b = $(this).offset().top var el = $(this) if(b-a50){ $("header").addClass("white") if($(".h-box").hasClass("show")){ $("header").removeClass("white") } }else{ $("header").removeClass("white") } } //鏄惁鏈変簩绾ц彍鍗曪紝鏈夋樉绀轰笅鎷夌澶 $(".h-sub").each(function(){ $(this).parents(".h-li").addClass("has-nav") }) $(".has-nav").click(function(e){ if($(this).hasClass("show")){ $(this).removeClass("show") $(this).find(".h-sub").slideUp(300) }else{ $(".has-nav").removeClass("show") $(this).addClass("show") $(".h-sub").slideUp(300) $(this).find(".h-sub").slideDown(300) } }) $(".has-nav").on("mouseenter",function(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { return } $(".has-nav").removeClass("show") $(this).addClass("show") $(".h-sub").stop().slideUp(300) $(this).find(".h-sub").stop().slideDown(300) }) $(".has-nav").on("mouseleave",function(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { return } $(this).removeClass("show") $(this).find(".h-sub").stop().slideUp(300) }) $("header").on("mouseleave",function(){ closeHeader() }) $(".h-sub").click(function(e){ e.stopPropagation() }) $(".has-nav a").each(function(){ if($(this).attr("href")=="/"){ $(this).css("cursor","default") $(this).click(function(e){ e.preventDefault() }) } }) //鐐瑰嚮閬僵灞 $(".h-mask").click(function () { $("header").removeClass("show-sch") }) //鐐瑰嚮鎼滅储 $(".h-search").click(function () { $("header").addClass("show-sch") setTimeout(function () { $(".h-text").focus() }, 300); }) //鐐瑰嚮鎵撳紑瑙嗛 $("[v-src]").click(function(e) { e.stopPropagation() $(".v-a").addClass("show") var src = $(this).attr("v-src") if (src.indexOf(".mp4") != -1) { $("#v2").attr("src", src) $("#v2").css("display", "block") $("#v1").css("display", "none") $("#v2")[0].play() } else { $("#v1").attr("src", src) $("#v1").css("display", "block") $("#v2").css("display", "none") } }) //鍏抽棴瑙嗛 $(".v-c").click(function() { if ($("#v2").length) { $(".v-a").removeClass("show") $("#v2")[0].pause() $("#v1").attr("src", "") } }) $(".v-a").click(function(e) { e.stopPropagation() }) //鐐瑰嚮璇█鎸夐挳 $(".h-lang").on("mouseenter click",function(e){ e.stopPropagation() $("header").addClass("show-lang") }) $(".h-lang").on("mouseleave",function(){ $("header").removeClass("show-lang") }) $("body").click(function(){ $("header").removeClass("show-lang") }) $(".h-lang-link").click(function(e){ e.stopPropagation() $("header").removeClass("show-lang") }) }) function goTop(){ $("html,body").animate({ scrollTop:0 },500,function(){}) } // 寮瑰嚭灞傜浉鍏 var hn = { dragging: false, dragX: 0, dragY: 0, dragEl: null, dragBox: null, dragMaxX: 0, dragMaxY: 0, dragHasSet: false, msg: function(text, el, fn) { var hnTip = $("#hnTip") if (!hnTip.length) { hnTip = $('
') $("body").append(hnTip) } hnTip.find(".hn-msg").html(text || '') setTimeout(function() { hnTip.addClass("show") }, 1) el = el || {} var time = el.time || 1500 setTimeout(function() { hnTip.removeClass("show") typeof el == 'function' && el() typeof fn == 'function' && fn() }, time) }, load: function(text, el, fn) { var hnLoad = $("#hnLoad") if (!hnLoad.length) { hnLoad = $('
') $("body").append(hnLoad) } hnLoad.find(".hn-load-title").html(text || '') setTimeout(function() { hnLoad.addClass("show") }, 1) el = el || {} var time = el.time || 360000 setTimeout(function() { hnLoad.removeClass("show") typeof el == 'function' && el() typeof fn == 'function' && fn() }, time) }, hideLoad: function() { $("#hnLoad").removeClass("show") }, confirm: function(el) { var hnConfirm = $("#hnConfirm") if (!hnConfirm.length) { hnConfirm = $('
鉁旤/div>
') $("body").append(hnConfirm) } hn.dragEl = hnConfirm.find(".hn-confirm-title") hn.dragBox = hnConfirm.find(".hn-confirm-dialog") hn.setDrag() hn.dragEl.text(el.title || '') hnConfirm.find(".hn-confirm-cont").text(el.content || '') var btns = hnConfirm.find(".hn-confirm-btns") btns.html('') if (el.btn.length) { for (var i = 0; i < el.btn.length; i++) { if (i == 0) { $('' + el.btn[i] + '').appendTo(btns) } else { $('' + el.btn[i] + '').appendTo(btns) } } } if (el.callback.length) { var cbtn = btns.find(".c-btn") for (var i = 0; i < el.callback.length; i++) { cbtn.eq(i).on("click", el.callback[i]) } } hn.dragBox.css({ left: ($(window).width() - hn.dragBox.outerWidth()) / 2, top: ($(window).height() - hn.dragBox.outerHeight()) / 2 }) setTimeout(function() { hnConfirm.addClass("show") }, 1) }, hideConfirm: function() { $("#hnConfirm").removeClass("show") }, open: function(el) { var hnHtml = $("#hnHtml") if (!hnHtml.length) { hnHtml = $('
鉁旤/div>
') $("body").append(hnHtml) } hn.dragEl = hnHtml.find(".hn-html-title") hn.dragBox = hnHtml.find(".hn-html-dialog") hn.setDrag() hn.dragEl.text(el.title || '') var cont = hnHtml.find(".hn-html-cont") cont.html(el.content || '') var area = el.area || [600, 338] cont.css({ width: area[0], height: area[1] - hn.dragEl.outerHeight() }) $(".hn-html-btns").remove() if (el.btn && el.btn.length) { var btns = $('
') for (var i = 0; i < el.btn.length; i++) { if (i == 0) { $('' + el.btn[i] + '').appendTo(btns) } else { $('' + el.btn[i] + '').appendTo(btns) } } hn.dragBox.append(btns) if (el.callback && el.callback.length) { var cbtn = btns.find(".c-btn") for (var i = 0; i < el.callback.length; i++) { cbtn.eq(i).on("click", el.callback[i]) } } } hn.dragBox.css({ left: ($(window).width() - hn.dragBox.outerWidth()) / 2, top: ($(window).height() - hn.dragBox.outerHeight()) / 2 }) setTimeout(function() { hnHtml.addClass("show") }, 1) }, hideOpen: function() { $("#hnHtml").removeClass("show") var table = $(".hn-html-cont .c-table") if(table.length){ table.addClass("hide") table.insertAfter($(".has-multi.active")) } }, //璁╁脊绐楀彲鎷栧姩 setDrag: function() { hn.dragEl.off("mousedown").on("mousedown", function(e) { hn.dragX = e.offsetX hn.dragY = e.offsetY hn.dragMaxX = $(window).width() - hn.dragBox.outerWidth() hn.dragMaxY = $(window).height() - hn.dragBox.outerHeight() hn.dragging = true }) if (hn.dragHasSet) { return } else { hn.dragHasSet = true } $(document).on("mousemove", function(e) { if (hn.dragging) { var x = e.pageX - hn.dragX - $(window).scrollLeft() var y = e.pageY - hn.dragY - $(window).scrollTop() x = x < 0 ? 0 : x y = y < 0 ? 0 : y x = x > hn.dragMaxX ? hn.dragMaxX : x y = y > hn.dragMaxY ? hn.dragMaxY : y hn.dragBox.css({ left: x, top: y }) } }) $(document).on("mouseup", function(e) { hn.dragging = false }) //灞忓箷瀹介珮鏀瑰彉鏃跺搷搴 $(window).resize(function(){ hn.dragBox.css({ left: ($(window).width() - hn.dragBox.outerWidth()) / 2, top: ($(window).height() - hn.dragBox.outerHeight()) / 2 }) }) } }