$(document).ready(function () { $("html,body").animate({scrollTop: $('.login-offset').offset().top-150},800); //商品加減 $(document).on('click','.Prod_Amount',function(){ var _this = $(this), box = _this.parents('.numberBox'), ID = box.find(".amountBox").attr("sid"), Act = box.find(".amountBox").attr("act"), Ch_Flag = box.find(".amountBox").attr("ch"), Amount = 0, max = box.find(".amountBox").attr("max"); $("#Shopcart_List").find(".amountBox[sid='"+ID+"']").each(function(){ Amount += parseInt($(this).val()) || 0; }); //會計算到手機版所以除以2 Amount = Amount/2; if(_this.hasClass("fa-minus")) { Amount -= 1; if(Amount <= 1) { Amout = 1; } } else { Amount += 1; if(Amount > max) { Amount = max; } } if(ID && Amount) { var data = 'ID='+ID+'&Amount='+Amount+'&Act='+Act+'&Ch_Flag='+Ch_Flag; loadChangeProd(box,data); } }); //商品修改數量 $(document).on('change','.Prod_Amount_Change',function(){ var box = $(this).parents('.numberBox'), ID = $(this).attr("sid"), Act = $(this).attr("act"), Ch_Flag = $(this).attr("ch"), Amount = 0, max = $(this).attr("max"); //變更手機版數量 $(this).parents(".Product_Box").find(".Prod_Amount_Change").val($(this).val()); $("#Shopcart_List").find(".amountBox[sid='"+ID+"']").each(function(){ Amount += parseInt($(this).val()) || 0; }); //會計算到手機版所以除以2 Amount = Amount/2; if(Amount <= 1) { Amout = 1; } if(Amount > max) { Amount = max; } if(ID && Amount) { var data = 'ID='+ID+'&Amount='+Amount+'&Act='+Act+'&Ch_Flag='+Ch_Flag; loadChangeProd(box,data); } }); function loadChangeProd(box,data) { //載入中 box.next('.number-load').css('display','inline-block'); box.next('.amountBox').css('cursor','no-drop').attr('disabled','disabled'); box.next('.fa').css('cursor','no-drop'); //鎖定數量 $(".Prod_Amount").removeClass("Prod_Amount"); $("#Shopcart_List").find(".amountBox").prop("disabled",true); //增加數量 $.ajax({ url:"/shopcart/ajax/ajax_cart_edit.php", type:"POST", cache:false, data:data, dataType: 'json', 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","add_to_cart",{ "items":d.GA4 }); } } updatePage(); break; case "RET_NO_MEMBER_NO": 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_Form").fromsAuth({ type:'NONE', callafter:function(){ if(typeof ga == 'function') { var obj = JSON.parse($("#GA_Data").text()); for(var key in obj) { ga('ec:addProduct',obj[key]); } ga('ec:setAction','checkout',{ 'step':4 }); ga('send','event','購物車','確認訂單'); } if(typeof fbq == 'function') { fbq('track','AddPaymentInfo'); } return true; } }); var _window = $(window); var change = 0; var moreview = false; var change_1023 = 1024; if(_window.width() < 1024){ var slide = $(".sildeBox"); slide.owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); }else{ if($(".sildeBox .productBox").length>4){ var slide = $(".sildeBox"); slide.owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 4 } }, nav : true, navText : ['',''], }); } } //if(_window.width() > 480 && change_1023 == 1024){ if(_window.width() > 0){ change_1023 = 480; //if($('.content_1 .click-block').length >3){ if($('.content_1 .click-block').length >1){ $('.content_1 .click-block').css('width',"98%"); $('.oproduct-tagcontent .content_1').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } //if($('.content_2 .click-block2').length >3){ if($('.content_2 .click-block2').length >1){ $('.content_2 .click-block2').css('width',"98%"); $('.oproduct-tagcontent .content_2').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } //if($('.content_3 .click-block').length >3){ if($('.content_3 .click-block').length >1){ $('.content_3 .click-block').css('width',"98%"); $('.oproduct-tagcontent .content_3').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } } $(document).on('click','.click-pic',function(){ // prodpop-new popBox var ID = $(this).data('id'); $.post('/shopcart/ajax/ajax_prodnew.php',{'ID':ID},function(data){ $('.prodpop-new').replaceWith(data) $('.prodpop-new').css('display','block'); }) }); $(document).on('click','.prodpop-new .close',function(){ $('.prodpop-new').css('display','none'); }); //購物車無資料,導回step1 if(parseInt($("#Main_Form").attr('cart_num'))< 1 || $("#Main_Form").attr('cart_num')==''){ Shopcart_Step_Go('step1'); } //選擇步驟 $("#Main_Content").on('click','.Step_Button',function(){ var step = $(this).attr('step'); Shopcart_Step_Go(step); }); window.onpopstate = function(e) { var step = 'step1'; if(e.state) { step = e.state.step; } Shopcart_Step_Go(step,2); } function Shopcart_Step_Go(step,type=1){ //步驟按鈕樣式 $("#Main_Content").find('.Step_Button').each(function(){ //初始步驟樣式 $(this).removeClass('now'); var chk_step = $(this).attr('step'); //目前步驟樣式 if(step == chk_step){ $(this).addClass('now'); } }); //步驟區塊開啟或關閉 $("#Main_Content").find('.Step_Block').each(function(){ //初始步驟區塊(關閉) $(this).addClass('hide'); var chk_step = $(this).attr('step'); //開啟目前步驟區塊 if(step == chk_step){ $(this).removeClass('hide'); } }); //切換網址 if(type == 1) { var new_url = '/shopcart/'+step; window.history.pushState({step:step},'shopcart',new_url); } //重載頁面記錄目前步驟SESSION updatePage('&step='+step); $(window).scrollTop(0); if(typeof ga == 'function') { var obj = JSON.parse($("#GA_Data").text()), ga_step = '', ga_title = ''; if(step == 'step1') { ga_step = '1'; ga_title = '進入購物車'; } else { ga_step = '2'; ga_title = '填寫寄送資料'; } for(var key in obj) { ga('ec:addProduct',obj[key]); } ga('ec:setAction','checkout',{ 'step':ga_step }); ga('send','event','購物車',ga_title); } } $(document).on('click','.click-block2 .button2',function(e){ e.preventDefault(); $(".loading").show(); var SID = $(this).attr('sid'); var Amount = $(this).parents('.click-block2').find('.num').val(); if(!$.isNumeric(Amount)){ alert(_jsLang.請選擇數量); return false; } $.ajax({ url:"/shopcart/ajax/ajax_cart_add.php", type:"POST", cache:false, data:{"ID":SID,"Amount":Amount}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Status){ case "RET_SUCCESS": 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.GA_conversion && typeof gtag == 'function') { gtag('event', 'conversion', {'send_to':d.GA_conversion}); } //GA4 if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } if(d.FBQ){eval(d.FBQ)} alert(_jsLang.加入購物車成功); updatePage(); break; case "RET_NO_MEMBER_NO": 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','.prod_del',function(){ if(confirm(_jsLang.確定刪除嗎+"?")){ $(".loading").show(); $.ajax({ url:"/shopcart/ajax/ajax_cart_del.php", type:"POST", cache:false, data:{ID:$(this).attr("sid"),Act:$(this).attr("act"),Ch_Flag:$(this).attr("ch")}, dataType:'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ if(d.Status == 'RET_SUCCESS') { if(d.GA && typeof ga == 'function') { for(var key in d.GA) { ga('ec:addProduct',d.GA[key]); } ga('ec:setAction','remove'); ga('send','event','購物車','移除購物車'); } //GA4 if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","remove_from_cart",{ "items":d.GA4 }); } } alert(_jsLang.刪除成功); updatePage(); } else { alert(_jsLang.資料庫忙線中); } } }); } }); //刪除願望清單 $("#Main_Content").on('click','.wish_del',function(){ if(confirm(_jsLang.確定刪除嗎+"?")){ $(".loading").show(); $.ajax({ url:"/shopcart/ajax/ajax_wishlist_del.php", type:"POST", cache:false, data:{ID:$(this).attr("sid")}, dataType:'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ if(d.Status == 'RET_SUCCESS') { alert(_jsLang.刪除成功); updatePage(); } else { alert(_jsLang.資料庫忙線中); } } }); } }); //下次買 $("#Main_Content").on('click','.prod_next',function(){ if(confirm(_jsLang.確定加入喜愛清單嗎)){ $(".loading").show(); $.ajax({ url:"/shopcart/ajax/ajax_cart_next.php", type:"POST", cache:false, data:{ID:$(this).attr("sid"),Act:$(this).attr("act"),Ch_Flag:$(this).attr("ch")}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Msg){ case "RET_SUCCESS": if(d.FBQ){eval(d.FBQ)} alert(_jsLang.加入喜愛清單成功); updatePage(); break; case "RET_NO_MEMBER": alert(_jsLang.請先登入會員); window.location.href = '/member-login'; break; default: alert(_jsLang.資料庫忙線中); break; } } }); } }); //加購加減 $(document).on('click','.Amount_Minus',function(){ var amount = parseInt($(this).next(".amountBox").val()) || 0; amount -= 1; if(amount < 1) { amount = 1; } $(this).next(".amountBox").val(amount); }); $(document).on('click','.Amount_Plus',function(){ var amount = parseInt($(this).prev(".amountBox").val()) || 0, max = parseInt($(this).prev(".amountBox").attr("max")); amount += 1; if(amount > max) { amount = max; } $(this).prev(".amountBox").val(amount); }); //加購商品 $(document).on('click','#All_Add_List .button2,#Full_Add_List .button2',function() { //媽媽餵需求須檢查尺寸 var size = $(this).parents('.productBox').find('.size-select'); if(size.length > 0 && !size.val()) { alert(_jsLang.請先選擇尺寸); return false; } //媽媽餵需求須檢查罩杯 var sp3 = $(this).parents('.productBox').find('.sp3-select'); if(sp3.length > 0 && !sp3.val()) { alert(_jsLang.請先選擇規格三); return false; } $(".loading").show(); $.ajax({ url:"/shopcart/ajax/ajax_cart_add.php", type:"POST", cache:false, data:{ID:$(this).attr("sid"),Amount:$(this).parents(".productBox").find(".amountBox").val()}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Status){ case "RET_SUCCESS": 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.GA_conversion && typeof gtag == 'function') { gtag('event', 'conversion', {'send_to':d.GA_conversion}); } //GA4 if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } if(d.FBQ){eval(d.FBQ)} alert(_jsLang.加入購物車成功); updatePage(); break; case "RET_NO_MEMBER_NO": 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','.money-button',function(e){ var $data = 'cate='+$(this).attr("cate")+'&value='; if($(this).attr("class").indexOf("usd") != -1 && $(this).attr("cate") != 'Usable'){ e.preventDefault(); updatePage($data); } }); //優惠折扣送出 $("#Main_Content").on('click','.money-send',function(e){ e.preventDefault(); if($(this).attr("cate") == 'NRBonus' || $(this).attr("cate") == 'RBonus' || $(this).attr("cate") == 'ActStr' || $(this).attr("cate") == 'Deposit') { var $data = 'cate='+$(this).attr("cate")+'&value='+$(this).parents("p").find("input").val(); } else if($(this).attr("cate") == 'MemberMoney') { var $data = 'cate='+$(this).attr("cate")+'&value='+$(this).parents("span").find("input").val(); } else if($(this).attr("cate") == 'Usable') { var $data = 'cate='+$(this).attr("cate")+'&value='+$("#usable_no").val(); }else { var $data = 'cate='+$(this).attr("cate")+'&value='+$(this).parents("span").find("input").val(); } updatePage($data); }); //購物金勾選 $("#Main_Content").on('click',"input[name='use_bonus']",function(){ var $data = 'cate=Bonus&value='+$(this).val(); updatePage($data); }); // //禮物卡勾選 // $("#Main_Content").on('click',"input[name='usable_no']",function(){ // $("#usable_no").val($(this).val()); // }); //選擇配送國家 $("#Main_Content").on('click',"input[name='Country_Type']",function(){ switch($(this).val()){ case "1": case "2": var $data = 'countryType='+$(this).val(); break; case "3": var $data = 'countryType=3&country='+$("#Country").val(); break; } updatePage($data); $.ajax({ url:"/ajax/ajax_get_city-p.php", type:"POST", cache:false, data:{"Send_ID":$("#Send_Country_ID option:eq(1)").val()}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ var the_sub = 'Send_City_ID'; $("#" + the_sub).children("option:gt(0)").remove(); for(k in d){ $("#" + the_sub).append(''); } } }); }); $("#Main_Content").on('change',"#Country",function(){ var $data = 'countryType=3&country='+$(this).val(); updatePage($data); }); //選擇運送方式 $("#Main_Content").on('click',"input[name='Ship_Type']",function(){ //GA4 if(typeof gtag == 'function') { gtag("event","add_shipping_info",{ "shipping_tier":$(this).data('name') }); } var $data = 'shipType='+$(this).val(); updatePage($data); }); $("#Main_Content").on("click","#Choose_Store", function(){ updatePage(); window.location.href = '/shopcart/e_returns/emap-p.php?url=shopcart/&type='+$(this).attr("type")+'&coll='+$(this).attr("coll"); }); //選擇付款方式 $("#Main_Content").on('click',"input[name='Pay_Type']",function(){ var $data = 'payType='+$(this).val(); if($(this).val() == 5)$data += '&countryType=1'; updatePage($data); if(typeof ga == 'function') { var obj = JSON.parse($("#GA_Data").text()); for(var key in obj) { ga('ec:addProduct',obj[key]); } ga('ec:setAction','checkout',{ 'step':3 }); ga('send','event','購物車','選擇付款方式'); } //GA4 if(typeof gtag == 'function') { gtag("event","add_payment_info",{ "payment_type":$(this).data('name') }); } }); //選擇使用禮物卡 $("#Main_Content").on('click',"input[name='usable_no[]']",function(){ var check = new Array(); $('input:checkbox:checked[name="usable_no[]"]').each(function(i){ check[i]=this.value; }); var $data = 'usable_no='+check+'&usable=1&cate=Usable'; updatePage($data); }); //選擇商品 $("#allCheck").change(function(){ if($(this).is(":checked")){ var $data = 'checkAll=y'; }else{ var $data = 'checkAll=n'; } updatePage($data); }); //選擇商品 $("#Main_Content").on('click',"input[name='cartID']",function(){ var check = new Array(); $('input[type="checkbox"][name="cartID"]:not(:checked)').each(function(i){ check[i]=this.value; }); var $data = 'cartID='+check; updatePage($data); }); //全選與反全選 $("#Main_Content").on('click',"input[name='AllSelect']",function(){ var All = $('input[type="checkbox"][name="AllSelect"]:checked').val(); if(All=="1"){ check = "all"; }else{ check = "none"; } var $data = 'AllSelect='+check; updatePage($data); }); //願望清單加入購物車 $("#Main_Content").on('click',"input[name='wishID']",function(){ var wishID = $('input[type="checkbox"][name="wishID"]:checked').val(); $.ajax({ url:"/shopcart/ajax/ajax_cart_add.php", type:"POST", cache:false, data:{"ID":wishID,"Amount":'1'}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Status){ case "RET_SUCCESS": 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.GA_conversion && typeof gtag == 'function') { gtag('event', 'conversion', {'send_to':d.GA_conversion}); } //GA4 if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } if(d.FBQ){eval(d.FBQ)} alert(_jsLang.加入購物車成功); updatePage(); break; case "RET_NO_MEMBER_NO": 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',"input[name='Premiu']",function(){ var $data = 'premiu='+$(this).val(); updatePage($data); }); //國家切換 $("#Main_Content").on('change',".Country",function(){ var Send_ID = $(this).val(); if($('.office_name_area').length > 0){ $('.office_name_area').hide(); $('.office_name_area #Send_Office_Name #Send_Identity').attr('fun', ''); $('.office_name_area #Send_Office_Name #Send_Identity').attr('value', ''); } $.ajax({ url:"/ajax/ajax_get_city-p.php", type:"POST", cache:false, data:{"Send_ID":Send_ID}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ var the_sub = 'Send_City_ID'; $("#" + the_sub).children("option:gt(0)").remove(); for(k in d){ $("#" + the_sub).append(''); } if($('input[name="Trans_Com_ID"]').val() == '12' && $('.office_name_area').length > 0){ $('.office_name_area').show(); $('.office_name_area #Send_Office_Name #Send_Identity').attr('fun', 'checkNull'); } } }); }); //縣市切換 $("#Main_Content").on('change',".City",function(){ updatePage(); }); //地區切換 $("#Main_Content").on('change',".Area",function(){ var opt = $(this).find("option:selected").text(), area = opt.split(" "), zip = area[0]; $("#Send_Area_No").val(zip); }); //同訂購人資料 $("#Main_Content").on('click',"#Same_Button",function(){ var $data = 'same=1'; updatePage($data); }); //預設發票地址 var Del_Type = $("#Del_Type").val(); var Send_Address = $("#Send_Address").val() || ''; var Send_Area_ID = $("#Send_Area_ID option:selected").attr("name") || ''; var Send_City_ID = $("#Send_City_ID option:selected").attr("name") || ''; var Send_Addr_Full = Send_City_ID+Send_Area_ID+Send_Address; if(Send_Addr_Full && Del_Type !='2'){ $("#Invo_Same_Button").prop("checked",true); $("#Invo_Address").val(Send_Addr_Full); } //同訂購人資料 $("#Main_Content").on('click',"#Invo_Same_Button",function(){ var dt = $(this).attr('dt'); if($("#Invo_Same_Button").prop("checked") && dt != '2'){ var Send_Address = $("#Send_Address").val() || ''; var Send_Area_ID = $("#Send_Area_ID option:selected").attr("name") || ''; var Send_City_ID = $("#Send_City_ID option:selected").attr("name") || ''; $("#Invo_Address").val(Send_City_ID+Send_Area_ID+Send_Address); } }); //從通訊錄中挑選 $("#Main_Content").on('click',".Send_Book",function(){ var $data = 'send_book='+$(this).attr("sid"); updatePage($data); }); //門市取貨 $("#Main_Content").on("change","#Store_Pick",function(){ var $data = 'CVSStoreID='+$(this).val(); updatePage($data); }); //發票載具 $("#Main_Content").on('change',"#CarrierType",function(){ updatePage(); }); //送出 $("#Main_Content").on('click',"#Form_Submit",function(){ var gift = $("#Left_Gift").val(); if(gift > '0'){ alert(_jsLang.尚可挑選+gift+_jsLang.件贈品請挑選後再送出購物車); }else{ //判斷超取收件人的姓名長度 (超取在正式區的val為2,測試區為) var Ship_Type_Val = $("input[name=Ship_Type]:checked").val(); if(Ship_Type_Val == '3' || Ship_Type_Val == '2'){ var rex = /[^\u4e00-\u9fa5]/; var Send_Name = $("#Send_Name").val(); if(rex.test(Send_Name) || Send_Name.length < 2 || Send_Name.length > 5){ alert("超取收件人姓名限中文,2~5個字"); }else{ $("#Main_Form").submit(); } }else{ $("#Main_Form").submit(); } } }); //雲端發票資料同步 $("#Main_Content").on('click',"input[name='Invo_Mod']",function(){ updatePage(); }); $("#Main_Content").on('change',"#Invo_Mod2",function(){ $("#changeradio-0"+$(this).val()).prop("checked",true); updatePage(); }); $("#Main_Content").on('click',"input[name='Invo_Send_Type']",function(){ updatePage(); }); $("#Main_Content").on('change', "input[name='Invo_Type']",function(){ if($(this).val() == 1){ $(".invo_type1").hide(); } else{ $(".invo_type1").show(); } updatePage(); }); /* $("#Main_Content").on('click','#Invo_Agree',function(){ var val = $(this).prop('checked'), data = '&Invo_Agree='+val; updatePage(data); }); */ }); function updatePage($data){ $(".loading").show(); var $member = ""; var $invo = ""; $(".card_content").each(function(){ $member += '&'+$(this).attr("name")+'='+$(this).val(); }); $("#Buy_Data").find("input:text,input:checked,select,input:password").each(function(){ $member += '&'+$(this).attr("name")+'='+$(this).val(); }); $("#Send_Data").find("input:text,input:hidden,input:checked,select,textarea,input:password").each(function(){ $member += '&'+$(this).attr("name")+'='+$(this).val(); }); $member += '&Send_Cellphone='+$("#Send_Cellphone").val(); $member += '&Send_Tel='+$("#Send_Tel").val(); $("#Invo_Data").find("input:text,input:checked,select").each(function(){ $invo += '&'+$(this).attr("name")+'='+$(this).val(); }); $invo += '&Member_Agree='+$("#Member_Agree").val(); var check = new Array(); $('input:checkbox:checked[name="usable_no[]"]').each(function(i){ check[i]=this.value; }); var $usable = '&usable_no='+check; var final = $data+$member+$invo+$usable+'&updatePage=1'; final = final.replace(/\+/g,'%2B'); $.ajax({ url:"/shopcart/ajax/ajax_cart_update.php", type:"POST", cache:false, async:false, data:final, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ var _window = $(window); var change_1023 = 1024; $("#Main_Content").html(d); //if(_window.width() > 480 && change_1023 == 1024){ if(_window.width() > 0){ change_1023 = 480; //if($('.content_1 .click-block').length >3){ if($('.content_1 .click-block').length >1){ $('.content_1 .click-block').css('width',"98%"); $('.oproduct-tagcontent .content_1').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } //if($('.content_2 .click-block2').length >3){ if($('.content_2 .click-block2').length >1){ $('.content_2 .click-block2').css('width',"98%"); $('.oproduct-tagcontent .content_2').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } //if($('.content_3 .click-block').length >3){ if($('.content_3 .click-block').length >1){ $('.content_3 .click-block').css('width',"98%"); $('.oproduct-tagcontent .content_3').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 3 } }, nav : true, navText : ['',''], }); } } $("#Main_Form").fromsAuth({ type:'NONE', callafter:function(){ if(typeof ga == 'function') { var obj = JSON.parse($("#GA_Data").text()); for(var key in obj) { ga('ec:addProduct',obj[key]); } ga('ec:setAction','checkout',{ 'step':4 }); ga('send','event','購物車','確認訂單'); } if(typeof fbq == 'function') { fbq('track','AddPaymentInfo'); } return true; } }); var bill = JSON.parse(base64_decode($("#Bill_Update").val())); for(s in bill){ $("#Bill_"+s).html(bill[s]); } if($("#Coupon_Msg").val()){ alert($("#Coupon_Msg").val()); } $("#Shop_Cart_Total > .num").html($("#Shop_Cart_Total_Update").val()); //下方選單 $("#Shop_Cart_Total_Bottom").html($("#Shop_Cart_Total_Update").val()); var slide = $(".sildeBox"); slide.owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 960:{ items : 4 } }, nav : true, }); //修改國旗圖片 $.post('/ajax/ajax_change_country.php', {Type:'update',ID: $(this).attr('sid')}, function(h){ if(h){ $("#This_Country_Pic").attr("src","/upload_files/fonlego-rwd/website/"+h); } }, 'html'); $(".loading").fadeOut(); var file_Obj = new prod_file({ amountBox:'num-select', specUrl: '/shopcart/ajax/ajax_get_item.php', ordButton:'button2' }); file_Obj.init(); } }); }