var sto_nav; var $win = $(window).width(); var $hei = $(window).height(); console.log($win, "---", $hei) // alert($win) var shareModel = { sinaWeiBo: function (title, pic) { var param = { url: window.location.href, type: '3', count: '1', appkey: '2890110694', title: title || '', pic: pic || '', ralateUid: '', rnd: new Date().valueOf() } var temp = ''; for (var p in param) { if (p) { temp += p + "=" + encodeURIComponent(param[p]) || '' temp += "&" } } var targetUrl = 'http://service.weibo.com/share/share.php?' + temp; window.open(targetUrl, 'sinaweibo', 'height=430, width=400'); }, linkUrl: function () { //鎷垮埌鎯宠澶嶅埗鐨勫€ let url = window.location.href; //鍒涘缓input鍏冪礌 let copyInput = document.createElement('input'); copyInput.setAttribute('class', 'copyinput') //鍚戦〉闈㈠簳閮ㄨ拷鍔犺緭鍏ユ document.body.appendChild(copyInput); //娣诲姞灞炴€э紝灏唘rl璧嬪€肩粰input鍏冪礌鐨剉alue灞炴€ copyInput.setAttribute('value', url); //閫夋嫨input鍏冪礌 copyInput.select(); //鎵ц澶嶅埗鍛戒护 document.execCommand("Copy"); //寮瑰嚭鎻愮ず淇℃伅锛屼笉鍚岀粍浠跺彲鑳藉瓨鍦ㄥ啓娉曚笉鍚 // this.$message.success("閾炬帴宸插鍒讹紒"); // event.preventDefault(); // event.stopPropagation(); //澶嶅埗涔嬪悗鍐嶅垹闄ゅ厓绱狅紝鍚﹀垯鏃犳硶鎴愬姛璧嬪€ //鍒犻櫎鍔ㄦ€佸垱寤虹殑鑺傜偣 copyInput.remove(); return $.growl.notice({ title: "", message: "閾炬帴宸插鍒讹紒" }); } } var tools = { bannerTab: function (tar) { var t if (tar && tar != "") { var nightBanner = tar.find("img").attr("data-nighttime") var dayBanner = tar.find("img").attr("data-daytime") if (nightBanner != "") { t = setInterval(function () { var nowDate = new Date().getHours() if (nowDate >= 6 && nowDate < 18) { tar.find("img").attr("src", dayBanner) clearInterval(t) } else { tar.find("img").attr("src", nightBanner) clearInterval(t) } }, 0) } else { tar.find("img").attr("src", dayBanner) } } }, scrollDiy: function (tar) { if (tar && tar.length > 0) { $(".ybscroll").mCustomScrollbar({ scrollButtons: { enable: false } }); } }, htmlsize: function () { var dw = 750; var ww = $(window).width(); console.log("w", ww) var maxw = 1920; var minw = 320; if ($(window).width() > maxw) { ww = maxw; } else if ($(window).width() < minw) { ww = minw; } $("html").css({ fontSize: Math.floor((ww / dw) * 100) }); }, // debounce: function (fn, delay = 200) { // let timer = null // return function (...args) { // if (timer) { // clearTimeout(timer) // timer = null // } // timer = setTimeout(() => { // fn.apply(this, args) // clearTimeout(timer) // timer = null // }, delay) // } // }, fHeader: function (tar) { if (tar && tar != "") { $(tar).mousewheel(function (event, delta, deltaX, deltaY) { if (delta > 0 && $(tar).scrollTop() >= 0) { $(".body_page").addClass("showdiv") } else { $(".body_page").removeClass("showdiv") } }); } }, navHover: function (tar) { if (!$(tar)) { return } $(tar).hover(function () { if ($(this).index() == 0) { return; } clearTimeout(sto_nav); $(".ejnav_child .item").removeClass("active"); $(tar).removeClass("active"); var ol = $(this).parents(".deMenu").offset().left; var al = $(this).offset().left + $(this).outerWidth() * 0.5; var fl = al - ol; var c = $(this).parents(".deMenu").find(".ejnav_child").find(".item").eq($(this).index()); var cl = fl - c.outerWidth() * 0.5; // if (c.find("").size() == 0) { // c.hide(); // } if (cl < 0) { c.css("left", 0); } else if (cl + c.outerWidth() > $(this).parents(".deMenu").outerWidth()) { c.css("right", 0); } else { c.css("left", cl); } $(this).addClass("active"); c.addClass("active"); }, function () { sto_nav = setTimeout(function () { $(".ejnav_child .item").removeClass("active"); $(tar).removeClass("active"); }, 100); }); }, childHover: function (tar) { $(tar).hover( function () { clearTimeout(sto_nav); }, function () { $(tar).removeClass("active"); $(".ejMenuBox a").removeClass("active"); } ); }, viewMap: function (tar, target, type) { if (tar && tar != "") { $(tar).on(type, function () { if (tar == ".ybSearchClose") { tools.iconTap(true) } if ($(target).hasClass("active")) { $(target).removeClass("active") if (target == ".ybSearchBox") { $(".topHeader .ybContainer_in ").removeClass("whiteBg") } } else { $(target).addClass("active") if (target == ".ybSearchBox") { $(".topHeader .ybContainer_in ").addClass("whiteBg") } } }) } }, showActive: function (tar) { if (tar && tar != "") { $(".mNavBox .m_a3").each(function () { if ($(this).hasClass("active")) { $(this).parents(".mItem").find(".m_a2").addClass("active") } }) } }, removeClass: function (tar, target, type) { if (tar && tar != "") { $(tar).on(type, function () { $(target).removeClass("active") }) } }, // 鎼滅储鏂规硶 singleSearch: function (tar) { if (tar && tar.length != 0) { var defHref = tar.attr("href"); tar.on("click", function (e) { if ($("#textfield").val() == "" || $("#textfield").val() == null) { $("#textfield").val(""); } //鏍稿績浠g爜锛屾嫾鎺ュ弬鏁 var args = "siteIds=" + window.btoa(tar.attr("data-siteIds")) + "&excludeCategoryId=" + window.btoa(tar.attr("data-excludeCategoryId")) + "&dataUrl=" + window.btoa(tar.attr("data-url")) + "&keyword=" + encodeURI(encodeURI($.trim($("#textfield").val()))); //鏍稿績浠g爜锛屾嫾鎺ュ弬鏁 end tar.attr("href", defHref + '#' + args); $("#searchword").val(""); // window.open(tar.attr("href")); $(".rqSearchBox,.closeSearchBox").hide(); $(".showSearchBox").css("display", "inline-block") // $(".hr-search-mask").show(); $("#textfield").val(""); }); $("#textfield").keyup(function (e) { if (e.keyCode == 13) { if ($("#textfield").val() == "" || $("#textfield").val() == null) { $("#textfield").val(""); } else { tar.trigger("click"); window.open(tar.attr("href")); } } }); } }, fLink: function (tar) { if (tar && tar != "") { $(tar).hover(function () { $(".flinkListBox").addClass("active") }, function () { $(".flinkListBox").removeClass("active") }) } }, mNavBox: function (tar, t2, fl) { if (tar && tar != "") { tar.on("click", function () { if (fl) { t2.addClass("active") } else { t2.removeClass("active") } }) } }, mNavClick: function (tar) { if (tar && tar != "") { tar.each(function () { $(this).on("click", function () { if ($(this).hasClass("active")) { $(this).removeClass("active") } else { tar.removeClass("active") $(this).addClass("active") } }) }) } }, mHandleNav: function (tar) { if (tar && tar != "") { tar.on("click", function () { var pTop = tar.offset().top - $(window).scrollTop() if ($(".mNavList").hasClass("active")) { $(".mNavList,.ejpupBpx").removeClass("active") $(".ejpupBpx").css({ "top": 0 }) $("html,body").css({ "height": "auto", "overflow": "auto" }) } else { $(".mNavList,.ejpupBpx").addClass("active") $(".ejpupBpx").css({ "top": pTop + 40 }) $("html,body").css({ "height": "100%", "overflow": "hidden" }) } }) } }, /* 鎼滅储icon鍒囨崲 */ iconTap: function (bl) { var bg = "url(" + $(".mSearchBtn").attr("data-imgbg") + ")" if (bl) { $(".mSearchBtn i").removeClass("icon-gongjulan-tubiao-guanbi").addClass("icon-gongjulan-tubiao-sousuo") $(".mSearchBtn").css("background-image", "none") } else { $(".mSearchBtn i").removeClass("icon-gongjulan-tubiao-sousuo").addClass("icon-gongjulan-tubiao-guanbi") $(".mSearchBtn").css("background-image", bg) } }, // 閫傞厤瀵艰埅鏄剧ず涓庨殣钘 mtopBtn: function () { $(".ybmHeader .ybmHeader_in .mSearchBtn").click(function (e) { e.stopPropagation() if ($(".ybSearchBox").hasClass("active")) { $(".ybSearchBox").removeClass("active") tools.iconTap(true) return false } else { $(".ybSearchBox").addClass("active") tools.iconTap(false) return false } }) $(".ybmHeader .mNavBtn").click(function () { var $win = $(window).width(); if ($win > 860) { $(".pubMap").addClass("active") } else { $(".mNavBox").addClass("active") } }) }, ybSwiperHistory: function (tar) { // 鍙戝睍鍘嗙▼ if (tar && tar != "") { try { var proSwiper = new Swiper('.pro-swiper', { slidesPerView: 4, watchSlidesVisibility: true, }); } catch (e) { console.log(e) } var mySwiper = new Swiper('.ybHistory_swiper', { slidesPerView: 1, spaceBetween: 40, simulateTouch: false, thumbs: { swiper: proSwiper }, breakpoints: { 640: { slidesPerView: 1, spaceBetween: 30 }, 750: { slidesPerView: 2, spaceBetween: 30 }, 860: { slidesPerView: 3, spaceBetween: 30 }, 1000: { slidesPerView: 4, spaceBetween: 20 }, 1200: { slidesPerView: 4, spaceBetween: 40 } } }); var swiper = new Swiper('.imgs_swiper', { slidesPerView: 1, spaceBetween: 0, autoplay: true, pagination: { el: '.swiper-pagination', clickable: true, }, }); var num = 0; $(".bb-wrap").removeClass("bb-sel"); $(".bb-wrap").eq(num).addClass("bb-sel"); if (num == 0) { $(".h_prev").addClass("bb-dis"); } $(".h_prev").on("click", function () { $(".h_next").removeClass("bb-dis"); if (num <= 0) { num = 0; $(".h_prev").addClass("bb-dis"); mySwiper.slideTo(0); return false; } else { if (num == 1) { $(".h_prev").addClass("bb-dis"); } mySwiper.slidePrev(); } num--; $(".bb-wrap").removeClass("bb-sel"); $(".bb-wrap").eq(num).addClass("bb-sel"); }); $(".h_next").on("click", function () { $(".h_prev").removeClass("bb-dis"); if (num >= $(".bb-wrap").length - 1) { $(".h_next").addClass("bb-dis"); return false; } else { if (num >= $(".bb-wrap").length - 2) { $(".h_next").addClass("bb-dis"); } mySwiper.slideNext(); } num++; $(".bb-wrap").removeClass("bb-sel"); $(".bb-wrap").eq(num).addClass("bb-sel"); }); $(".bb-wrap").each(function (index) { $(this).on("click", function () { $(".bb-wrap").removeClass("bb-sel"); $(".bb-wrap").eq(index).addClass("bb-sel"); num = index; if (index == 0) { $(".h_next").removeClass("bb-dis"); $(".h_prev").addClass("bb-dis"); } else if (index == $(".bb-wrap").length - 1) { $(".h_prev").removeClass("bb-dis"); $(".h_next").addClass("bb-dis"); } else { $(".h_prev").removeClass("bb-dis"); $(".h_next").removeClass("bb-dis"); } }); }); } // 鍙戝睍鍘嗙▼ END }, // 鍝佺墝涓庝骇鍝 brandFn: function () { $(".leftList .item").each(function () { $(this).on("click", function () { var num = $(this).index(); $(".leftList .item").removeClass("active") $(this).addClass("active") $(".rightImgs a").removeClass("active").eq(num).addClass("active") }) }) $(".ybProduct_in .item_in").click(function () { var title = $(this).attr("data-title").substring(0, 15) var cover = $(this).attr("data-cover") var html = $(this).find(".itemHtml").html() $(".popContainer_in .imgs img").attr("src", cover) $(".popContainer_in .title").text(title) $('.popContainer_in .popUpTxt .txt').html(html) $(".popUpBox").show() }) $(".popContainer_out .closePopBt i").click(function () { $(".popUpBox").hide() }) $(".drinkClassTab a").click(function () { var _this = $(this).index() $(".drinkClassTab a").removeClass("active").eq(_this).addClass("active") $(".drinkClass_txt .item").hide().eq(_this).show(); }) }, // 鎷涙爣涓撳尯 鎶ュ悕鐘舵€ BiddingArea: function (tar) { if (tar && tar != "") { nowTime = new Date().getTime() $(".ybCGInformation_Table .typeBox .v").each(function () { var effective_date = $(this).attr("data-time") var effective_date_str = new Date(effective_date).getTime() console.log("-time-", effective_date_str, effective_date_str) if (effective_date != "") { if (effective_date_str > nowTime) { $(this).text("姝e湪鎶ュ悕").addClass("attend") } else { $(this).text("鎶ュ悕缁撴潫") } } else { $(this).text("---------") } }) } } } var tool750 = { fCodeFn: function (c, t) { c.hover(function () { c.find(t).css({ "opacity": 1, "transform": "none", "visibility": "visible" }) }, function () { c.find(t).css({ "opacity": 0, "transform": "translateY(-50px)", "visibility": "hidden" }) }) }, footerNav: function () { $(".fmenuList .item h3").on("click", function () { $(this).siblings(".item_a").toggle() }) }, fCodeHover: function () { $(".fFollowUs .list .item").each(function () { tool750.fCodeFn($(this), ".imgs") }) }, mNavSwiperFn: function (tar) { var mNavSwiper = new Swiper('.mNavSwiper', { // slidesPerView: 4.2, slidesPerView: "auto", spaceBetween: 0, initialSlide: $(".ybmNav .mshow .swiper-slide a.active").attr("data-num"), }); } } tools.htmlsize(); $(window).resize(tools.htmlsize); $(function () { $(".counter").each(function () { $(this).numberRock({ lastNumber: $(this).text(), duration: 5000, easing: 'swing', }) }) tools.htmlsize(); tools.navHover(".ejMenuBox a") tools.childHover(".ejnav_child .item") tools.viewMap(".pcMenuBtn i", ".pubMap", "click") tools.viewMap(".searchBtn", ".ybSearchBox", "click") tools.viewMap(".ybSearchClose", ".ybSearchBox", "click") tools.showActive($(".mNavBox")) tools.removeClass(".ybClose i", ".pubMap", "click") tools.singleSearch($("#submitbuttom")) tools.fLink(".flinkList") tools.fHeader(".pageBody") tools.scrollDiy($(".ybscroll")) tools.mNavClick($(".mNavBox .m_a1")) tools.mNavClick($(".mNavBox .m_a2")) tools.mNavBox($(".mheader .icon-tubiao-shezhi"), $(".mNavBox"), true) tools.mNavBox($(".mCloseNavBtn"), $(".mNavBox"), false) tools.mtopBtn() tools.ybSwiperHistory($(".ybHistoryList")) tools.brandFn() // tools.bannerTab($(".ybBanner")) tools.BiddingArea($(".ybCGInformation_Table")) if ($win <= 750) { tool750.footerNav() tools.mHandleNav($(".mPageName")) tool750.fCodeHover() tool750.fCodeFn($(".ejShare .list .item").eq(0), ".codeBox") tool750.mNavSwiperFn() } })