Authored by 姜枫

添加购物车清空实效商品

@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 </div> 15 </div>
16 <div id="remove_selected" class="action hoverable">删除选中的商品</div> 16 <div id="remove_selected" class="action hoverable">删除选中的商品</div>
17 <div id="send_favorite" class="action hoverable">移入收藏夹</div> 17 <div id="send_favorite" class="action hoverable">移入收藏夹</div>
  18 + <div id="remove_invalid" class="action hoverable">清除失效商品</div>
18 <div class="selected-num">已选<span>{{selectedNum}}</span></div> 19 <div class="selected-num">已选<span>{{selectedNum}}</span></div>
19 <div class="checkout-total"> 20 <div class="checkout-total">
20 <div class="total-title">商品金额:</div> 21 <div class="total-title">商品金额:</div>
@@ -23,8 +23,8 @@ module.exports = { @@ -23,8 +23,8 @@ module.exports = {
23 cookieDomain: 'yohoblk.com', 23 cookieDomain: 'yohoblk.com',
24 domains: { 24 domains: {
25 singleApi: 'http://single.yoho.cn/', 25 singleApi: 'http://single.yoho.cn/',
26 - api: 'http://api.yoho.yohoops.org/',  
27 - service: 'http://service.yoho.yohoops.org/', 26 + api: 'http://api.yoho.cn/',
  27 + service: 'http://service.yoho.cn/',
28 search: 'http://search.yohoops.org/yohosearch/' 28 search: 'http://search.yohoops.org/yohosearch/'
29 }, 29 },
30 useOneapm: false, 30 useOneapm: false,
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 "winston": "^2.2.0", 63 "winston": "^2.2.0",
64 "winston-daily-rotate-file": "^1.1.4", 64 "winston-daily-rotate-file": "^1.1.4",
65 "xss": "^0.2.13", 65 "xss": "^0.2.13",
66 - "yoho-node-lib": "0.0.51" 66 + "yoho-node-lib": "0.2.0"
67 }, 67 },
68 "devDependencies": { 68 "devDependencies": {
69 "autoprefixer": "^6.3.6", 69 "autoprefixer": "^6.3.6",
@@ -140,6 +140,10 @@ $(function() { @@ -140,6 +140,10 @@ $(function() {
140 }); 140 });
141 }); 141 });
142 142
  143 + $('#remove_invalid').off().on('click', function() {
  144 + Cart.removeInvalid();
  145 + });
  146 +
143 // 变动商品数量 147 // 变动商品数量
144 Stepper.init(); 148 Stepper.init();
145 }); 149 });
@@ -575,6 +575,40 @@ Cart = { @@ -575,6 +575,40 @@ Cart = {
575 } 575 }
576 } 576 }
577 }); 577 });
  578 + },
  579 +
  580 + /**
  581 + * 清除失效商品
  582 + */
  583 + removeInvalid: function() {
  584 + var invalidEles;
  585 + var products = [];
  586 + var dialog = new _confirm({
  587 + content: '您确定要清除失效商品吗?',
  588 + cb: function() {
  589 + dialog.close();
  590 +
  591 + invalidEles = $('.invalid-pros ul li.chk');
  592 +
  593 + if (invalidEles.length > 0) {
  594 + $(invalidEles).each(function() {
  595 + products.push(JSON.parse($(this).attr('data-product_info')));
  596 + });
  597 +
  598 + Util.ajax({
  599 + url: '/shopping/cart/product/remove',
  600 + data: {skuList: JSON.stringify(products)},
  601 + type: 'DELETE',
  602 + success: function(res) {
  603 + Util.refreshCart(res, function() {
  604 + });
  605 + }
  606 + });
  607 + } else {
  608 + new _alert('购物袋中没有失效商品!').show();
  609 + }
  610 + }
  611 + }).show();
578 } 612 }
579 }; 613 };
580 614