jQuery(function () { var banners, total, current, next, last, rotator, paused, animating, resumeTimer; var times = { anim: 1320, // same as "an-vlong" wait: 6200, // delay between banners switching frame: 16, // a tiny gap for allowing classes to change }; times.interval = times.anim + times.wait + times.frame * 2; initSlickKv(); initProductSlick(); searchBoxEvent(); customDropdown(); floatingContactButton(); // FAQ getIconBarItems = function () { banners = $('.icon-banner-item'); total = banners.length; current = banners.not('.hidden').first().index(); next = current; last = total - 1; }; startRotation = function () { addMobileContentMarginTop(); getIconBarItems(); if (total > 1) { $('.icon-banner-item').not(':first').addClass('hidden'); rotator = setInterval(function () { if (!paused) { nextBanner(); } }, times.interval); } }; addMobileContentMarginTop = function () { var allTopHeight = $('.top-container').outerHeight(); $('#maincontent,.product_c_nav,.Content-container,.FindUs,.AirCon,.w-mall,#Product_Listing_01,.cart-top').css('margin-top', allTopHeight); if (!$('body').hasClass('customer-account-index')) { $('.myAccount-nav').css('margin-top', allTopHeight); } }; addMobileMenuSsoHeight = function () { var menuSsoTop = $('#icon-banner').outerHeight() + $('.top-close').outerHeight() + $('#top-login-box').outerHeight() + window.innerHeight * 0.01; var loginBlockHeight = window.innerHeight - menuSsoTop; $('.whirlpool.mini .block-customer-login').css('height', loginBlockHeight + 'px'); }; stopRotation = function () { clearInterval(rotator); $('#maincontent').css('margin-top', 0); rotator = null; $('.icon-banner-item').removeClass('hidden an-pop-out an-pop-in go'); }; pause = function () { clearTimeout(resumeTimer); paused = true; }; resume = function () { clearTimeout(resumeTimer); resumeTimer = setTimeout(function () { paused = false; }, 1000); }; getHeight = function () { return $('#icon-banner').outerHeight() + 10; }; nextBanner = function () { if (!animating && total > 1) { var $leaving = banners.eq(current), $coming, currenth = getHeight(), newh = 0; animating = true; next++; if (next >= total) { next = 0; } $coming = banners.eq(next); $leaving.removeClass('an-pop-in an-pop-out go hidden').addClass('an-pop-out'); $coming.removeClass('an-pop-in an-pop-out go').addClass('hidden'); setTimeout(function () { $leaving.addClass('go'); }, times.frame); setTimeout(function () { $leaving.addClass('hidden'); $coming.removeClass('hidden').addClass('an-pop-in'); newh = getHeight(); if (currenth < newh) { $('#icon-banner').css('height', currenth); } }, times.anim); setTimeout(function () { $coming.addClass('go'); if (currenth < newh) { $('#icon-banner').css('height', newh); } animating = false; }, times.anim + times.frame); current++; if (current >= total) { current = 0; } } }; if ($('html').attr('lang') === 'en-US') { $('#top .top-right .top-menu > li:nth-child(3)').removeClass('chinese'); $('#top .top-right .top-menu > li:nth-child(3)').removeClass('chinese'); $('#top .top-right .top-menu > li:nth-child(4)').removeClass('chinese'); } else { if ($('.category-description').length > 0) { $('html,body,h1,h2:not(.noClass),h3,h4,h5,h6,input,img,ul,ol,li,dl,dd,dt,td,p:not(.noClass)').css('font-weight', '500'); } else { $('html,body,h1,h2,h3,h4,h5,h6,input,img,ul,ol,li,dl,dd,dt,td,p').css('font-weight', '500'); } // $("html,body,h1,h2,h3,h4,h5,h6,input,img,ul,ol,li,dl,dd,dt,td,p").css("font-weight","500"); $('#top .top-right .top-menu > li:nth-child(1)').addClass('chinese'); $('#top .top-right .top-menu > li:nth-child(3)').addClass('chinese'); $('#top .top-right .top-menu > li:nth-child(4)').addClass('chinese'); } var classNm = ['arrow_two', 'arrow_three', 'arrow_four', 'arrow_five', 'arrow_six', 'arrow_seven']; function checkClass(className) { for (var i = 0; i < classNm.length; i++) { if (className != null) { if (classNm[i] === className) { $('.FAQ-container-main').addClass(classNm[i]); } else { $('.FAQ-container-main').removeClass(classNm[i]); } } else { $('.FAQ-container-main').removeClass(classNm[i]); } } } // 首页轮播图处按钮内有文字就显示,无则隐藏 if ($('.kv-item span').length > 0) { for (var i = 0; i < $('.kv-item span').length; i++) { if ($('.kv-item span').eq(i).text() != '') { $('.kv-item span').eq(i).show(); } else { $('.kv-item span').eq(i).hide(); } } } $('.FAQ-container-main > ul > li .faq_span img').click(function () { liParent = $(this).parent().parent(); if ($(window).width() > 768) { liParent.addClass('faq_select').siblings().removeClass('faq_select'); liParent.find('.faq_span').addClass('faq_active'); liParent.siblings().find('.faq_span').removeClass('faq_active'); asize($('.FAQ-container-main > ul > li.faq_select'), 380); if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Washer')) { checkClass(); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Dryer')) { checkClass('arrow_two'); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Refrigerator')) { checkClass('arrow_three'); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Microwave')) { checkClass('arrow_four'); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Cooking')) { checkClass('arrow_five'); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Oil')) { checkClass('arrow_six'); } else if ($('.FAQ-container-main > ul > li.faq_select').hasClass('the_Dehumidifier')) { checkClass('arrow_seven'); } } else { liParent.addClass('faq_mobile'); $('div.FindUs > div.FAQ-container > h2').addClass('hide'); $('div.mobile_return').removeClass('hide'); $('div.mobile_title').removeClass('hide'); asize($('.FAQ-container-main > ul > li.faq_mobile'), 357); } }); $('.FAQ-container-main > ul > li .faq_span > span').click(function () { $(this).siblings().trigger('click'); }); $('div.mobile_return > img').click(function () { $('.FAQ-container-main > ul > li.faq_mobile').removeClass('faq_mobile'); $('div.FindUs > div.FAQ-container > h2').removeClass('hide'); $('.FAQ-m').css('margin-bottom', 0); $('div.mobile_return').addClass('hide'); $('div.mobile_title').addClass('hide'); }); $('.hover-show-one > ul > li').click(function () { if ($(window).width() < 768) { $(this).find('.video-con').toggle(0); if ($(this).hasClass('toggle')) { $(this).removeClass('toggle'); } else { $(this).addClass('toggle'); } asize($('.FAQ-container-main > ul > li.faq_mobile'), 1357); } }); function asize(selector, num) { var height = parseInt(selector.find('.hover-show-one').height()); // if($(window).width()<769 && height<0) { // height += 140; // } var father = selector.parents().find('.FAQ-m'); // father.css("margin-bottom",height+'px'); var height = parseInt(selector.find('.hover-show-one').height()); var father = selector.parents().find('.FAQ-m'); var MT = $('.mobile_return').height() + $('.mobile_title').height() + 20 + height - father.height(); father.css('margin-bottom', MT + 'px'); } // FAQ //加载完html后执行 window.onload = function () { if ($('.detailImgLeft-right-slide-ul').length > 0) { if ($(window).width() < 769) { fixBox($('.detailImgLeft-right-slide-ul #hoverImg .mid_img'), 'no'); } else { fixBox($('.detailImgLeft-right-slide-ul #hoverImg .mid_img'), 'yes'); } } if ($('img.desktop-banner').length > 0) { var obj = $('img.desktop-banner'); var obja = $('.wysiwyg_left > a'); var objb = $('.wysiwyg_right > a'); obj.removeAttr('title'); obja.removeAttr('title'); objb.removeAttr('title'); } if ($(window).width() > 768) { asize($('.FAQ-container-main > ul > li.faq_select'), 380); } else { startRotation(); } }; //调整手机端盒子图片比例 function fixBox(selector, isMobile) { for (var i = 1; i <= selector.length; i++) { var img_width = parseInt(selector.eq(i - 1).width()); var img_height = parseInt(selector.eq(i - 1).height()); if (img_width < img_height) { selector.eq(i - 1).width('auto'); selector.eq(i - 1).height('100%'); } else { if (isMobile === 'no') { selector.eq(i - 1).height('auto'); selector.eq(i - 1).width('48vw'); } else { selector.eq(i - 1).height('auto'); selector.eq(i - 1).width('100%'); } } } } //判断设备为PC端还是移动端的函数 function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } $('.page-wrapper').click(function () { var menuHover = $('.top-menu > li:first-of-type'); menuHover.removeClass('active'); }); var prev = 1; //定义是否处于登陆页面 var isLogin = false; //点击图标弹出导航栏 jQuery('.nav_btm').click(function () { jQuery('.top-right').slideDown(600); jQuery('html').css('overflow-y', 'hidden'); addMobileMenuSsoHeight(); jQuery('.floating-cs-icon').css('display', 'none'); }); //点击图标关闭导航栏 jQuery('.top-close .top-close-right img').click(function () { jQuery('.top-right').slideUp(600); jQuery('html').css('overflow-y', 'auto'); jQuery('.floating-cs-icon').css('display', 'block'); }); //进入下一级导航 jQuery('.hover-Tcolor i').click(function () { if (prev === 1) { jQuery('.top-close-left').css('display', 'flex'); } else if (prev === 2) { } else if (prev === 3) { jQuery(this).parent().next().find('.menu-hoverThree').fadeIn(600); } prev++; jQuery(this).parent().next().fadeIn(600); }); //返回上一级导航 jQuery('.top-close-left i').click(function () { if (isLogin) { jQuery('.login-dl ').hide(); isLogin = false; if (prev === 2) { jQuery('.top-close-left').css('display', 'none'); } } else { if (prev === 2) { jQuery('.top-close-left').css('display', 'none'); jQuery('.menu-hover').fadeOut(600); } else if (prev === 3) { jQuery('.top-close-left').css('display', 'flex'); jQuery('.menu-hoverTwo').fadeOut(600); } else if (prev === 4) { jQuery('.menu-hoverThree').fadeOut(600); } } prev--; }); $('select').click(function (e) { if ($(this).hasClass('select_clk')) { $(this).removeClass('select_clk'); } else { $(this).addClass('select_clk'); } e.stopPropagation(); }); $(document).click(function () { if ($('.select_clk').length > 0) { $('.select_clk').removeClass('select_clk'); } if ($('.RepairBooking-map-input ul').css('display') === 'block') { $('.RepairBooking-map-input ul').hide(); } }); $('.RepairBooking-map-input input').click(function (e) { e.stopPropagation(); }); //左右移动超过四个的导航栏图标 $('.arrow_btn').click(function (e) { var moveWidth = parseInt($(this).parent().find('.menu-hoverThree ol li').width()) * 4; var times = $(this).parent().find('.menu-hoverThree ol li').length; if ($(this).hasClass('arrow_left')) { var n = parseInt($(this).parent().find('.menu-hoverThree ol').css('left')); if (n + moveWidth > 0) { } else { // $(this).parent().find(".menu-hoverThree ol").css("left",n+moveWidth); $(this) .parent() .find('.menu-hoverThree ol') .animate( { left: n + moveWidth + 'px', }, 600 ); } } else { var n = parseInt($(this).parent().find('.menu-hoverThree ol').css('left')); var rightMax = Math.ceil((times - 4) / 4) * moveWidth; if (n - moveWidth < -rightMax) { } else { // $(this).parent().find(".menu-hoverThree ol").css("left",n-moveWidth); $(this) .parent() .find('.menu-hoverThree ol') .animate( { left: n - moveWidth + 'px', }, 600 ); } } e.stopPropagation(); }); $('.warranty-col-top img').click(function () { if ($(this).hasClass('up')) { $(this).removeClass('up'); } else { $(this).addClass('up'); } }); //判断是否为登陆状态而决定样式 if ($('.login-dl').length > 0) { $('.login .line').removeClass('after'); } else { $('.login .line').addClass('after'); } //点击layout移除hover类 jQuery('.login .cs-info > span:nth-child(3)').click(function () { jQuery('#top .top-right .top-right-locator .top-right-locator-ac li.login').removeClass('hover'); }); var liWidth; //每个li模块的宽度 var Left; //Left坐标值 var last; //每次移动鼠标的相对位置 var ifbool; //判断向左向右移动的变量 var rightbool = true; //判断是否无法向右移动 var leftbool = true; //判断是否无法向左移动 var firstX; //移进鼠标的位置 var lastX = 0; //移出鼠标的位置 var boolIs = true; //判断是否为初次点击 var lastx; var countIndex = 0; window.name = 0; //移动端商品slide函数 function move(selector, e, count) { Left = selector.css('left'); var off = selector.offset(); //获得的是方块的绝对偏移量 var touch = e.originalEvent.targetTouches[0]; if (boolIs) { firstX = touch.pageX; boolIs = false; } var x = touch.pageX - off.left; //这个是获得鼠标点击的位置与边框边左边距的位置 var li = selector.children(); liWidth = 0.95 * count * parseInt(selector.parent().css('width')); var theWhole = -(li.length - 1) * liWidth; jQuery(document).bind('touchmove', function (ev) { var vtouch = ev.originalEvent.targetTouches[0]; lastX = firstX - vtouch.pageX; if (lastX != null) { lastX > vtouch.pageX ? (ifbool = false) : (ifbool = true); } lastx = vtouch.pageX - x; var thex; last = vtouch.pageX; lastx > theWhole ? (thex = vtouch.pageX - x) : (thex = theWhole); lastx < 0 ? (lastx = thex) : (lastx = 0); lastx === 0 ? (rightbool = true) : (rightbool = false); lastx === theWhole ? (leftbool = true) : (leftbool = false); if (rightbool || leftbool) { } else { selector.animate( { left: lastx + 'px', }, 1 ); } }); } //商品绑定移动端touch事件 jQuery('.hightlights-ct-img > ul').on('touchstart', function (e) { move(jQuery(this), e, 0.94); }); //移动端鼠标移出判断位置函数 function touchend(selector) { boolIs = true; //鼠标离开时将控制获取的布尔值重置 var bool; Math.abs(lastX / liWidth) < 0.5 ? (bool = false) : (bool = true); if (bool) { //移动距离超过一半 if (ifbool) { //向右移动时 if (rightbool) { //无法再向右移动! } else { selector.animate( { left: parseInt(Left) + liWidth + 'px', }, 100 ); countIndex = window.name; countIndex--; window.name = countIndex; } } else { //向左移动时 if (leftbool) { //无法再向左移动! } else { selector.animate( { left: parseInt(Left) - liWidth + 'px', }, 100 ); countIndex = window.name; countIndex++; window.name = countIndex; } } } else { //移动距离不超过一半 selector.animate( { left: Left, }, 100 ); } lastx = selector.css('left'); } //--商品移除移动端touch事件 start-- jQuery(document).on('touchend', function (e) { touchend(jQuery('.hightlights-ct-img > ul')); //调用判断函数进行判断,鼠标移动超过一半距离进入下一个,否则返回 jQuery(this).unbind('touchmove'); //移除移动端touch事件 rightbool = true; leftbool = true; }); jQuery('.detailRelated > ul').on('touchend', function (e) { touchend(jQuery('.detailRelated > ul')); jQuery(this).unbind('touchmove'); rightbool = true; leftbool = true; }); jQuery('.alert_cart_down_related > ul').on('touchend', function (e) { touchend(jQuery('.alert_cart_down_related > ul')); jQuery(this).unbind('touchmove'); rightbool = true; leftbool = true; }); jQuery('.accessories > ol').on('touchend', function (e) { touchend(jQuery('.accessories > ol')); jQuery(this).unbind('touchmove'); rightbool = true; leftbool = true; }); // jQuery('.detailImgLeft-right-slide .detailImgLeft-right-slide-ul').on('touchend',function (e) { // touchend(jQuery('.detailImgLeft-right-slide .detailImgLeft-right-slide-ul')); // jQuery(this).unbind('touchmove'); // jQuery("#detailImg_content").children().eq(window.name).addClass('active').siblings().removeClass('active'); // rightbool = true; // leftbool = true; // }); // jQuery('.product_c_feature > ul').on('touchend',function (e) { // touchend(jQuery('.product_c_feature > ul')); // jQuery(this).unbind('touchmove'); // rightbool = true; // leftbool = true; // }); //--商品移除移动端touch事件 end-- //变换window触发事件 jQuery(window).resize(function () { // menuResize(); mobileResize(); asize($('.FAQ-container-main > ul > li.faq_select'), 380); var check = jQuery('.cart-container > form #shopping-cart-table tbody td.subtotal'); if (check.length > 0) { mobileCart(check); } }); //移动端切换到PC时候执行以下函数 function mobileResize() { var windowL = jQuery(document.body).width(); if (windowL >= 768) { jQuery('.login-dl ').hide(); jQuery('html').css('overflow-y', 'auto'); jQuery('#top .top-right .top-right-locator .top-right-locator-ac li.login').removeClass('click'); // jQuery(".top-right-log").css("top","auto").css("bottom","0"); jQuery('.top-close-left').hide(); jQuery('.top-right').hide(); jQuery('.cs-info ').hide(); jQuery('.menu-hover').hide(); jQuery('.menu-hoverTwo').hide(); jQuery('.menu-hoverThree').hide(); stopRotation(); } else { jQuery('.cs-info ').css('display', 'flex'); addMobileContentMarginTop(); addMobileMenuSsoHeight(); if (!rotator) { startRotation(); } } } //productinfo.js开始 jQuery('.leftfilter > div > .aaaa').click(function () { jQuery('body').css('overflow', 'hidden'); jQuery(this).parent().addClass('leftClick'); jQuery('.FilterBy').removeClass('left-hide').addClass('left-flex'); jQuery('.resultClose').removeClass('left-hide').addClass('left-flex'); jQuery(this).addClass('left-hide').siblings().removeClass('left-hide').show(); }); jQuery('.leftfilter > div > .bbbbb').click(function () { jQuery('.leftfilter > div:nth-child(2) > .sorter').toggle(); }); jQuery('.leftfilter .left .down > span').click(function () { jQuery(this).parent().next().toggle(300); if (jQuery(this).hasClass('downArrow')) { jQuery(this).removeClass('downArrow'); } else { jQuery(this).addClass('downArrow'); } }); jQuery('.leftfilter .left .resultClose').click(function () { var urlstr = ''; $('.leftClick .input').each(function () { $(this) .find('.click_dump li') .each(function () { if ($(this).find('input')[0].checked) { urlstr += $(this).find('input').attr('data-code') + '[]=' + $(this).find('input').val() + '&'; } }); }); $('.leftClick .Dimension li').each(function () { if ($(this).find('input').val() != $(this).find('input').attr('max-value')) { urlstr += $(this).find('input').attr('data-attr') + '=' + $(this).find('input').val() + '&'; } }); window.location.href = $(this).attr('data-url') + urlstr; //fnClose(); }); jQuery('.FilterBy > p > span:first-of-type').click(function () { fnClose(); }); function fnClose() { jQuery('body').css('overflow', 'auto'); jQuery('.FilterBy').removeClass('left-flex').addClass('left-hide'); jQuery('.resultClose').removeClass('left-flex').addClass('left-hide'); jQuery('.leftfilter > div > .aaaa').parent().removeClass('leftClick'); jQuery('.leftfilter > div > .aaaa').removeClass('left-hide').siblings().addClass('left-hide'); } //productinfo.js结束 // fabri-care jQuery('.distinguish-left > .aaaa').click(function () { jQuery('body').css('overflow', 'hidden'); jQuery(this).parent().addClass('leftClick'); jQuery('.resultClose').removeClass('left-hide').addClass('left-flex'); jQuery(this).addClass('left-hide').siblings().removeClass('left-hide').show(); }); jQuery('.distinguish-left .resultClose').click(function () { jQuery('body').css('overflow', 'auto'); jQuery('.resultClose').removeClass('left-flex').addClass('left-hide'); jQuery('.distinguish-left > .aaaa').parent().removeClass('leftClick'); jQuery('.distinguish-left > .aaaa').removeClass('left-hide').siblings().addClass('left-hide'); }); jQuery('.left-list-top img').click(function () { jQuery(this).parent().next().toggle(500); }); //account $('.myAccount-nav').click(function () { if ($(window).width() < 769) { $(this).find('ul').fadeToggle(300); if ($('.down_icon').hasClass('up_icon')) { $('.down_icon').removeClass('up_icon'); } else { $('.down_icon').addClass('up_icon'); } } }); $('.Find-nav .down_icon').click(function () { if ($(window).width() < 769) { if ($('.down_icon').hasClass('up_icon')) { $('.down_icon').removeClass('up_icon'); } else { $('.down_icon').addClass('up_icon'); } } }); //icon悬浮显示详细文本 start //PC端鼠标悬浮显示文本 // $('.detailImg div.product-add-form .icon-p img').mouseenter(function (e) { // e.stopPropagation(); // hoverIcon($(this)); // }); // $('.form-info-col').mouseenter(function (e) { // $('.icon-p').addClass('opacity'); // $('.product-add-form-info').show(); // }); // $('.form-info-col').mouseleave(function (e) { // e.stopPropagation(); // $('.icon-p').removeClass('opacity'); // $('.product-add-form-info').hide(); // $(document).unbind('mousemove'); // }); // $('.detailImg div.product-add-form .icon-p img').mouseleave(function (e) { // e.stopPropagation(); // $('.icon-p').removeClass('opacity'); // $('.product-add-form-info').hide(); // $(document).unbind('mousemove'); // }); // //移动端触摸显示文本 // $('.detailImg div.product-add-form .icon-p img').on('touchstart', function (e) { // hoverIcon($(this)); // }); //显示文本 // function hoverIcon(selector) { // var $overlay = $('.product-add-form-info'); // var $parent = selector.parent(); // var $img = $('img', $overlay); // var $text = $('span', $overlay); // var obj = $(selector); // var parentObj = obj.parent().offset(); // var offset = obj.offset(); // var right = offset.left; // var top = offset.top; // var url = $(selector).attr('src'); // if ($('html').attr('lang') == 'zh-Hant-HK') { // var Text = $(selector).attr('data-alt'); // } else { // var Text = $(selector).attr('alt'); // } // $overlay.removeClass('align-right').css('opacity', 0).show(); // var imgPosition = $img.position(); // // var paddingLeft = imgPosition.left; // // var paddingTop = imgPosition.top; // var paddingLeft = $('.columns').offset().left + 5; // var paddingTop = $('.columns').offset().top + 5; // $img.attr('src', url); // $text.text(Text); // $('.icon-p').addClass('opacity'); // if (selector.position().left > $parent.width() * 1.5 && $(window).width() < 768) { // right = window.innerWidth - (selector.offset().left + selector.outerWidth() + paddingLeft); // $overlay.addClass('align-right').css({ // left: 'auto', // right: right, // top: top - paddingTop, // }); // } else { // $overlay.css({ // left: right - paddingLeft, // right: 'auto', // top: $('.product-add-form').offset().top + (top - $('.product-add-form').offset().top), // }); // } // $img.css({ // width: selector.width(), // height: selector.height(), // }); // $overlay.stop().animate( // { // opacity: 1, // }, // 300 // ); // } //icon悬浮显示详细文本 end //checkout 触发事件 if (window.checkoutConfig) { var checkout = jQuery('.action.checkout'); var Becheckout = jQuery('.action.Becheckout'); Becheckout.click(function () { checkout.trigger('click'); }); //预计到达时间 var myDate = new Date(); var myDate2 = new Date(); var isStaff = window.checkoutConfig.isStaff; var accWproOnly = window.checkoutConfig.quoteData.acc_wpro_only; myDate.setDate(myDate.getDate() + 2); myDate2.setDate(myDate2.getDate() + 6); var installDate2 = new Date(myDate); installDate2.setDate(myDate.getDate() + 1); function formatTime(date) { var month = date.getMonth() + 1, month = month < 10 ? '0' + month : month; var day = date.getDate(), day = day < 10 ? '0' + day : day; return month + '/' + day; } // $('.cart-p-detail-wrapper .arrival_date_data').text(formatTime(myDate) + '-' + formatTime(myDate2)); $('.cart-p-detail-wrapper .arrival_date_data').text(formatTime(myDate)); if (isStaff) { $('.cart-p-detail-wrapper .arrival_date_data').text(formatTime(myDate)); } else { // $('.cart-p-detail-wrapper .arrival_date_data').text(formatTime(myDate) + '-' + formatTime(myDate2)); $('.cart-p-detail-wrapper .arrival_date_data').text(formatTime(myDate)); } // if (isStaff && !accWproOnly) { // $('.cart-p-detail-wrapper .installation_date_data').text(formatTime(myDate) + '-' + formatTime(installDate2)); // } else { // $('.cart-p-detail-wrapper .installation_date_data').hide(); // } } // shoppingcart.js //js控制间距 var check = jQuery('.cart-container > form #shopping-cart-table tbody td.subtotal'); if (check.length > 0) { mobileCart(check); } function mobileCart(select) { if (jQuery(window).width() < 769) { for (var i = 0; i < select.length; i++) { var td = select.eq(i).prev(); var wholeUL = parseInt(td.find('.product-item-details').css('height')); var arriveDate = parseInt(td.find('.arrival_date').css('height')); //手机端购物车价格显示位置 var price = wholeUL - arriveDate; var lengthV = td.find('.product-item-photo').css('width'); select .eq(i) .find('.price-excluding-tax') .css('margin-left', parseInt(lengthV) + 10 + 'px'); select.eq(i).css('top', price + 'px'); } } } //按下切换折扣码输入textbox jQuery('.form-cart-p > a').click(function () { var form_discount = jQuery(this).parent().siblings(); form_discount.toggle(); }); // helpcenter_washer // $(".FAQ-container-main > ul > li>a").click(function () { // var ul = $(".hover-show-one"); // ul.addClass("show"); // $(".FAQ-container-main").addClass("hide"); // return false; // }); // 点击添加购物车弹出弹框 $('#product-addtocart-button').click(function () { // initialize slick postion after showed popup setTimeout(function () { $('#slider_0').slick('refresh'); $('#slider_0').slick('setPosition'); }, 1000); }); $('.alert_cart_up_title > img').click(function () { $('.alert_cart').removeClass('cart_show'); $('.panel_black').removeClass('cart_show'); setTimeout(function () { $('#slider_1').slick('refresh'); $('#slider_1').slick('setPosition'); }, 500); }); $('.alert_content_foot_submit_checkout').click(function () { createMcCookie('hide_popupcart', null, 999); }); //helpecenter 手机下拉菜单 $('div.Find-nav > div > span.down_icon').click(function () { if ($(this).parent().siblings().hasClass('show')) { $(this).parent().siblings().removeClass('show'); } else { $(this).parent().siblings().addClass('show'); } }); // 商品详情页面视频——开始 //按下方块弹出视频 $('#mark').click(function () { var $videoButton = $('.iconPlay', '#hoverImg'); if ($videoButton.is(':visible')) $videoButton.trigger('click'); }); //按ESC关闭视频 $(document).keyup(function (event) { switch (event.keyCode) { case 27: $('#compareClos').trigger('click'); } }); //按任意地方模拟关闭视频按钮事件 $('.v-play.pop-bigBj').click(function () { $('#compareClos').trigger('click'); $(this).hide(); $('iframe', this).attr('src', ''); }); //阻止事件 $('.v-play.pop-bigBj > div').click(function (event) { event.stopPropagation(); }); // 商品详情页面视频——结束 // where to find——开始 $('a.where_find').click(function () { $('html').css('overflow', 'hidden'); $('.finder').addClass('show'); $('#pop-up').addClass('show'); return false; }); $('.finder-con-title-model-close').click(function () { $('html').css('overflow', 'auto'); $('.finder').removeClass('show'); $('#pop-up').removeClass('show'); }); $('#pop-up').click(function () { $('.finder-con-title-model-close').trigger('click'); }); // where to find——结束 }); require(['jquery'], function ($) { $('#model_select_one').change(function () { $.ajax({ type: 'post', url: $(this).attr('data-url'), data: { category_id: $(this).val(), }, dataType: 'text', success: function (data) { var obj = eval('(' + data + ')'); var strss = ''; if (obj.code) { var titles = 'title3'; var images = 'image1'; strss += '<div class="finer-con-result-col">'; if (obj.data[titles] == null || obj.data[titles] == '') { } else { strss += ' <div class="finer-con-result-col-til">'; strss += ' <h5>' + obj.data[titles] + '</h5> '; strss += '</div>'; } strss += '<div class="finer-con-result-col-showPic">'; if (obj.data[images] == null || obj.data[images] == '') { } else { strss += ' <div class="showPic-col">'; strss += ' <img src="' + obj.data[images] + '" alt="">'; strss += ' </div>'; } strss += ' </div>'; strss += ' </div>'; } $('.finer-con-result').html(strss); }, }); }); }); function initSlickKv() { var $tar = $('.kv-silder'); var $parent = $tar.parents('.kv-silder-container'); if (!$tar.length) return; $tar.each(function (i, v) { $(v).slick({ dots: true, infinite: true, speed: 1000, slidesToShow: 1, autoplay: true, autoplaySpeed: 8000, prevArrow: $('.btn-ks-prev', $parent), nextArrow: $('.btn-ks-next', $parent), }); }); } function searchBoxEvent() { var $tar = $('input#search'); var $parent = $tar.parents('.Search'); /* 20211007 - remove extend class $tar.focus(function () { $(this).parent().addClass('extend'); //$parent.siblings('.search_keywords').show(); //alert('focus'); }); $tar.blur(function () { $(this).parent().removeClass('extend'); //alert('blur'); }); */ $parent.siblings('.result_box').appendTo($parent); $parent.siblings('.search_keywords').appendTo($parent); //$parent.siblings('.result_box').appendTo($parent); } function customDropdown() { var tar = '.custom-dropdown-contaniner'; var item = '.dropdown-item'; var showClass = 'custom-dropdown-contaniner--show'; var displayAreaClass = '.custom-dropdown-selected'; var $tar = $(tar); var isMobile = 'ontouchstart' in document.documentElement; if (isMobile) $tar.addClass('mobile'); $(tar + ' select').on('change', function () { var $parent = $(this).parents(tar); var $displayArea = $(displayAreaClass, $parent); var _val = $(this).val(); var _text = this.options[this.selectedIndex].text; $displayArea.html(_text); $(item + '[data-value="' + _val + '"]') .addClass('selected') .siblings() .removeClass('selected'); $parent.removeClass(showClass); }); if (!isMobile) { $('body').on('click', tar, function (e) { e.stopPropagation(); $(this).toggleClass(showClass); }); $('body').on('click', item, function (e) { e.stopPropagation(); var $parent = $(this).parents(tar); var $select = $('select', $parent); var _val = $(this).attr('data-value'); $select.val(_val).change(); }); } } function initProductSlick($elem) { var $tar = $elem && $elem.length ? $elem : $('.product-feature-slick').not('.slick-initialized'); if (!$tar.length) return; var breakpoint = 1180; var timer; var lastBreakpoint = false; function slickInit($tar) { var currentBreakpoint = window.innerWidth <= 1180 ? 'mobile' : 'desktop'; var isMobile = window.innerWidth <= 1180; var isBreakpontChange = currentBreakpoint != lastBreakpoint; if (isBreakpontChange) { lastBreakpoint = currentBreakpoint; if (isMobile) { $tar.each(function (i, v) { $(v).slick({ dots: false, arrows: false, infinite: false, slidesToShow: 3, /* slidesToScroll: 1, */ variableWidth: false, /* speed: 1000, */ responsive: [ { breakpoint: 1180, settings: { infinite: false, slidesToShow: 3, variableWidth: false, slidesToScroll: 1, autoplay: true, autoplaySpeed: 1500, }, breakpoint: 768, settings: { infinite: false, slidesToShow: 1, variableWidth: true, slidesToScroll: 1, autoplay: true, autoplaySpeed: 1500, }, }, ], }); $(v).slick('slickGoTo', 0); }); } else { $tar.each(function (i, v) { if ($(v).hasClass('slick-initialized')) { $(v).slick('unslick'); } }); } } } $(window) .on('resize', function () { clearTimeout(timer); timer = setTimeout(function () { slickInit($tar); }, 300); }) .resize(); } function slickGoTo($tar, idx) { if (!$tar || !$tar.length) return; var _idx = idx || 0; $tar.slick('slickGoTo', _idx); } function setScrollTop(top) { $('html,body').animate( { scrollTop: top - 50, }, 500 ); } function floatingContactButton() { $('.floating-cs, button.action.close').click(function (e) { $(this).parent('.floating-cs-icon').toggleClass('open'); }); $('.floating-cs-banner button.close').click(function (e) { $(this).parent('.floating-cs-banner').addClass('off'); if (!accessCookie('floating_cs_banner_close') || accessCookie('floating_cs_banner_close') == 'false') { var tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setHours(0, 0, 0, 0); document.cookie = 'floating_cs_banner_close' + '=' + 'true' + '; expires=' + tomorrow.toGMTString() + '; path=/; secure'; } }); }