$(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('網路連線過慢,網頁請重新整理'); }, 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-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('網路連線過慢,網頁請重新整理'); }, 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.GA && typeof ga == 'function') { for(var key in d.GA) { Pro = JSON.parse(d.GA[key]); Sku = Pro['id']; ga('ec:addProduct',Pro); } ga('ec:setAction','add'); ga('send','event','購物車','加入購物車',Sku); } if(d.GA_conversion && typeof gtag == 'function') { gtag('event', 'add_to_cart', {'send_to':d.GA_conversion,'value':d.GA_values,'items':d.GA_items}); gtag('event', 'conversion', {'send_to':d.GA_conversion}); } if(d.FBQ){eval(d.FBQ)} //LINE-Tag if(d.LINE_Tag_id){ _lt('send', 'cv', { type: 'AddToCart' },[d.LINE_Tag_id]); } window.dataLayer = window.dataLayer || []; dataLayer.push({ 'event' : 'productAddToCart', 'ecommerce' : { 'currencyCode' : 'TWD', 'add' : { 'products' : [ { 'name' : d.adGeek_Data['name'], 'en_name' : '', 'id' : d.adGeek_Data['id'], 'category' : d.adGeek_Data['category'][0], 'price' : d.adGeek_Data['price'], 'specification' : d.adGeek_Data['specification'][0], 'quantity' : num } ] } } }); $.ajax({ url:"/ajax/ajax_get_cart.php", type:"POST", async:false, cache:false, data:{Type:'Prod',ID:SID,Act:'Add'}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, 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); } }); // 首頁主廣告 if($("#slideshow .slide-item").length>=1){ $("#slideshow").owlCarousel({ loop : true, items : 1, nav : false, navText : ['',''], dots:true, autoplay:true, animateOut:'fadeOut', autoplayTimeout:9500, }); } // 首頁主廣告 if($(".slideshow-004").length!=0){ var AID = $(".today-wrapper").find(".slide-item").eq(0).attr("AID"); $("#Today_Title_Url").attr("href","/activities9/"+AID) $(".today-wrapper").owlCarousel({ loop : false, responsive:{ 0:{ items : 2 }, 660:{ items : 3 }, 1024:{ items : 1 } }, nav : false, navText : ['',''], dots:true, autoplay:true, navSpeed:1000, autoplayTimeout:8000, autoplaySpeed:1000, }); $(".today-wrapper").on('changed.owl.carousel',function(d){ var AID = $(".today-wrapper").find(".slide-item").eq(d.item.index).attr("AID"); $("#Today_Title_Url").attr("href","/activities9/"+AID) }); } // ========================================================== // 三欄式紅眼廣告 // ========================================================== $(".slideshow-005 .slideshow").owlCarousel({ autoplay: true, loop: true, center: true, margin: 20, nav: true, dots: true, items: 3, responsive: { 0: { items: 1 }, 1025: { items: 2 } } }) // ========================================================== // 首頁跑馬燈 // ========================================================== $('.marpuee-001 .marquee').owlCarousel({ autoplay:true, loop: true, margin: 30, nav: false, dots: false, responsive: { 0: { items: 1 }, 480: { items: 1 }, 660: { items: 2 } } }) // 限時商品 $('.todaySell-silde').owlCarousel({ responsive:{ 0:{ items : 1 }, 480:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], dots:true, }); // 限時商品 $('.hairBaike-wrapper').owlCarousel({ items : 1, nav : true, navText : ['',''], dots:true, animateOut:'fadeOut', }); var _window = $(window); if(_window.width() <= 768){ $('.video_listWrapper').owlCarousel({ responsive:{ 0:{ items : 3 }, }, margin:5, merge:true, nav :false, navText : ['',''], dots:true, }); } // 限時商品 $('.video-silde').owlCarousel({ responsive:{ 0:{ items : 1 }, 660:{ items : 3 } }, nav : true, navText : ['',''], }); // IG $('.igpicbox-wrapper').owlCarousel({ // loop : true, margin:10, responsive:{ 0:{ stagePadding:50, items : 2 }, 660:{ stagePadding:60, items : 3 }, 1024:{ stagePadding:80, items : 4 }, 1300:{ stagePadding:100, items : 5 } }, loop:true, dots:false, nav : true, navText : ['',''], }); // 今日限定 $('.todaySale .wrapper').owlCarousel({ navText : ['',''], responsive:{ 0:{ items : 2, margin:5, nav : true, dots: false, }, 661:{ items : 3, margin:10, nav : true, dots: false, }, 1025:{ items :5, margin:25, nav : false, dots: true, } }, }); // 熱銷商品 $('.oneline-fiveitem-01 .wrapper').owlCarousel({ margin:15, responsive:{ 0:{ items : 2 }, 661:{ items : 3 }, 1025:{ items : 5 } }, navText : ['',''] }); var _window = $(window); // 推薦商品 $('.tags-001 .itembox').owlCarousel({ margin: 15, nav: true, dots: false, responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 661:{ items : 3 }, 1025:{ items : 4 }, 1201:{ items : 5 } }, navText : ['',''] }); //首頁專題 $(".lookbook .picbox").owlCarousel({ // loop : true, items : 1, nav : true, navText : ['',''], autoplay:true, autoplayTimeout:5000, dots:false, }); //試用評價 $('.review-001 .warpper').owlCarousel({ responsive:{ 0:{ items : 1, }, 481:{ items : 2, }, 661:{ items : 3, }, 1025:{ items : 4, }, 1201:{ items : 5, } }, navText : ['',''], nav :true, dots:false, margin: 15, }); $('.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('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#topic_content").html(d.Content); } }); } }); ;(function($) { let $deviceType = '' function destroyOwl(selector) { if (typeof $(selector).data('owl.carousel') !== 'undefined') { $(selector).data('owl.carousel').destroy() } } function mobileDestroy(selector, windowWidth, deviceType, owlObject) { if (windowWidth > 1024 && deviceType !== 'desktop') { deviceType = 'desktop' $(selector).owlCarousel(owlObject) } else if (windowWidth <= 1024 && deviceType !== 'mobile') { deviceType = 'mobile' destroyOwl(selector) } } function desktopDestroy(selector, windowWidth, deviceType, owlObject) { if (windowWidth > 1024 && deviceType !== 'desktop') { deviceType = 'desktop' destroyOwl(selector) } else if (windowWidth <= 1024 && deviceType !== 'mobile') { deviceType = 'mobile' $(selector).owlCarousel(owlObject) } } $(window).on('resize', function(e) { const $windowWidth = $(window).outerWidth(true) const sixItems = { nav: true, dots: true, items: 6, slideBy: 'page', responsive: { 768: { margin: 15, }, 1201: { margin: 30, }, } } const fourItems = { nav: true, dots: true, items: 4, responsive: { 0: { margin: 20, }, 1201: { margin: 30, }, } } const fiveItems = { nav: true, dots: true, slideBy: 'page', responsive: { 0: { items: 4, margin: 30, }, 1367: { items: 5, margin: 30, } } } const singleInResponsive = { nav: true, dots: false, margin: 20, responsive: { 0: { items: 1, loop:true, nav:false, autoplay:true, autoplayTimeout:5000, autoplaySpeed:1000, }, 481: { items: 2, loop:true, nav:false, autoplay:true, autoplayTimeout:5000, autoplaySpeed:1000, }, 769: { items: 3, }, }, } // ========================================================== // 暢銷熱榜 // ========================================================== //mobileDestroy('.hot-sale', $windowWidth, $deviceType, sixItems) $('.hot-sale').owlCarousel({ responsive:{ 0:{ items : 2, margin: 15 }, 481:{ items : 3, margin: 15 }, 768:{ items : 6, margin: 15 }, 1201:{ items : 6, margin: 30 } }, navText : ['',''], nav :true, dots:false, }); // ========================================================== // 最近瀏覽 // ========================================================== mobileDestroy('.last-view', $windowWidth, $deviceType, sixItems) // ========================================================== // 購物百科 // ========================================================== mobileDestroy('.sale-active', $windowWidth, $deviceType, fiveItems) // ========================================================== // lookbook 002 // ========================================================== desktopDestroy('.lookbook-list', $windowWidth, $deviceType, singleInResponsive) // ========================================================== // 閱讀穿搭 // ========================================================== mobileDestroy('.outfit-list', $windowWidth, $deviceType, fiveItems) }) })($) // ========================================================== // 推薦商品區塊 // ========================================================== ;(function($) { $('.tags-001').on('click', '.title-tag', function(e) { const target = $(this).data('target') $(this).addClass('in-checked').siblings('.title-tag').removeClass('in-checked') $(target).addClass('in-checked').siblings('.itembox').removeClass('in-checked') }) })($) $(".save-like").click(function(){ $(this).toggleClass('show'); })