$(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(''+_jsLang.取消選購);
//鎖定
_item.find(".SEL,.color-select").attr("disabled","true");
}
});
});
//取消商品
$(".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(''+_jsLang.選購);
//解除鎖定
_item.find(".SEL,.color-select").removeAttr("disabled");
}
});
});
//加入購物車
$("#Total_Div").on('click','#Add_Tmp_To_Cart',function(){
var Prod = "";
$(".prodbox").each(function(){
Prod += $(this).find(".amountBox").val()+","+$(this).find(".add_to_cart").attr("SID")+"-";
});
$.ajax({
url:'/activities/ajax/ajax_add_to_cart.php',
type:"POST",
cache:false,
async:true,
data:{Act_Type:$(this).attr("act_type"),Prod:Prod},
error:function(d){
alert(d.responseText);
},
success:function(d){
switch(d){
case "RET_SUCCESS":
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_OVER":
alert(_jsLang.超過限制購買數量);
break;
default:
alert(_jsLang.資料庫忙線中);
break;
};
}
});
});
});