// ========================================================== // 浮動廣告開關 // ========================================================== ;(function($) { // if(!localStorage.getItem('floatSlide')) { // localStorage.setItem('floatSlide', 'show') // } // floatCheck(); //改為開著 localStorage.setItem('floatSlide', 'show'); $('.float-slide').removeClass('hide'); })($) // BKE $(document).ready(function () { //立即購買 $('body').on('click','.index-buyButton',function(){ var SID = $(this).attr('sid'); if(SID){ get_prod_item(SID); } }); //立即購買_關閉 $('.buypop-close').on('click',function(){ $('.buypopbox').removeAttr('style'); }); //立即購買_規格下拉選單 $(".buypop-selectbox").on('change',".color-select, .size-select",function(){ var SID = $(this).val(); if(SID){ get_prod_item(SID); } }); //立即購買_加入購物車按鈕 $(".buypop-buttonbox").on("click",".buypop-button",function(){ var _item = $(this).parents(".buypop-buttonbox"), SID = $(this).attr('sid') || 0, num = _item.find(".amountBox").val() || 0; if(SID == 0){ alert(_jsLang.請選擇尺寸或規格); //errorbox(); }else if(num ==0){ alert(_jsLang.請選擇數量); //errorbox(); }else{ add_to_cart(SID,num); } }); //立即購買_取得商品詳細資料 function get_prod_item(SID){ $.ajax({ url:"/module/ajax/ajax_get_pop_prod_item-p.php", type:"POST", cache:false, async:false, dataType:"json", data:{SID:SID}, error:function(d){ alert(_jsLang.網路連線過慢網頁請重新整理); }, success:function(d){ if(d.Size_Sel==''){ if(d.Stock>0){ add_to_cart(SID,1); }else{ alert(_jsLang.商品庫存不足); } }else{ $(".buypop-title").html(d.Name); $('.buypop-word').html(d.Name_Sub); $('.buypop-picbox').html(d.Pic_Path); $('.buypop-price').html('NT$'+d.Price1); $('.buypop-selectbox').html(d.Size_Sel); if(d.Stock>0){ $('.text-smail').val(1); }else{ $('.buypop-buttonbox').html(_jsLang.商品庫存不足); } $('.text-smail').attr('max',d.Stock); $('.buypop-button').attr('sid',d.ID); $('.buypopbox').css('display','flex'); } } }); } //立即購買_加入購物車 function add_to_cart(SID,num){ $.ajax({ url:"/ajax/ajax_add_to_cart.php", type:"POST", cache:false, async:false, data:{SID:SID, num:num, webcacheno:$('#webcacheno').val()}, dataType: 'json', error:function(d){ alert(_jsLang.網路連線過慢網頁請重新整理); }, success:function(d){ if(d.Stock && d.Stock != 'null'){ d.Stock = (d.Stock>20)?'20':d.Stock; if(d.Stock>0){ $('.text-smail').val(1); }else{ $('.text-smail').val(0); } $('.text-smail').attr('max',d.Stock); } if(d.Alert == 'OK'){ if(d.DataLayer){eval(d.DataLayer)} if(d.GA && typeof ga == 'function') { for(var key in d.GA) { ga('ec:addProduct',d.GA[key]); } ga('ec:setAction','add'); ga('send','event','購物車','加入購物車'); } if(d.FBQ){eval(d.FBQ)} if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } // omnichat if(d.Omnichat){ window.omnichatTracker = window.omnichatTracker || []; window.omnichatTracker.push(['event', 'add_to_cart', { 'items': d.Omnichat }]); } $.ajax({ url:"/ajax/ajax_get_cart.php", type:"POST", async:false, cache:false, data:{Type:'Prod',ID:SID,Act:'Add'}, error:function(d){ alert(_jsLang.網路連線過慢網頁請重新整理); }, success:function(d){ //$(".shopping-cartbox").css('display','none'); $("#Header_Shopcart").html(d); $("#Header_Shopcart").parent(".shopping-cartbox").animate({'opacity':1,'maxHeight':'999px'}).css('z-index','100'); setTimeout(function(){ $("#Header_Shopcart").parent(".shopping-cartbox").animate({'maxHeight':'0px','opacity':0},function(){ $(this).removeAttr('style'); $(".shopping-cartbox").removeAttr('style'); }); },3000); } }) }else{ alert(d.Alert); } } }); } //立即購買_數量- $('.buypop-num').on('click','.fa-minus',function(){ var now_num = $('.amountBox').val(); now_num = parseInt(now_num); if(now_num>1){ $('.amountBox').val(now_num-1); } }); //立即購買_數量+ $('.buypop-num').on('click','.fa-plus',function(){ var now_num = $('.amountBox').val(); var max_num = $('.amountBox').attr('max'); now_num = parseInt(now_num); max_num = parseInt(max_num); if(now_num < max_num){ $('.amountBox').val(now_num+1); } }); //立即購買_輸入 $('.amountBox').keyup(function(){ var now_num = $('.amountBox').val(); var max_num = $('.amountBox').attr('max'); now_num = parseInt(now_num); max_num = parseInt(max_num); $('.amountBox').val(now_num); if(now_num>max_num){ $('.amountBox').val(max_num); } if(now_num<1){ $('.amountBox').val(1); } if(isNaN(now_num)){ $('.amountBox').val(1); } }); }); // ========================================================== // 紅眼廣告 // ========================================================== ;(function($) { if($("#slideshow .slide-item").length>=1){ $("#slideshow").owlCarousel({ loop: true, items: 1, navText: ['',''], dots: true, autoplay: true, animateOut: 'fadeOut', autoplayTimeout: 9500, autoplayHoverPause: true, responsive: { 0: { nav : false, }, 1025: { nav : true, }, }, }); } // 兩欄式,限時搶購區塊 $(window).on('resize', function(e) { if($(".slideshow-004").length) { let slideshowTodayStep = '' const todaySale = $(".today-wrapper") function slideshowTodayObj(num) { const obj = { autoplay: true, autoplaySpeed: 1000, autoplayTimeout: 8000, dots: true, items: num, loop: false, margin: 20, nav: false, navSpeed: 1000, navText: ['',''], } return obj } if($(this).width() > 1024 && slideshowTodayStep !== 'desktop') { slideshowTodayStep = 'desktop' if(todaySale.data('owl.carousel')) { todaySale.data('owl.carousel').destroy() } if(todaySale.children().length > 1) { todaySale.owlCarousel(slideshowTodayObj(1)) } } else if($(this).width() > 660 && $(this).width() <= 1024 && slideshowTodayStep !== 'laptop') { slideshowTodayStep = 'laptop' if(todaySale.data('owl.carousel')) { todaySale.data('owl.carousel').destroy() } if(todaySale.children().length > 3) { todaySale.owlCarousel(slideshowTodayObj(3)) } } else if($(this).width() <= 660 && slideshowTodayStep !== 'mobile') { slideshowTodayStep = 'mobile' if(todaySale.data('owl.carousel')) { todaySale.data('owl.carousel').destroy() } if(todaySale.children().length > 2) { todaySale.owlCarousel(slideshowTodayObj(2)) } } } }) $(window).trigger('resize') })($) // ========================================================== // 計時器功能 // ========================================================== ;(function($) { $('.countdown-timer').each(function(i, ele) { const startTime = new Date($(ele).data('start')); const endTime = new Date($(ele).data('end')); // setInterval(countDown, 1000, ele, endTime, startTime) setTimeout(countDown, 1000, ele, endTime, startTime) countDown(ele, endTime, startTime) }); function countDown(target, endTime, startTime) { const nowTime = Date.now() if($(target).children('.timer-string').length) { $(target).children('.timer-string').remove() } if(startTime > nowTime) { $(target).prepend(''+_jsLang.尚未開始+'') return setTimeout(countDown, 1000, target, endTime, startTime) } else if(nowTime > endTime) { $(target).prepend(''+_jsLang.優惠結束+'') return false } else { const leftTime = endTime - nowTime; const leftSec = Math.floor(leftTime / 1000) % 60; const leftMin = Math.floor(leftTime / 1000 / 60) % 60; const leftHour = Math.floor(leftTime / 1000 / 60 / 60) % 24; const leftDay = Math.floor(leftTime / 1000 / 60 / 60 / 24); $(target).children('.second-box').text(padLeft(leftSec, 2)); $(target).children('.minute-box').text(padLeft(leftMin, 2)); $(target).children('.hour-box').text(padLeft(leftHour, 2)); $(target).children('.date-box').text(padLeft(leftDay, 2)); return setTimeout(countDown, 1000, target, endTime, startTime) } } function padLeft(content, length, symbol) { let targetStr = content.toString() let letter = symbol || 0 if(targetStr.length < length) { targetStr = letter + targetStr return padLeft(targetStr, length, letter) } else { return targetStr } } })($) // ========================================================== // 限時搶購 // ========================================================== ;(function($) { let todayStep = ''; const todaySale = $('.todaySale .wrapper') $(window).on('resize', function(e) { if($(this).width() > 660 && todayStep !== 'desktop') { todayStep = 'desktop' todaySale.owlCarousel(commonOwlObj(4)); } else if($(this).width() <= 660 && todayStep !== 'mobile') { todayStep = 'mobile' if(todaySale.data('owl.carousel')) { todaySale.data('owl.carousel').destroy() } } }) $(window).trigger('resize') })($) // ========================================================== // 一、二、三個小廣告 // ========================================================== ;(function($) { let adboxStep = '' const adboxCommon = $('.adbox-group') function adboxObj(num) { const obj = { items: num, nav: false, dots: true, autoplay: true, loop: true, slideBy: 'page', responsive: { 0: { margin: 10, }, 1025: { margin: 15, } } } return obj } $(window).on('resize', function(e) { if($(this).width() > 660 && adboxStep !== 'desktop') { adboxStep = 'desktop' adboxCommon.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).parents().hasClass('adbox1')) { if($(ele).children().length > 1) { $(ele).owlCarousel(adboxObj(1)) } } if($(ele).parents().hasClass('adbox2')) { if($(ele).children().length > 2) { $(ele).owlCarousel(adboxObj(2)) } } if($(ele).parents().hasClass('adbox3')) { if($(ele).children().length > 3) { $(ele).owlCarousel(adboxObj(3)) } } }) } else if($(this).width() <= 660 && adboxStep !== 'mobile') { adboxStep = 'mobile' adboxCommon.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).children().length > 1) { $(ele).owlCarousel(adboxObj(1)) stopAutoPlay(".adbox3 .owl-carousel") } }) } }) $(window).trigger('resize') })($) //到最後一個停止輪播 function stopAutoPlay(target){ $(target).on("change.owl.carousel", function(e){ if(e.namespace && e.property.name === "position" && e.relatedTarget.relative(e.property.value) === e.relatedTarget.items().length - 1){ $(target).trigger("stop.owl.autoplay") } }) } // ========================================================== // 推薦主題商品 // ========================================================== ;(function($) { let tagsStep = '' const tagsCommon = $('.tagitem-content > .itembox') // 頁籤切換 $('.tags-section').on('click', '.title-tag', function(e) { const targetID = $(this).data('target') $(this).addClass('in-click').siblings('.title-tag').removeClass('in-click') $(`.itembox[data-id="${targetID}"]`).addClass('in-click').siblings('.itembox').removeClass('in-click') }) // 響應式輪撥開關 $(window).on('resize', function(e) { if($(this).width() > 660 && tagsStep !== 'desktop') { tagsStep = 'desktop' tagsCommon.each(function(i, ele) { if($(ele).children().length > 3) { $(ele).owlCarousel(commonOwlObj(4)) } }) } else if($(this).width() <= 660 && tagsStep !== 'mobile') { tagsStep = 'mobile' tagsCommon.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }) } }) $(window).trigger('resize') })($) // ========================================================== // 新品上市、熱銷商品 // ========================================================== ;(function($) { let owlStep = '' const owlSlide = $('.oneline-fiveitem-01, .new-arrivals').find('.wrapper') $(window).on('resize', function(e) { if($(this).width() > 660 && owlStep !== 'desktop') { owlStep = 'desktop' owlSlide.each(function(i, ele) { if($(ele).children().length > 3) { $(ele).owlCarousel(commonOwlObj(5)) } }) } else if($(this).width() <= 660 && owlStep !== 'mobile') { owlStep = 'mobile' owlSlide.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }) } }) $(window).trigger('resize') })($) // ========================================================== // 首頁影音列表輪播設定 // ========================================================== ;(function($) { const videoList = $('.video-list'); videoList.each(function(i, ele) { if($(ele).children().length > 1) { $(ele).owlCarousel({ items: 1, margin: 20, nav: false, dots: true, loop: true, autoplay: true, autoplayTimeout: 8000, autoplayHoverPause: true, }); } }); })($) // ========================================================== // lookbook // ========================================================== ;(function($) { $(".lookbook .picbox").owlCarousel({ loop: true, items: 1, nav: false, navText: ['',''], autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, dots: false, }); $('.picbox').on('translated.owl.carousel',function(event){ var id = $(this).find('.active').eq(0).find('.pic-item').attr('did'); ajax_topic_content(id); }); function ajax_topic_content(topic_id){ $.ajax({ url:"/module/ajax/ajax_get_topic_content-p.php", type:"POST", cache:false, async:false, dataType:"json", data:{ID:topic_id}, error:function(d){ alert(_jsLang.網路連線過慢網頁請重新整理); }, success:function(d){ $("#topic_content").html(d.Content); } }); } })($) // ========================================================== // instagram 區塊 // ========================================================== ;(function ($) { let igStep = ''; const wrap = '.instagram-section .wrapper'; const child = ''; const owlList = $(wrap); $(window).on('resize', function (e) { const winWidth = $(this).width(); if (igStep !== 'mobile' && winWidth < 661) { igStep = 'mobile'; if(owlList.data('owl.carousel')) { owlList.data('owl.carousel').destroy() } owlList.find('.owl-group > .item').unwrap(); } else if (igStep !== 'tablet' && winWidth < 1025 && winWidth >= 661) { igStep = 'tablet'; owlGroupWrap(owlList, 8); } else if (igStep !== 'desktop' && winWidth >= 1025) { igStep = 'desktop'; owlGroupWrap(owlList, 12); } }); $(window).trigger('resize'); })($); // ========================================================== // 浮動廣告區塊 // ========================================================== ;(function($) { const owlTarget = $('.float-slide .float-list') let floatStep = '' // close 按鈕 $('.float-slide').on('click', '.closer', function(e) { //改為開著 // localStorage.setItem('floatSlide', 'hide') // floatCheck(); $('.float-slide').addClass('hide'); }) // 響應式輪播 $(window).on('resize', function(e) { if(floatStep !== 'mobile' && $(this).width() <= 660) { floatStep = 'mobile' if(owlTarget.data('owl.carousel')) { owlTarget.data('owl.carousel').destroy() } } else if(floatStep !== 'desktop' && $(this).width() > 660) { floatStep = 'desktop' owlTarget.owlCarousel({ items: 1, nav: false, dots: true, slideBy: 'page', autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, margin: 10, }) } }) })($) // 浮動廣告區塊 check function floatCheck() { if(localStorage.getItem('floatSlide') === 'hide') { $('.float-slide').remove() } else if(localStorage.getItem('floatSlide') === 'show') { $('.float-slide').removeClass('hide') } }