$(document).ready(function(){ //增加 $('.combosBox').on('click','.button1',function(e){ var _this = $(this), id = _this.attr("sid"), group = _this.attr("group"), num = _this.parents(".productBox").find(".num-select").val(), parent = _this.attr("parent"); if(id && num){ $.ajax({ url:Project_Country+'activities/ajax/act8/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'add',group:group,id:id,Amount:num,parent:parent}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#Act_Title_Box").html(d); if($("#Alert_Msg").val()){ alert($("#Alert_Msg").val()); }else{ order_add(_this); } } }); }else{ if(!id){ alert(_jsLang.請選擇尺寸與規格); }else if(!num){ alert(_jsLang.請選擇數量); } return false; } }); //減少 $(".user-orderBox").on('click','.delete',function(){ var id = $(this).attr("sid"), group = $(this).attr("group"), parent = $(this).attr("parent"); $.ajax({ url:Project_Country+'activities/ajax/act8/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'del',group:group,id:id,parent:parent}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#Act_Title_Box").html(d); } }); }); //加入購物車 $(document).on('click','.Add_Tmp_To_Cart',function(){ //固定模式 if($(this).attr("type") == "Stable"){ var Prod = ""; $(".orderProduct .button1").each(function(){ Prod += $(this).attr("group")+"="+$(this).attr("sid")+","; }); } $.ajax({ url:Project_Country+'activities/ajax/ajax_add_to_cart.php', type:"POST", cache:false, async:true, data:{Act_Type:$(this).attr("act_type"),Act_ID:$(this).attr("act_id"),ID:$(this).attr("prod_id")}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ if(d.Msg) { alert(d.Msg); } else { switch(d.status){ case "RET_SUCCESS": case "RET_SUCCESS_OVER_ACT9": if(d.dataLayer){eval(d.dataLayer)} alert(d.alert); window.location.reload(); break; default: alert(d.alert); break; }; } } }); }); }); function order_add(_this){ const product = _this.parents('.productBox') const product_title = product.find('.title').text() const product_img = product.find('img').attr('src') const product_price = product.find('.price-digit').text() const product_num = product.find('.num-select').val() const product_spec = product.find('.color-select').find('option:selected').text() const product_group = _this.attr("group") const product_id = _this.attr("sid") const product_parent = _this.attr("parent") const n = _this.parents('.combos').index(); const html = `
${product_title}
${(product_spec? product_spec: _jsLang.單一規格)}
${_jsLang.Language_Currency + product_price}
` const slideWrapper = $('.user-orderBox') slideWrapper.addClass('in-active') setTimeout(function() { slideWrapper.removeClass('in-active') }, 1000) order_animate(product,html,'.'+_this.parents('.combos').attr("group"),product_num); } function order_animate(product,html,combos,num){ var choseImg = product.find('.productImg'), Img_html = choseImg.clone().addClass('moveImg'), choseImg_top = product.offset().top, choseImg_left = product.offset().left, choseImg_width = product.width(), choseImg_height = product.height(); if($('.user-orderBox').find(combos).length!=0){ var orderBox_change = $('.user-orderBox').find(combos).eq(0), changeBox_top = orderBox_change.offset().top, changeBox_left = orderBox_change.offset().left, changeBox_width = orderBox_change.width(), changeBox_height = orderBox_change.height(); $('body').append(Img_html); $('.moveImg').css({ 'top':choseImg_top, 'left':choseImg_left, 'width':choseImg_width, 'height':choseImg_height }).animate({ 'top':changeBox_top, 'left':changeBox_left, 'width':changeBox_width, 'height':changeBox_height },300,function(){ $(this).remove(); orderBox_change.after(html).remove(); num = num-1; if(num >0){ order_animate(product,html,combos,num); } }); } } // ========================================================== // 複製連結 // ========================================================== $(function(){ $(document).on("click", ".copy-btn", function(e){ e.preventDefault() navigator.clipboard.writeText($(this).data("link")) alert("複製連結成功") }) })