//GoodsCheck購物車每個店鋪的checkBox
//goods-check購物車所有的checkBox
//ShopCheck店鋪全選的按鈕
//commlistFrm店鋪商品的模塊
//allCheck 所有全選按鈕
// 購物車全選
$('.ShopCheck').click(function () {
if ($(this).prop("checked") == true) {
$(this).parents('.commlistFrm').find(".GoodsCheck").prop('checked',true);
}else{
$(this).parents('.commlistFrm').find(".GoodsCheck").prop('checked',false);
}
shopAllcheck();
});
$('.GoodsCheck').click(function () {
shopItemCheck(this);
shopAllcheck();
});
function shopAllcheck() {
var item =$('.mui-content').children('.commlistFrm').find('.GoodsCheck').length;//獲取購物車checkbox的數量
var item_check = $('.mui-content').children('.commlistFrm').find('.GoodsCheck:checked').length;
if(item ==item_check){
$('.allCheck').prop('checked',true)
}
else {
$('.allCheck').prop('checked',false)
}
}
function shopItemCheck(t){
var item =$(t).parents('.commlistFrm').find('.GoodsCheck').length;//獲取購物車checkbox的數量
var item_check = $(t).parents('.commlistFrm').find('.GoodsCheck:checked').length;
if(item ==item_check){
$(t).parents('.commlistFrm').find(".ShopCheck").prop('checked',true);
}else{
$(t).parents('.commlistFrm').find(".ShopCheck").prop('checked',false);
}
}
// 結算全選
$('.allCheck').click(function () {
if(this.checked==true){
$('.goods-check').prop('checked',true);
}
else {
$('.goods-check').prop('checked',false);
}
});