1){
num -= 1;
$(".cart-num input").val(num);
}
});
$(".cart-jia").click(function(){
var num = parseInt($(".cart-num input").val());
num += 1;
$(".cart-num input").val(num);
});
$(".attr-item").click(function(){
var obj = $(this).parent();
var value = $(this).attr("data-id");
var key = $(this).attr("data-key");
$(obj).find(".attr-item").removeClass("attr-item-hover");
$(this).addClass("attr-item-hover");
for(let i in arr){
if(i == key){
for(let j in arr[i].attr_value){
if(arr[i].attr_value[j].attr == $(this).attr("data-id")){
arr[i].attr_value[j].check = true;
if(arr[i].attr_value[j].images){
}
}else{
arr[i].attr_value[j].check = false;
}
}
}
}
});
$(".cart-addtocart").click(function(){
let sku = [];
layer.load();
if(arr.length == 0){
addtocart();
return;
}
for(let i in arr){
for(let j in arr[i].attr_value){
if(arr[i].attr_value[j].check){
if (!sku.includes(arr[i].attr_value[j].attr)) {
sku.push(arr[i].attr_value[j].attr);
}
}
}
}
let key = sku.join(",");
let key_rev = sku.reverse();
let key_reverse = key_rev.join(",");
if(skus[key]){
addtocart(skus,key);
}
else if (skus[key_reverse]) {
addtocart(skus,key_reverse);
}else{
layer.closeAll();
layer.msg("Please choose the product option!");
}
});
$(".review-items-row").on("click",".reviewImg img",function(){
layer.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
skin: 'yourclass',
content: ''
});
})
function addtocart(skus,key){
var qty = $(".cart-num input").val();
var data = {
"productId":"85450",
"cartNum":qty,
"new":0
};
if(key){
data.uniqueId = skus[key].unique;
}
$.ajax({
url:"?m=jqajax&act=addtocart",
method:"POST",
dataType:"JSON",
data:data,
success :function(e){
layer.closeAll();
if(e.error == 0){
$(".right-mini-cart-box").html(e.html);
$(".mini-cart-num").html(e.data.count);
$('.drawer-toggle-cart').trigger("click");
}else{
layer.msg(e.msg);
}
}
});
}
$(".cart-wishlist").click(function(){
$.ajax({
url: "?m=jqajax&act=addwish",
method: "POST",
dataType: "JSON",
data: {
id:'85450'
},
success: function (e) {
console.log(e);
if(e.error == 1){
window.location.href = "?m=login";
}else{
layer.msg("Add favorite successfully!");
}
}
});
});