Showing
1 changed file
with
19 additions
and
21 deletions
@@ -2,9 +2,9 @@ | @@ -2,9 +2,9 @@ | ||
2 | * Created by yoho on 2017-01-05. | 2 | * Created by yoho on 2017-01-05. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | -var $ = require('yoho-jquery'); | ||
6 | -var dialog = require('../common/dialog'); | ||
7 | -var Confirm = dialog.Confirm; | 5 | +var $ = require('yoho-jquery'), |
6 | + capi = require('./cart-api'); | ||
7 | + | ||
8 | var rDialog = require('./rdialog'); | 8 | var rDialog = require('./rdialog'); |
9 | var RConfirm = rDialog.RConfirm; | 9 | var RConfirm = rDialog.RConfirm; |
10 | var RAlert = rDialog.RAlert; | 10 | var RAlert = rDialog.RAlert; |
@@ -13,8 +13,7 @@ var Cart; | @@ -13,8 +13,7 @@ var Cart; | ||
13 | 13 | ||
14 | var $cartnewTips = $('.cartnew-tips'), | 14 | var $cartnewTips = $('.cartnew-tips'), |
15 | $payWapper = $('.pay-wapper'), | 15 | $payWapper = $('.pay-wapper'), |
16 | - $cartnewSum = $('.cartnew-sum'), | ||
17 | - capi = require('./cart-api'); | 16 | + $cartnewSum = $('.cartnew-sum'); |
18 | 17 | ||
19 | // 关闭温馨提示 | 18 | // 关闭温馨提示 |
20 | $cartnewTips.find('.btn_close').click(function() { | 19 | $cartnewTips.find('.btn_close').click(function() { |
@@ -78,6 +77,7 @@ Cart = { | @@ -78,6 +77,7 @@ Cart = { | ||
78 | var $this = $(this); | 77 | var $this = $(this); |
79 | var selected; | 78 | var selected; |
80 | var selectArray = []; | 79 | var selectArray = []; |
80 | + var $noStores = $payWapper.find('[data-role=cart-item-check][data-tipnostore]'); | ||
81 | 81 | ||
82 | $this.toggleClass('cart-item-checked'); | 82 | $this.toggleClass('cart-item-checked'); |
83 | selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N'; | 83 | selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N'; |
@@ -96,17 +96,15 @@ Cart = { | @@ -96,17 +96,15 @@ Cart = { | ||
96 | } | 96 | } |
97 | }); | 97 | }); |
98 | 98 | ||
99 | - var $noStores = $payWapper.find('[data-role=cart-item-check][data-tipnostore]'); | ||
100 | - | ||
101 | if (selected === 'Y' && $noStores && $noStores.length > 0) { // 无库存提示 | 99 | if (selected === 'Y' && $noStores && $noStores.length > 0) { // 无库存提示 |
102 | 100 | ||
103 | $('html,body').animate({scrollTop: $noStores.eq(0).offset().top - 50 + 'px'}, 500); | 101 | $('html,body').animate({scrollTop: $noStores.eq(0).offset().top - 50 + 'px'}, 500); |
104 | 102 | ||
105 | - $noStores.each(function(){ | 103 | + $noStores.each(function() { |
106 | toastNoStore($(this).closest('li[data-role=pitem]'), '您全选的商品中存在库存不足商品,已帮您自动取消勾选'); | 104 | toastNoStore($(this).closest('li[data-role=pitem]'), '您全选的商品中存在库存不足商品,已帮您自动取消勾选'); |
107 | }); | 105 | }); |
108 | 106 | ||
109 | - setTimeout(function(){ | 107 | + setTimeout(function() { |
110 | capi.choiceOut(selectArray); | 108 | capi.choiceOut(selectArray); |
111 | }, 2000); | 109 | }, 2000); |
112 | } else { | 110 | } else { |
@@ -153,7 +151,7 @@ Cart = { | @@ -153,7 +151,7 @@ Cart = { | ||
153 | 151 | ||
154 | var selectArray = []; | 152 | var selectArray = []; |
155 | var PromotionArray = []; | 153 | var PromotionArray = []; |
156 | - var content = '<div><i class="iconfont"></i>删除商品</div><p>确定从购物车中删除所有选中商品?</p>'; | 154 | + var content = '<div><i class="iconfont"></i>删除商品</div><p>确定从购物车中删除所有选中商品?</p>'; //eslint-disable-line |
157 | 155 | ||
158 | $payWapper.find('[data-role=cart-item-check]').each(function() { | 156 | $payWapper.find('[data-role=cart-item-check]').each(function() { |
159 | 157 | ||
@@ -184,12 +182,12 @@ Cart = { | @@ -184,12 +182,12 @@ Cart = { | ||
184 | 182 | ||
185 | if (!$.isEmptyObject(selectArray)) { | 183 | if (!$.isEmptyObject(selectArray)) { |
186 | 184 | ||
187 | - new RConfirm(content, function() { | 185 | + new RConfirm(content, function() { // eslint-disable-line |
188 | capi.cartItemDel(selectArray, true, PromotionArray); | 186 | capi.cartItemDel(selectArray, true, PromotionArray); |
189 | }); | 187 | }); |
190 | } else { | 188 | } else { |
191 | - var content = '<div class="alert-main"><i class="iconfont"></i>请至少选中一件商品!</div>'; | ||
192 | - new RAlert(content); | 189 | + var content = '<div class="alert-main"><i class="iconfont"></i>请至少选中一件商品!</div>'; // eslint-disable-line |
190 | + new RAlert(content); // eslint-disable-line | ||
193 | } | 191 | } |
194 | }, | 192 | }, |
195 | cleanAllDisable: function() { | 193 | cleanAllDisable: function() { |
@@ -221,13 +219,13 @@ Cart = { | @@ -221,13 +219,13 @@ Cart = { | ||
221 | }); | 219 | }); |
222 | 220 | ||
223 | if (!$.isEmptyObject(selectArray)) { | 221 | if (!$.isEmptyObject(selectArray)) { |
224 | - var content = '<div><i class="iconfont"></i>清除失效商品</div><p>确定要清除失效商品吗?</p>'; | ||
225 | - new RConfirm(content, function() { | 222 | + var content = '<div><i class="iconfont"></i>清除失效商品</div><p>确定要清除失效商品吗?</p>'; // eslint-disable-line |
223 | + new RConfirm(content, function() { // eslint-disable-line | ||
226 | capi.cartItemDel(selectArray, true, PromotionArray); | 224 | capi.cartItemDel(selectArray, true, PromotionArray); |
227 | }).show(); | 225 | }).show(); |
228 | } else { | 226 | } else { |
229 | - var content = '<div class="alert-main"><i class="iconfont"></i>购物车中没有失效商品!</div>'; | ||
230 | - new RAlert(content); | 227 | + var content = '<div class="alert-main"><i class="iconfont"></i>购物车中没有失效商品!</div>'; // eslint-disable-line |
228 | + new RAlert(content); // eslint-disable-line | ||
231 | } | 229 | } |
232 | }, | 230 | }, |
233 | toFav: function() { | 231 | toFav: function() { |
@@ -253,7 +251,6 @@ Cart = { | @@ -253,7 +251,6 @@ Cart = { | ||
253 | toFavAll: function() { | 251 | toFavAll: function() { |
254 | 252 | ||
255 | var selectArray = []; | 253 | var selectArray = []; |
256 | - var content = '<div><i class="iconfont"></i>移入收藏</div><p>确定要将已选中的商品从购物车中移入收藏夹吗?<br/>移入收藏后已选中的商品将不在购物车中显示</p>'; | ||
257 | 254 | ||
258 | $payWapper.find('[data-role=cart-item-check]').each(function() { | 255 | $payWapper.find('[data-role=cart-item-check]').each(function() { |
259 | 256 | ||
@@ -274,13 +271,14 @@ Cart = { | @@ -274,13 +271,14 @@ Cart = { | ||
274 | 271 | ||
275 | if (!$.isEmptyObject(selectArray)) { | 272 | if (!$.isEmptyObject(selectArray)) { |
276 | 273 | ||
277 | - new RConfirm(content, function() { | 274 | + var content = '<div><i class="iconfont"></i>移入收藏</div><p>确定要将已选中的商品从购物车中移入收藏夹吗?<br/>移入收藏后已选中的商品将不在购物车中显示</p>'; // eslint-disable-line |
275 | + new RConfirm(content, function() { // eslint-disable-line | ||
278 | capi.cartItemDel(selectArray); | 276 | capi.cartItemDel(selectArray); |
279 | }); | 277 | }); |
280 | 278 | ||
281 | } else { | 279 | } else { |
282 | - var content = '<div class="alert-main"><i class="iconfont"></i>请至少选中一件商品!</div>'; | ||
283 | - new RAlert(content); | 280 | + var content = '<div class="alert-main"><i class="iconfont"></i>请至少选中一件商品!</div>'; // eslint-disable-line |
281 | + new RAlert(content); // eslint-disable-line | ||
284 | } | 282 | } |
285 | }, | 283 | }, |
286 | modNum: function() { | 284 | modNum: function() { |
-
Please register or login to post a comment