|
@@ -9,6 +9,7 @@ var $ = require('jquery'), |
|
@@ -9,6 +9,7 @@ var $ = require('jquery'), |
9
|
Hammer = require('yoho.hammer');
|
9
|
Hammer = require('yoho.hammer');
|
10
|
|
10
|
|
11
|
var chosePanel = require('./chose-panel'),
|
11
|
var chosePanel = require('./chose-panel'),
|
|
|
12
|
+ dialog = require('../me/dialog'),
|
12
|
tip = require('../plugin/tip');
|
13
|
tip = require('../plugin/tip');
|
13
|
|
14
|
|
14
|
var $cartContent = $('.cart-content');
|
15
|
var $cartContent = $('.cart-content');
|
|
@@ -18,6 +19,48 @@ var navHammer, |
|
@@ -18,6 +19,48 @@ var navHammer, |
18
|
|
19
|
|
19
|
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
|
20
|
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
|
20
|
|
21
|
|
|
|
22
|
+function shouldSelectGift() {
|
|
|
23
|
+ var $freebie = $('.freebie');
|
|
|
24
|
+
|
|
|
25
|
+ if ($freebie.length <= 0) {
|
|
|
26
|
+ return false;
|
|
|
27
|
+ }
|
|
|
28
|
+
|
|
|
29
|
+ return true;
|
|
|
30
|
+}
|
|
|
31
|
+
|
|
|
32
|
+function shouldLowStocks() {
|
|
|
33
|
+ var $lowStocks = $('.low-stocks'),
|
|
|
34
|
+ result = false;
|
|
|
35
|
+
|
|
|
36
|
+ if ($lowStocks.length <= 0) {
|
|
|
37
|
+ return result;
|
|
|
38
|
+ }
|
|
|
39
|
+
|
|
|
40
|
+ $lowStocks.each(function(idx, item) {
|
|
|
41
|
+ if ($(item).parent().parent().parent().siblings('.checkbox').hasClass('icon-cb-checked')) {
|
|
|
42
|
+ result = true;
|
|
|
43
|
+ return false;
|
|
|
44
|
+ }
|
|
|
45
|
+ });
|
|
|
46
|
+
|
|
|
47
|
+ return result;
|
|
|
48
|
+}
|
|
|
49
|
+
|
|
|
50
|
+function showChooseGifDialog() {
|
|
|
51
|
+ dialog.showDialog({
|
|
|
52
|
+ dialogText: '您还未选择赠品,是否去选择赠品',
|
|
|
53
|
+ hasFooter: {
|
|
|
54
|
+ leftBtnText: '我不要赠品',
|
|
|
55
|
+ rightBtnText: '去选择'
|
|
|
56
|
+ }
|
|
|
57
|
+ }, function() {
|
|
|
58
|
+ window.location.href = $('.freebie').find('a').attr('href');
|
|
|
59
|
+ }, function() {
|
|
|
60
|
+ window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
61
|
+ });
|
|
|
62
|
+}
|
|
|
63
|
+
|
21
|
require('./good');
|
64
|
require('./good');
|
22
|
|
65
|
|
23
|
lazyLoad($('img.lazy'));
|
66
|
lazyLoad($('img.lazy'));
|
|
@@ -65,7 +108,11 @@ $('.freebie').on('touchend', function() { |
|
@@ -65,7 +108,11 @@ $('.freebie').on('touchend', function() { |
65
|
});
|
108
|
});
|
66
|
|
109
|
|
67
|
$('.btn-balance').on('touchend', function() {
|
110
|
$('.btn-balance').on('touchend', function() {
|
68
|
- if ($('.low-stocks').length > 0) {
|
111
|
+ if (shouldSelectGift()) {
|
|
|
112
|
+ showChooseGifDialog();
|
|
|
113
|
+ return false;
|
|
|
114
|
+ }
|
|
|
115
|
+ if (shouldLowStocks()) {
|
69
|
tip.show('库存不足无法结算');
|
116
|
tip.show('库存不足无法结算');
|
70
|
return false;
|
117
|
return false;
|
71
|
}
|
118
|
}
|