$(function() { $("#Main_Form").fromsAuth({ type:'NONE', }); $("#Member_Form").fromsAuth(); var header_height = 100; if($(window).width() <= 480){ header_height = 70; } $('.product-link').on('click',function(){ if($('#productbox').length!=0){ $("html,body").animate({scrollTop: $('#productbox').offset().top - header_height},800); }else{ $("html,body").animate({scrollTop: $('#productlist').offset().top - header_height},800); } }); $('.article-link').on('click',function(){ $("html,body").animate({scrollTop: $('#articlebox').offset().top - header_height},800); }); $('.shopcart-link').on('click',function(){ $("html,body").animate({scrollTop: $('#s1').offset().top - header_height},800); }); $("#Main_Content").on('click', '#step2', function() { var sh = $("#s2 .section-wrapper").height() + 100; $("html,body").animate({scrollTop: $('#s2').offset().top - sh}, 800); }); $("#Main_Content").on('click', '#step3', function() { var sh2 = $("#s3").height(); if($(window).width() <= 480){ $("html,body").animate({scrollTop: $('#s3').offset().top - 70}, 800); } else { $("html,body").animate({scrollTop: $('#s3').offset().top}, 800); } }); $("#Main_Content").on('click','.Content_Button',function(){ $('.popupbg').addClass('is-show'); $('.popupbg').html($("#Content"+$(this).attr("sid")).html()); }); $("#Main_Content").on('click','#productlistbox .Pop_Prod_Data',function(){ if(!$(this).is('.button-cant')){ var $class = $(this).attr("class"), $id = $(this).attr("sid"), type = '1'; if($class == 'button-add') { type = '2'; } $('.popupbg').addClass('is-show'); $('.popupbg').attr("type",type); $('.popupbg').html($("#Data-"+$id).html()); $('.popupbg').find(".productView .moreview").owlCarousel({ items: 1, nav: false, dots: true }).on('mouseleave','.owl-stage-outer', function() { var box = $(this).parents(".popupbg"); box.find(".productView .zoonbox").removeAttr('style'); }).on('click','.owl-item', function() { var now = $(this).index(), box = $(this).parents(".popupbg"); box.find(".productView .owl-item").not(this).find('.picitem').removeClass('now'); $(this).find('.picitem').addClass('now'); box.find(".productView .zoonbox").removeClass('now').eq(now).addClass('now'); }).on('mouseenter','.owl-item', function() { var now = $(this).index(), box = $(this).parents(".popupbg"); box.find(".productView .zoonbox").css('display','none').eq(now).css('display','flex'); }); } }); $("#Main_Content").on('click','.informButton',function(){ $("#informID").val($(this).attr("sid")); $('.emailPopup').css('display','flex'); }); $("#Main_Content").on('click','.emailPopup .close',function(){ $('.emailPopup').css('display','none'); }); $("#Main_Content").on('click','.popupbg .close',function(){ $('.popupbg').removeClass('is-show'); $('.popupbg').removeAttr('style'); }); $("#Main_Content").on('click','.Content_Title',function(){ var num = $(this).attr("num"); $(this).parents(".popupbg").find(".Content_Title").css({"color":"#909090","border-top":"1px solid #e2e2e2"}); $(this).css({"color":"#000000","border-top":"1px solid #2f2f2f"}); $(this).parents(".popupbg").find(".Box1,.Box2,.Box3").hide(); $(this).parents(".popupbg").find(".Box"+num).show(); }); $("#Main_Content").on('click','.loginButton',function(){ $('.memberPopup').css('display','flex'); }); $("#Main_Content").on('click','.memberPopup .close',function(){ $('.memberPopup').css('display','none'); }); $("#Change_Pic").click(function(e){ $("#Checkspan").load('/ajax/ajax_get_check_pic.php',{change:1}); }); $("#Main_Content").on('focusin','.input-text',function(){ $(this).next('.text-title').addClass('now'); }); $("#Main_Content").on('focusout','.input-text',function(){ if($(this).val()==''){ $(this).next('.text-title').removeClass('now'); } }); $('.gotop').on('click',function(){ $("html,body").animate({scrollTop: 0},800); }); // $('.header-wrapper').on('click', '.menu-b', function(event) { // $(this).removeClass('menu-b').addClass('menu-b close'); // $(this).next('.header-aside').addClass('open'); // }); // $('.header-wrapper').on('click', '.close', function(event) { // $(this).removeClass('close').addClass('menu-b'); // $(this).next('.header-aside').removeClass('open'); // }); var _window = $(window); _window.on('scroll', function(event) { var scrollTop = _window.scrollTop(); if(scrollTop>0){ $(".gotop").css("opacity","1"); $("body").addClass('is-sticky'); // _body.css('padding-top',body_padding_s+'px'); }else{ $(".gotop").css("opacity","0"); $("body").removeClass('is-sticky'); // _body.css('padding-top',body_padding+'px'); } }); //時間倒數 var num = parseInt($("#CountDown_Box").attr("second"),10), _this = $("#CountDown_Box"); if(num > 0) { setInterval(function() { num--; if(num <= 0) { window.location.reload(); } var day = Math.floor(num/(3600*24)), hour = Math.floor((num - (day*3600*24) )/3600), min = Math.floor((num - (day*3600*24) - (hour*3600) )/60 ), second = num - (day*3600*24) - (hour*3600) - (min*60), pad = '00'; if(day > 0) { _this.find(".timer").eq(0).html(day); _this.find(".timer").eq(1).html(pad.substring(hour.toString().length)+hour); _this.find(".timer").eq(2).html(pad.substring(min.toString().length)+min); _this.find(".timer").eq(3).html(pad.substring(second.toString().length)+second); } else { _this.find(".Date_Box").remove(); _this.find(".timerbox").html(_this.find(".timerbox").html().replace('天','')); _this.find(".timer").eq(0).html(pad.substring(hour.toString().length)+hour); _this.find(".timer").eq(1).html(pad.substring(min.toString().length)+min); _this.find(".timer").eq(2).html(pad.substring(second.toString().length)+second); } },1000); } $("#Main_Content").on("click",".table-button",function(){ $(".table-button").removeClass('now'); $(this).addClass('now'); var type=$(this).data('type'); $(".tableBox").hide(); $("#Box-"+type).show(); $(".wear_report").show(); }); $("#Main_Content").on("click",".table-button1",function(){ $(".table-button1").removeClass('now'); $(this).addClass('now'); var type=$(this).data('type'); $(".tableBox1").hide(); $("#Box1-"+type).show(); $(".wear_report").show(); }); //整套模板 $(document).on('click', '.lookbook-wrapper-show .set-img', function(event) { let cid=$(this).attr('cid'); $(this).parents('.lookbook-wrapper-show').siblings('.cid'+cid).addClass('open') }); $(document).on("click", ".amount .fa", function(){ if($(this).parents(".outfit-popup").length > 0){ return false } let inputField = $(this).parents(".amount").find(".amountBox"), min = inputField.attr("min") ? parseInt(inputField.attr("min")) : 1, max = parseInt(inputField.attr("max")), now = parseInt(inputField.val()) if($(this).hasClass("fa-minus")){ if(now > min){ inputField.val(now - 1) } }else if($(this).hasClass("fa-plus")){ if(now < max){ inputField.val(now + 1) } } }) $(".popup-item .amountBox").on("change",function(){ let now = parseInt($(this).val()), min = $(this).attr("min") ? parseInt($(this).attr("min")) : 1, max = parseInt($(this).attr("max")) if((now < min) || !now){ $(this).val(min) }else if(now > max){ $(this).val(max) } }) $(document).on('click', '.popupbox .close', function(event) { $(".popupbox").removeClass('open'); }); }); //刪除購物車 $("#Main_Content").on('click','.product-del',function() { $.ajax({ url:"/iwoman/ajax/ajax_del_cart.php", type:"POST", cache:false, dataType: 'json', data:{ID:$(this).attr("sid"), Page_Shop_ID:$("#Page_Shop_ID").val()}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Status){ case "RET_SUCCESS": //GA4 if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","remove_from_cart",{ "items":d.GA4 }); } } updatePage('&action=del'); break; case "RET_NO_MEMBER_NO": alert(_jsLang.欲購買紅利兌換商品請先登入會員並完成會員認證); break; case "RET_NO_MEMBER_LEVEL": alert(_jsLang.此橘幣商品有限制會員對應等級); break; case "RET_RBONUS_OUT": alert(_jsLang.紅利不足); break; case "RET_ERROR": alert(_jsLang.資料庫忙線中); break; case "RET_PROD_ERROR": alert(_jsLang商品已下架); break; case "RET_NO_PROD": alert(_jsLang.請選擇商品); break; case "RET_STOCK_ERROR": alert(_jsLang.商品庫存不足); break; case "RET_LIMIT_ERROR": alert(_jsLang.數量超過限購量); break; default: alert(_jsLang.資料庫忙線中); break; }; } }); setTimeout(function () { $('.emptyCartPrompt').fadeOut() }, 5000) }); //修改數量 $("#Main_Content").on('click','.Prod_Plus',function(){ var Amount = parseInt($(this).prev(".Prod_Amount").val())+1, Stock = parseInt($(this).attr("max")); if(Amount > 100 || Amount > Stock) { return false; } $(this).prev(".Prod_Amount").val(Amount).change(); }); $("#Main_Content").on('click','.Prod_Minus',function(){ var Amount = parseInt($(this).next(".Prod_Amount").val())-1; if(Amount < 1) { return false; } $(this).next(".Prod_Amount").val(Amount).change(); }); $("#Main_Content").on('change','.Prod_Amount',function(){ var ID = $(this).parents(".listbox-item").find(".product-del").attr("sid"), Amount = $(this).val(); if(Amount > 100) { Amount = 100; } if(Amount < 1) { Amount = 1; } $.ajax({ url:"/iwoman/ajax/ajax_change_cart.php", type:"POST", cache:false, data:{ID:ID,Amount:Amount,Page_Shop_ID:$("#Page_Shop_ID").val()}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ var d = d.trim(); switch(d){ case "RET_SUCCESS": updatePage(); break; case "RET_NO_MEMBER_NO": alert(_jsLang.欲購買紅利兌換商品請先登入會員並完成會員認證); break; case "RET_NO_MEMBER_LEVEL": alert(_jsLang.此橘幣商品有限制會員對應等級); break; case "RET_RBONUS_OUT": alert(_jsLang.紅利不足); break; case "RET_ERROR": alert(_jsLang.資料庫忙線中); break; case "RET_PROD_ERROR": alert(_jsLang商品已下架); break; case "RET_NO_PROD": alert(_jsLang.請選擇商品); break; case "RET_STOCK_ERROR": alert(_jsLang.商品庫存不足); break; case "RET_LIMIT_ERROR": alert(_jsLang.數量超過限購量); break; default: alert(_jsLang.資料庫忙線中); break; }; } }); }); //活動字串 $("#Main_Content").on('click','#Act_Str_Button',function(){ var str = $("#Act_Str_Input").val(); if(str) { updatePage('&Act_Str='+str); } }); $("#Main_Content").on('click','#Act_Str_Cancel',function(){ updatePage('&Act_Str=Cancel_Act_Str'); }); //切換配送國家 $("#Main_Content").on('change','#Send_Country',function(){ updatePage('&Country='+$(this).val()); }); //切換配送方式 $("#Main_Content").on('click','input[name="Ship_Type"]',function(){ //GA4 if(typeof gtag == 'function') { gtag("event","add_shipping_info",{ "shipping_tier":$(this).data('name') }); } updatePage('&Ship_Type='+$(this).val()); }); //切換付款方式 $("#Main_Content").on('click','input[name="Pay_Type"]',function(){ //GA4 if(typeof gtag == 'function') { gtag("event","add_payment_info",{ "payment_type":$(this).data('name') }); } updatePage('&Pay_Type='+$(this).val()); }); //切換配送城市 $("#Main_Content").on('change','#Send_City',function(){ updatePage('&City='+$(this).val()); }); //切換配送地區 $("#Main_Content").on('change','#Send_Area',function(){ updatePage('&Area='+$(this).val()); }); //選擇門市 $("#Main_Content").on("click","#Choose_Store", function(){ var $return = encodeURIComponent('kol/'+$("#Page_Shop_IDAs").val()+'/#shopcartbox'), $type = $(this).attr("type"), $coll = $(this).attr("coll"); updatePage('&save=1'); setTimeout(function(){ window.location.href = '/shopcart/e_returns/emap-p.php?url='+$return+'&type='+$type+'&coll='+$coll+'&shop_id='+$("#Page_Shop_ID").val(); },500); }); //送出訂單 $("#Main_Content").on('click','#Form_Submit',function(){ $("#Main_Form").submit(); // $('.cart-complete').addClass('in-active');// 開啟結帳完成視窗 // $('body').addClass('in-sticky');// 視窗鎖定 }); // 關閉結帳完成視窗 $('.js-close').on('click', function(e) { $('.cart-complete').removeClass('in-active'); $('body').removeClass('in-sticky'); }) //姓名、電話、Email、地址、備註 $("#Main_Content").on('change','#Send_Name,#Send_Cellphone,#Email,#Send_Address,#Send_Memo',function(){ updatePage('&save=1'); }); //自動加入會員、收貨時間 $("#Main_Content").on('click',"#Auto_Add,input[name='Send_Time']",function(){ updatePage('&save=1'); }); //切換載具類型 $("#Main_Content").on('change',"#CarrierType",function(){ updatePage(); }); //切換發票類型 $("#Main_Content").on('click',"input[name='Invo_Mod']",function(){ updatePage(); }); //同收件地址 $("#Main_Content").on('click','#Invo_Same_Button',function(){ if($(this).prop("checked")) { var same = '1'; $("#Invo_Address_Box").hide(); $("#Invo_Address").attr("fun",""); } else { var same = '2'; $("#Invo_Address_Box").show(); $("#Invo_Address").attr("fun","checkNull"); } updatePage('&Invo_Same='+same+'&save=1'); $("input[name='Invo_Same']").val(same); }); $("#Main_Content").on('click','.title-big',function(){ $(this).parent('section').toggleClass("open",500); }); $("#Main_Content").on('click','.shopcart-link',function(){ $('section').addClass("open",500); }); $('body').on('click','.arrow .title-big', function(event) { // console.log($('.is-nowStep')); if(!$(this).is('.open')){ $('section').not(this).removeClass('open'); $(this).parent('section').addClass('open'); updatePage('&Step='+$(this).parent('section').attr("id").substr(1,1)+'&save=1'); } }); $("#Main_Content").on('click','#step2',function(){ $('#s2').addClass("open",500); $('#s2').addClass("arrow",500); //$(this).parents('.section-wrapper').parent('section').removeClass('open'); updatePage('&Step=2&save=1&MoneyShow=1'); }); $("#Main_Content").on('click','#step3',function(){ $('#s3').addClass("open",500); $('#s3').addClass("arrow",500); //$(this).parents('section').removeClass('open'); updatePage('&Step=3&save=1'); }); //門市國家 $("#Main_Content").on('change','#store_country',function(){ var country = $(this).val(); if(country <= 0) { country = 'none'; } updatePage('&store_country='+country); }); //門市區域 $("#Main_Content").on('change','#store_area',function(){ var area = $(this).val(); if(area <= 0) { area = 'none'; } updatePage('&store_area='+area); }); //門市搜尋 $("#Main_Content").on('click','#searchBtn',function(){ updatePage('&store_search=1'); }); //門市按鈕 $("#Main_Content").on('click','.storeBtn',function(){ if($(this).hasClass("active")) { return false; } updatePage('&Store_ID='+$(this).attr("sid")); }); //推薦門市國家 $("#Main_Content").on('change','#Recommender_country',function(){ var rec_country = $(this).val(); if(rec_country <= 0) { rec_country = 'none'; } updatePage('&Recommender_country='+rec_country); }); //推薦門市區域 $("#Main_Content").on('change','#Recommender_area',function(){ var rec_area = $(this).val(); if(rec_area <= 0) { rec_area = 'none'; } updatePage('&Recommender_area='+rec_area); }); //推薦門市 $("#Main_Content").on('change','#Recommender_Store',function(){ var rec_store = $(this).val(); if(rec_store <= 0) { rec_store = 'none'; } updatePage('&Recommender_Store='+rec_store); }); // 按下我要結帳後出現底部浮動 $("#Main_Content").on('click', '#step2', function() { $('.moneyPrompt').css('display', 'flex').hide().fadeIn() }); //使用禮券 $("#Main_Content").on("click",".gift-sent,.gift-jump",function(){ var usable = ''; $(".Choose_Usable:checked").each(function(){ usable += $(this).val()+','; }); updatePage('&Usable='+usable); }); //取消使用禮券 $("#Main_Content").on('click','.Usable_Cancel',function(){ updatePage('&Cancel_Usable='+$(this).attr("sid")); }); function updatePage(data) { //取得一般配送資料 var send = ''; var data = data || ''; //寄送資料 $("#Send_Name,#Send_Cellphone,#Email,#Send_Address,input[name='Send_Time']:checked,#Send_Memo,#Del_Type,#Auto_Add:checked").each(function(){ send += '&'+$(this).attr("name")+'='+$(this).val(); }); //發票資料 $("input[name='Invo_Mod']:checked,#CarrierType,#CarrierId1,#CarrierId2,#NPOBAN,#Invo_Title,#Invo_No,#Invo_Address").each(function(){ send += '&'+$(this).attr("name")+'='+$(this).val(); }); var $data = 'type=update'+data+send+'&Page_Shop_ID='+$("#Page_Shop_ID").val(); $.ajax({ url:"/iwoman/ajax/ajax_get_cart.php", type:"POST", async: true, data:$data, cache:false, error:function(d,e,f){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $('body').css('overflow','auto'); if(d) { $("#Ajax_Box").html(d); //活動字串訊息 if($("#Coupon_Msg").val()){ alert($("#Coupon_Msg").val()); } $("#Main_Form").fromsAuth({ type:'NONE' }); //加購按鈕 var add = parseInt($("#CanAdd").val()); if(add > 0) { $(".Add_Button").removeClass('button-cant'); $(".Add_Button").html('加購'); } else { $(".Add_Button").addClass('button-cant'); $(".Add_Button").html('未符合加購'); } //滿額按鈕 var gift = parseInt($("#CanGift").val()); if(gift > 0) { $(".Gift_Button").removeClass('button-cant'); $(".Gift_Button").html('挑選'); } else { $(".Gift_Button").addClass('button-cant'); $(".Gift_Button").html('未符合滿額贈品挑選'); } var amount = parseInt($("#ChooseGift").val()); $("#Gift_Amount").html(amount); } } }) } $("#Main_Content").on("click",".add_to_cart",function(){ $('#pdlist-addToCart').remove() }); $("#Main_Content").on("click",".selectPopupBox-buttonbox",function(){ $('.popupbg').removeClass('is-show'); }); //禮券開關 $("#Main_Content").on("click",".gift-jump,.gift-button,.loginButton",function(){ $('.gift-content,.gift-jump').removeClass('is-show'); $('body').removeAttr('style'); }); $("#Main_Content").on("click",".gift",function(){ //未登入 if($(this).hasClass('loginButton')) { return false; } $('.gift-content,.gift-jump').addClass('is-show'); $('body').css('overflow','hidden'); }); // ========================================================== // 主選單開關 // ========================================================== $(".menu-b").click(function(){ $(".header-01").toggleClass("open-nav"); $(".navBox").toggleClass("open-nav"); $('body').toggleClass('in-sticky') $(this).toggleClass('close'); }); //語系選擇 $("#Select_This_Lang3").on("click",".menu_sub_a",function(){ $.post('/ajax/ajax_change_language.php', {Name: $(this).attr('sid')}, function(h){ window.location.reload(); }, 'html'); }); $(document).on("change",".footer-lang-select",function(){ let val = $(this).val() $.post('/ajax/ajax_change_language.php', {Name: val}, function(h){ window.location.reload(); }, 'html'); }); $('#menu-nav').on('click','.item-title',function(){ if($(window).width() > 1025){ var n = $(this).parent(".open").length; var t = $(this).attr("type"); if(t==''){ $('#menu-nav .nav-item').removeClass('open'); $('#menu-nav .menu-item').removeClass('open-sub'); $(".subitembox").removeClass('open-sub'); if(n == 0){ $(this).parent(".nav-item").addClass('open'); } }else{ $('#menu-nav .nav-item').removeClass('open'); $('#menu-nav .menu-item').removeClass('open-sub'); $(".subitembox").removeClass('open-sub'); if(n == 0){ $(this).parent(".nav-item").find("#subitembox"+t).addClass('open-sub'); $(this).parent(".nav-item").addClass('open'); } } } }).on(' click','.subtitle',function(){ if($(window).width() > 1025){ var n = $(this).parent(".open-sub").length; $('#menu-nav .menu-item').removeClass('open-sub'); if(n == 0){ $(this).parent(".menu-item").addClass('open-sub'); } } }); //分享次數 $(".count_share").click(function(e){ var share_id = $(this).attr('outfit-share-id'); var share_num = parseInt($('#share_num'+share_id).text()); $.ajax({ url:"/member/ajax/ajax_add_outfit_shares-p.php", type:"POST", cache:false, async:false, data:{share_id: share_id}, success:function(d){ if(d == 'OK') { $('#share_num'+share_id).text(share_num+1) } } }); }); // ========================================================== // 建立購物跳窗 // ========================================================== ;(function($, jQuery) { $('.preview-wrap').on('click', '.product-pin', function(e) { $(".loading_2").show(); var getAll = []; var urlParams = location.search.slice(1).split("&") urlParams.forEach(function(item){ let tmp = item.split("="); getAll[tmp[0]] = tmp[1]; }); e.preventDefault() jQuery.ajax({ method: 'POST', url: '/ajax/ajax_outfit_popup.php', data: { prodID: $(this).attr('serial'), getMode: getAll['mode'] }, async: true, }).done(res => { $(".loading_2").hide(); const appendData = res $('body').append(appendData) let pics = $('.modal-wrapper .box_pic') if(pics.length > 0){ $('.modal-wrapper .picbox').owlCarousel({ items: 1, nav: false, dots: true }) window.dispatchEvent(new Event('resize')) } }).fail((x, y, z) => { console.log(x, y, z) }) }) })($, jQuery) //穿搭點擊圖片導致商品詳細頁 $(document).ready(function(){ $(document).on('click','.outfit_pic',function(){ window.location.href = "/product-detail/" + $(this).attr('serial'); }); }); // ========================================================== // 跳窗關閉 // ========================================================== ;(function($) { $('body').on('click', '.modal-layer', function(e) { if(!$(e.target).hasClass('stock-info-item') && !$(e.target).hasClass('line-at-btn')){ e.preventDefault() } if(e.target === e.currentTarget || $(e.target).hasClass('modal-closer')) { if($(this).attr('id') == 'stockCheck'){ $(this).removeClass('in-active') }else{ $(this).remove() } } }) $("body").on('click', '.open-modal:not(.detail-link)', function (e) { e.preventDefault(); $(this).parents('.modal-layer').removeClass('in-active') var type = $(this).data('target'); if(type !== '#stockCheck') { $('.modal-layer').removeClass('in-active'); } $(type).addClass('in-active'); }); })($) $(function(){ $("body").on("click",".rack_detail",function(){ var sid = $(this).attr("store_sid"); var flag = $(this).attr("data_id"); var box = $(this); if(!sid){ sid = $(this).attr("sid"); } if(sid && flag != sid){ $.ajax({ url:'/products/ajax/detail/ajax_get_mobile_data.php', type:'POST', data:{'sid':sid}, cache:false, sync:false, dataType:'JSON', error:function(d) { }, success:function(d) { if(d){ box.attr('data_id',sid); $("#stockCheck").find(".modal-content").html(d); } } }); } }); //門市資料 $("body").on('change','.stock-drop',function(){ $('.CityList').hide(); $('.Main-City'+$(this).val()).show(); }); }); // ========================================================== // 猜你喜歡 // ========================================================== $(function(){ let recommend = $(".recommend_l") if(recommend.length > 0){ recommend.owlCarousel({ nav : true, margin:28, responsive:{ 0:{ items : 2, margin:10, }, 480:{ items : 2, margin:15, }, 768:{ items : 3, margin:20, }, 1024:{ items : 4, margin:28, } }, }); } })