$(document).ready(function(){ //增加 $('.combosBox').on('click','.button1',function(e){ var _this = $(this), id = _this.attr("sid"), num = _this.parents(".productBox").find(".num-select").val(), parent = _this.attr("parent"); if(id && num){ $.ajax({ url:Project_Country+'activities/ajax/act7/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'add',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-list6 .orderSlide").on('click','.delete',function(){ var id = $(this).attr("sid"), parent = $(this).attr("parent"); $.ajax({ url:Project_Country+'activities/ajax/act7/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'del',id:id,parent:parent}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#Act_Title_Box").html(d); } }); }); //加入購物車 $("#Act_Title_Box").on('click','.Add_Tmp_To_Cart',function(){ $.ajax({ url:Project_Country+'activities/ajax/ajax_add_to_cart.php', type:"POST", cache:false, async:true, data:{Act_Type:$(this).attr("act_type"),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": if(d.DataLayer){eval(d.DataLayer)} alert(_jsLang.加入購物車成功); window.location.reload(); 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; case "RET_OVER_SIT_MAX": alert(_jsLang.數量超過定期購限購量); break; case "RET_PROD_IN_ONESHOPPAGE_ERROR": alert(_jsLang.此商品於一頁式購物推廣中+','+_jsLang.暫無法加入購物車); break; case "RET_NO_MEMBER": alert(_jsLang.欲購買會員等級限制商品請先登入會員); break; case "RET_ERROR_LEVEL": alert(_jsLang.此會員等級暫無法加入購物車); break; default: alert(_jsLang.資料庫忙線中); 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_id = _this.attr("sid") const product_parent = _this.attr("parent") const add_array = new Array() add_array[0] = 0; $(".delete").each(function(){ add_array.push(parseInt($(this).attr("sid"))); }); var img_index = Math.max.apply(null,add_array); 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(); var orderBox_change = $('.user-orderBox'), changeBox_top = orderBox_change.offset().top, changeBox_left = orderBox_change.offset().left, changeBox_width = orderBox_change.width()/5, changeBox_height = orderBox_change.height()-20; for($i=0;$i
${product_title}
${(product_spec ? product_spec: _jsLang.單一規格)}
${_jsLang.Language_Currency + product_price}
`; $(".user-list6 .orderSlide").trigger('to.owl.carousel',[0,0,true]) .trigger('add.owl.carousel',[$(html),0]) .trigger('refresh.owl.carousel'); } const slideWrapper = $('.user-orderBox') slideWrapper.addClass('in-active') setTimeout(function() { slideWrapper.removeClass('in-active') }, 1000) $('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(); }); }