Authored by xuqi

removed products

@@ -107,12 +107,17 @@ $(function() { @@ -107,12 +107,17 @@ $(function() {
107 $('#removed_products').delegate('.send-to-favorite', 'click', function() { 107 $('#removed_products').delegate('.send-to-favorite', 'click', function() {
108 var $removedProduct = $(this).parents('.removed-product'); 108 var $removedProduct = $(this).parents('.removed-product');
109 109
110 - Cart.sendToFavorite([$.parseJSON($(this).attr('data-product_info'))], function() { 110 + var info = $.parseJSON($(this).attr('data-product_info'));
  111 +
  112 + Cart.sendToFavorite([info], function() {
111 if ($('#removed_products .removed-product').length > 1) { 113 if ($('#removed_products .removed-product').length > 1) {
112 $removedProduct.remove(); 114 $removedProduct.remove();
113 } else { 115 } else {
114 $('#removed_products').html(''); 116 $('#removed_products').html('');
115 } 117 }
  118 +
  119 + // clear removed memory
  120 + Cart.clearRemovedMemory(info.productSku);
116 }); 121 });
117 }).delegate('.buy-again', 'click', function() { 122 }).delegate('.buy-again', 'click', function() {
118 var productInfo = $.parseJSON($(this).attr('data-rebuy_info')), 123 var productInfo = $.parseJSON($(this).attr('data-rebuy_info')),
@@ -125,6 +130,9 @@ $(function() { @@ -125,6 +130,9 @@ $(function() {
125 } else { 130 } else {
126 $('#removed_products').html(''); 131 $('#removed_products').html('');
127 } 132 }
  133 +
  134 + // clear removed memory
  135 + Cart.clearRemovedMemory(productInfo.productSku);
128 }); 136 });
129 }); 137 });
130 }); 138 });
@@ -286,6 +286,25 @@ Cart = { @@ -286,6 +286,25 @@ Cart = {
286 })); 286 }));
287 }, 287 },
288 288
  289 + clearRemovedMemory: function(sku) {
  290 + var idx;
  291 +
  292 + if (!sku) {
  293 + return;
  294 + }
  295 +
  296 + // remove sku
  297 + removedProSkus.splice(removedProSkus.indexOf(sku), 1);
  298 +
  299 + // remove info
  300 + for (idx = removedProsInfo.length - 1; idx >= 0; idx--) {
  301 + if (removedProsInfo[idx].productSku === sku) {
  302 + removedProsInfo.splice(idx, 1);
  303 + return;
  304 + }
  305 + }
  306 + },
  307 +
289 /* 308 /*
290 * 商品移入收藏夹 309 * 商品移入收藏夹
291 * @function [sendToFavorite] 310 * @function [sendToFavorite]