Authored by yyq

品牌店铺批量取消收藏

... ... @@ -393,7 +393,6 @@ $('#me-checkall').click(function() {
//删除收藏
$('.del-favorite').click(function(e) {
var id = $(this).closest('.fav-row').data('id'),
shopid = $(this).closest('.fav-row').data('shopid'),
brandorshoptype = $(this).closest('.fav-row').data('brandorshoptype');
e.preventDefault();
... ... @@ -403,9 +402,7 @@ $('.del-favorite').click(function(e) {
url: '/home/favorite/cancel',
data: {
id: id,
shopid: shopid,
brandorshoptype: brandorshoptype,
type: favType
type: brandorshoptype || favType
}
}).then(function(data) {
if (data.code === 200) {
... ... @@ -418,16 +415,27 @@ $('.del-favorite').click(function(e) {
$('#me-del-checked').click(function() {
var ids = [],
name = '商品';
var optType, group = {};
if (favType === 'brand') {
name = '品牌';
name = '品牌店铺';
} else if (favType === 'article') {
name = '文章';
}
if (confirm('您确定要删除您收藏的' + name + '吗?')) {
$('.checkbox input[type="checkbox"]:checked').each(function() {
ids.push($(this).closest('.fav-row').data('id'));
var $favRow = $(this).closest('.fav-row'),
rdata = $favRow.data();
ids.push(rdata.id);
if (rdata.brandorshoptype) {
if (!group[rdata.brandorshoptype]) {
group[rdata.brandorshoptype] = [];
}
group[rdata.brandorshoptype].push(rdata.id);
}
});
if (ids.length === 0) {
... ... @@ -440,6 +448,10 @@ $('#me-del-checked').click(function() {
url: '/home/favorite/cancel',
data: {
id: ids.join(','),
group: {
bid: group.brand ? group.brand.join(',') : '',
sid: group.shop ? group.shop.join(',') : ''
},
type: favType
}
}).then(function(data) {
... ...
... ... @@ -181,19 +181,27 @@ class FavoriteController extends WebAction
$uid = $this->getUid(true);
$id = $this->get('id', '');
$type = $this->get('type', '');
$shopid = $this->get('shopid', '');
$brandorshoptype = $this->get('brandorshoptype', '');
$group = $this->get('group', ''); // 组操作
if (!$uid || !$id) {
$result = array('code' => 400, 'message' => '缺少参数', 'data' => '');
break;
}
if ($brandorshoptype && $shopid && $brandorshoptype === 'shop') {
$result = FavoriteData::cancelProductFav($uid, $shopid, false, true); //取消店铺收藏
break;
}
switch (strval($type)) {
case 'shop':
$result = FavoriteData::cancelProductFav($uid, $id, false, true); //取消店铺收藏
break;
case 'brand':
if ($group) {
if ($group['bid']) {
$result = FavoriteData::cancelProductFav($uid, $group['bid'], true); //取消品牌收藏
}
if ($group['sid']) {
$result = FavoriteData::cancelProductFav($uid, $group['sid'], false, true); //取消店铺收藏
}
break;
}
$result = FavoriteData::cancelProductFav($uid, $id, true); //取消品牌收藏
break;
case 'article':
... ...