$(document).ready(function(){
/*上方banner廣告圖*/
$(".top_productbox").owlCarousel({
loop : false,
responsive:{
0:{
items : 2
},
320:{
items : 3
},
480:{
items : 6
},
660:{
items : 8
},
768:{
items : 9
},
960:{
items : 10
},
1023:{
items : 12
}
},
nav : true,
});
//增加商品
$(".col-60").on("click",".add_to_tmp",function(){
var _this = $(this);
_item = _this.parents(".prodbox");
$.ajax({
url:"/activities/ajax/act14/ajax_set_cart.php",
type:"POST",
data:{type:'add',Prod_Sell_ID:_this.attr("SID"),Amount:_item.find(".amountBox").val()},
success:function(d){
$("#Total_Div").html(d);
_item.addClass("click");
_this.removeClass("add_to_tmp").addClass("del_from_tmp");
_this.html('取消選購');
}
});
});
//取消商品
$(".col-60").on("click",".del_from_tmp",function(){
var _this = $(this);
_item = _this.parents(".prodbox");
$.ajax({
url:"/activities/ajax/act14/ajax_set_cart.php",
type:"POST",
data:{type:'del',Prod_Sell_ID:_this.attr("SID")},
success:function(d){
$("#Total_Div").html(d);
_item.removeClass("click");
_this.removeClass("del_from_tmp").addClass("add_to_tmp");
_this.html('選購');
}
});
});
//活動-直接加入購物車
$(".Add_Tmp_To_Cart").on('click',function(){
var box = $(this).parents(".prodbox");
$.ajax({
url:'/activities/ajax/ajax_add_to_cart.php',
type:"POST",
cache:false,
async:true,
data:{Act_Type:$(this).attr("act_type"),Num:box.find(".amountBox").val(),Prod:$(this).attr("SID")},
dataType: 'json',
error:function(d){
alert(d.responseText);
},
success:function(d){
switch(d.Result){
case "RET_SUCCESS":
//fbq('track','AddToCart');
$("#Shop_Cart_Total .num").html('('+d.Total+')');
alert("加入購物車成功");
$.ajax({
url:"/ajax/ajax_get_cart.php",
type:"POST",
async:false,
cache:false,
data:{Type:'Prod',ID:$(this).attr("SID")},
success:function(d){
$(".shopping-cartbox").css('display','none');
$("#Header_Shopcart_Prod").html(d);
$("#Header_Shopcart_Prod").parent(".one-cartbox").animate({'opacity':1,'maxHeight':'999px'}).css('z-index','100');
setTimeout(function(){
$("#Header_Shopcart_Prod").parent(".one-cartbox").animate({'maxHeight':'0px','opacity':0},function(){
$(this).removeAttr('style');
$(".shopping-cartbox").removeAttr('style');
});
},3000);
}
})
break;
case "RET_NO_MEMBER_NO":
alert("欲購買紅利兌換商品請先登入會員並完成會員認證");
break;
case "RET_RBONUS_OUT":
alert("紅利不足");
break;
case "RET_ERROR":
alert("資料庫忙線中");
break;
case "RET_PROD_ERROR":
alert("商品已下架");
break;
case "RET_NO_PROD":
alert("請選擇商品");
break;
case "RET_STOCK_ERROR":
alert("商品庫存不足");
break;
case "RET_LIMIT_ERROR":
alert("超過限制購買量");
break;
default:
alert("資料庫忙線中");
break;
};
}
});
});
});