$(document).ready(function(){ $("#Main_Form").fromsAuth({type:'NONE'}); var now = new Date(), vYear = now.getFullYear(), vMonth = now.getMonth()+1, vDay = now.getDate()+1, Tomorrow = vYear + '-' + (vMonth<10? "0"+vMonth : vMonth) + '-' + (vDay<10? "0"+vDay : vDay); //日期選擇器SET $(".date").datetimepicker({ format:'YYYY-MM-DD', minDate:Tomorrow }); //加入購物車 $(".inner").on("click",".Add_To_Cart",function(){ var SID = $(this).attr("SID"); if(confirm(_jsLang.確定加入購物車嗎)){ $.ajax({ url:'/ajax/ajax_add_to_cart.php', type:'POST', cache:false, dataType: 'json', data:{SID:SID,num:1,Type:'wishList'}, error:function(d){ alert(d.responseText); }, success:function(d){ if(d.Alert != 'OK'){ alert(d.Alert); } else { 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','購物車','加入購物車'); gtag('event', 'conversion', {'send_to': 'AW-670123971/gFIbCNO99cIBEMOPxb8C'}); } if(d.FBQ){ eval(d.FBQ); PDA_AddToCart(d.IDs2); } if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } Rosetta_AddToCart(d.IDs3); SAYA_AddToCart(); Avivid_AddToCart(); } window.location.reload(); } }); } }); //下次買 $(".inner").on('click','.Next_Buy',function(){ if(confirm(_jsLang.確定加入願望清單嗎)){ $(".loading").show(); $.ajax({ url:"/shopcart/ajax/ajax_cart_next.php", type:"POST", cache:false, dataType: 'json', data:{ID:$(this).attr("sid")}, 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 = $("#Website_Mall_ID").val()+'/member-login/'; break; default: alert(_jsLang.資料庫忙線中); break; } } }); } }); //變更預約試衣清單商品尺寸 $(".inner").on("change",".size-select",function(){ var SID = $(this).val(); var OSID = $(this).attr('OSID'); $.ajax({ url:'/ajax/ajax_reservation_list.php', type:'POST', cache:false, dataType: 'json', data:{SID:SID, OSID:OSID, Type:"Change"}, error:function(d){ alert(d.responseText); }, success:function(d){ alert(d.Alert); window.location.reload(); } }); }); //刪除預約試衣清單商品 $(".inner").on("click",".Del_Reservation_List",function(){ var SID = $(this).attr("SID"); if(confirm(_jsLang.確定移除這個項目嗎)){ $.ajax({ url:'/ajax/ajax_reservation_list.php', type:'POST', cache:false, dataType: 'json', data:{SID:SID,Type:"Del"}, error:function(d){ alert(d.responseText); }, success:function(d){ alert(d.Alert); window.location.reload(); } }); } }); //預約門市切換國家 $(".inner").on("change","#country",function(){ var the_sub ='area'; $.ajax({ type: "POST", url: "/ajax/ajax_get_rsv_rack_country-p.php", data: "&Country_Type=" + $(this).val(), async: false, dataType: 'json', success: function(jsonObj){ $("#" + the_sub).children("option:gt(0)").remove(); for(k in jsonObj){ $("#" + the_sub).append(''); } } }); }); //預約門市切換區域 $(".inner").on("change","#area",function(){ $('#storeBox').hide(); }); //查詢預約門市 $(".inner").on("click","#searchBtn",function(){ var the_sub = 'storeBox', country = $('#country').val(), area = $('#area').val(); if(!country){ alert('請選擇國家'); return false; } if(!area){ alert('請選擇區域'); return false; } $.ajax({ type: "POST", url: "/ajax/ajax_get_rsv_rack_class-p.php", data: "&Rack_Class_ID=" + area, async: false, dataType: 'json', success: function(jsonObj){ var h = ''; for(k in jsonObj){ h += '' + jsonObj[k] + ''; } $("#" + the_sub).html(h); } }); $('#storeBox').show(); }); //選擇預約門市 $(".inner").on("click",".storeBtn",function(){ $(this).addClass('active'); $('.storeBtn').not(this).removeClass('active'); var rid = $(this).attr('value'); $.ajax({ url:'/ajax/ajax_get_rsv_rack_data-p.php', type:'POST', cache:false, dataType: 'json', data:{RID:rid}, error:function(d){ alert(d.responseText); }, success:function(d){ $("#R_Store").val(rid); $(".googleMap").html(d.Map); var h = ''; for(k in d.Time){ h += '' + d.Time[k] + ''; } $("#timeBox").html(h); $('#timeBox').show(); } }); }); //選擇預約試衣商品(單次最多10件) $(".inner").on("click",".choiceMultiple",function(){ var _this = $(this), tmp = [], cnt = 1; $("input[class=choiceMultiple]:checked").each(function(){ if(cnt > 10){ _this.prop('checked',false); alert("單次預約最多10件商品"); }else{ tmp.push($(this).val()); } cnt++; }); $("#R_Prod").val(tmp.join(',')); }); //選擇預約時段 $(".inner").on("click",".timeBtn",function(){ $(this).addClass('active'); $('.timeBtn').not(this).removeClass('active'); var time_id = $(this).attr('value'); $("#R_Time").val(time_id); }); //展開預約試衣說明 $(".inner").on("click",".explain",function(){ $('.popBox').addClass('open'); }); //關閉預約試衣說明 $(".inner").on("click",".closeExplain",function(){ $('.popBox').removeClass('open'); }); })