Authored by yyq

Merge branch 'feature/favShopDelAll' into release/5.3.1

@@ -393,7 +393,6 @@ $('#me-checkall').click(function() { @@ -393,7 +393,6 @@ $('#me-checkall').click(function() {
393 //删除收藏 393 //删除收藏
394 $('.del-favorite').click(function(e) { 394 $('.del-favorite').click(function(e) {
395 var id = $(this).closest('.fav-row').data('id'), 395 var id = $(this).closest('.fav-row').data('id'),
396 - shopid = $(this).closest('.fav-row').data('shopid'),  
397 brandorshoptype = $(this).closest('.fav-row').data('brandorshoptype'); 396 brandorshoptype = $(this).closest('.fav-row').data('brandorshoptype');
398 397
399 e.preventDefault(); 398 e.preventDefault();
@@ -403,9 +402,7 @@ $('.del-favorite').click(function(e) { @@ -403,9 +402,7 @@ $('.del-favorite').click(function(e) {
403 url: '/home/favorite/cancel', 402 url: '/home/favorite/cancel',
404 data: { 403 data: {
405 id: id, 404 id: id,
406 - shopid: shopid,  
407 - brandorshoptype: brandorshoptype,  
408 - type: favType 405 + type: brandorshoptype || favType
409 } 406 }
410 }).then(function(data) { 407 }).then(function(data) {
411 if (data.code === 200) { 408 if (data.code === 200) {
@@ -418,16 +415,27 @@ $('.del-favorite').click(function(e) { @@ -418,16 +415,27 @@ $('.del-favorite').click(function(e) {
418 $('#me-del-checked').click(function() { 415 $('#me-del-checked').click(function() {
419 var ids = [], 416 var ids = [],
420 name = '商品'; 417 name = '商品';
  418 + var optType, group = {};
421 419
422 if (favType === 'brand') { 420 if (favType === 'brand') {
423 - name = '品牌'; 421 + name = '品牌店铺';
424 } else if (favType === 'article') { 422 } else if (favType === 'article') {
425 name = '文章'; 423 name = '文章';
426 } 424 }
427 425
428 if (confirm('您确定要删除您收藏的' + name + '吗?')) { 426 if (confirm('您确定要删除您收藏的' + name + '吗?')) {
429 $('.checkbox input[type="checkbox"]:checked').each(function() { 427 $('.checkbox input[type="checkbox"]:checked').each(function() {
430 - ids.push($(this).closest('.fav-row').data('id')); 428 + var $favRow = $(this).closest('.fav-row'),
  429 + rdata = $favRow.data();
  430 +
  431 + ids.push(rdata.id);
  432 +
  433 + if (rdata.brandorshoptype) {
  434 + if (!group[rdata.brandorshoptype]) {
  435 + group[rdata.brandorshoptype] = [];
  436 + }
  437 + group[rdata.brandorshoptype].push(rdata.id);
  438 + }
431 }); 439 });
432 440
433 if (ids.length === 0) { 441 if (ids.length === 0) {
@@ -440,6 +448,10 @@ $('#me-del-checked').click(function() { @@ -440,6 +448,10 @@ $('#me-del-checked').click(function() {
440 url: '/home/favorite/cancel', 448 url: '/home/favorite/cancel',
441 data: { 449 data: {
442 id: ids.join(','), 450 id: ids.join(','),
  451 + group: {
  452 + bid: group.brand ? group.brand.join(',') : '',
  453 + sid: group.shop ? group.shop.join(',') : ''
  454 + },
443 type: favType 455 type: favType
444 } 456 }
445 }).then(function(data) { 457 }).then(function(data) {
@@ -181,19 +181,27 @@ class FavoriteController extends WebAction @@ -181,19 +181,27 @@ class FavoriteController extends WebAction
181 $uid = $this->getUid(true); 181 $uid = $this->getUid(true);
182 $id = $this->get('id', ''); 182 $id = $this->get('id', '');
183 $type = $this->get('type', ''); 183 $type = $this->get('type', '');
184 - $shopid = $this->get('shopid', '');  
185 - $brandorshoptype = $this->get('brandorshoptype', ''); 184 + $group = $this->get('group', ''); // 组操作
186 185
187 if (!$uid || !$id) { 186 if (!$uid || !$id) {
188 $result = array('code' => 400, 'message' => '缺少参数', 'data' => ''); 187 $result = array('code' => 400, 'message' => '缺少参数', 'data' => '');
189 break; 188 break;
190 } 189 }
191 - if ($brandorshoptype && $shopid && $brandorshoptype === 'shop') {  
192 - $result = FavoriteData::cancelProductFav($uid, $shopid, false, true); //取消店铺收藏  
193 - break;  
194 - } 190 +
195 switch (strval($type)) { 191 switch (strval($type)) {
  192 + case 'shop':
  193 + $result = FavoriteData::cancelProductFav($uid, $id, false, true); //取消店铺收藏
  194 + break;
196 case 'brand': 195 case 'brand':
  196 + if ($group) {
  197 + if ($group['bid']) {
  198 + $result = FavoriteData::cancelProductFav($uid, $group['bid'], true); //取消品牌收藏
  199 + }
  200 + if ($group['sid']) {
  201 + $result = FavoriteData::cancelProductFav($uid, $group['sid'], false, true); //取消店铺收藏
  202 + }
  203 + break;
  204 + }
197 $result = FavoriteData::cancelProductFav($uid, $id, true); //取消品牌收藏 205 $result = FavoriteData::cancelProductFav($uid, $id, true); //取消品牌收藏
198 break; 206 break;
199 case 'article': 207 case 'article':