|
@@ -17,29 +17,85 @@ let goodObj = { |
|
@@ -17,29 +17,85 @@ let goodObj = { |
17
|
let self = this;
|
17
|
let self = this;
|
18
|
|
18
|
|
19
|
self.handle = handle;
|
19
|
self.handle = handle;
|
20
|
-
|
|
|
21
|
$('.good-item').on('click', '.num-opt .btn', function(e) {
|
20
|
$('.good-item').on('click', '.num-opt .btn', function(e) {
|
22
|
- self.modifyNum(e);
|
21
|
+ self.modifyNumClick(e);
|
23
|
});
|
22
|
});
|
24
|
$('.good-item').on('click', '.chk.select', function(e) {
|
23
|
$('.good-item').on('click', '.chk.select', function(e) {
|
25
|
- if (!$(this).hasClass('checked') && $(e.delegateTarget).find('.low-stocks').length > 0) {
|
|
|
26
|
- tip.show('库存不足,无法购买');
|
|
|
27
|
- return false;
|
|
|
28
|
- }
|
|
|
29
|
- self.selectGood($(this));
|
24
|
+ self.checkSelectClick(e);
|
30
|
});
|
25
|
});
|
31
|
- $('.good-item').on('click', '.chk.edit', function() {
|
|
|
32
|
- $(this).toggleClass('checked');
|
26
|
+ $('.good-item').on('click', '.chk.edit', function(e) {
|
|
|
27
|
+ self.checkClick(e);
|
33
|
});
|
28
|
});
|
34
|
-
|
|
|
35
|
$('.btn-fav').on('click', function() {
|
29
|
$('.btn-fav').on('click', function() {
|
36
|
- if (!$('.good-item .chk.edit.checked').length) {
|
|
|
37
|
- tip.show('请至少选择一件商品');
|
|
|
38
|
- return;
|
30
|
+ self.favClick();
|
|
|
31
|
+ });
|
|
|
32
|
+ $('.good-item').on('click', '.size-info', function(e) {
|
|
|
33
|
+ self.sizeInfoClick(e);
|
|
|
34
|
+ });
|
|
|
35
|
+ $('.good-item').on('click', '.name,.color-size-row,.img', function(e) {
|
|
|
36
|
+ self.goodClick(e);
|
|
|
37
|
+ });
|
|
|
38
|
+ $('.check-all').on('click', function() {
|
|
|
39
|
+ self.checkedAllClick();
|
|
|
40
|
+ });
|
|
|
41
|
+ $('.btn-del').on('click', function() {
|
|
|
42
|
+ self.delClick();
|
|
|
43
|
+ });
|
|
|
44
|
+ $('.btn-remove').on('click', function() {
|
|
|
45
|
+ self.removeInvalidClick();
|
|
|
46
|
+ });
|
|
|
47
|
+ self.clearLowStock();
|
|
|
48
|
+ },
|
|
|
49
|
+ checkClick(e) {
|
|
|
50
|
+ $(e.currentTarget).toggleClass('checked');
|
|
|
51
|
+ },
|
|
|
52
|
+ removeInvalidClick() {
|
|
|
53
|
+ dialog.showDialog({
|
|
|
54
|
+ dialogText: '您确定要清空失效商品吗?',
|
|
|
55
|
+ hasFooter: {
|
|
|
56
|
+ leftBtnText: '取消',
|
|
|
57
|
+ rightBtnText: '确定'
|
|
|
58
|
+ }
|
|
|
59
|
+ }, function() {
|
|
|
60
|
+ ((callback) => {
|
|
|
61
|
+ let promise = self.removeAllDisabled();
|
|
|
62
|
+
|
|
|
63
|
+ if (promise) {
|
|
|
64
|
+ promise.then(() => {
|
|
|
65
|
+ callback();
|
|
|
66
|
+ }, () => {
|
|
|
67
|
+ dialog.hideDialog();
|
|
|
68
|
+ });
|
|
|
69
|
+ } else {
|
|
|
70
|
+ return callback();
|
|
|
71
|
+ }
|
|
|
72
|
+ })(() => {
|
|
|
73
|
+ dialog.showDialog({
|
|
|
74
|
+ dialogText: '清空成功',
|
|
|
75
|
+ autoHide: true,
|
|
|
76
|
+ fast: true
|
|
|
77
|
+ });
|
|
|
78
|
+ });
|
|
|
79
|
+
|
|
|
80
|
+ });
|
|
|
81
|
+ },
|
|
|
82
|
+ delClick() {
|
|
|
83
|
+ let self = this;
|
|
|
84
|
+
|
|
|
85
|
+ if (!$('.good-item .chk.edit.checked').length) {
|
|
|
86
|
+ tip.show('请至少选择一件商品');
|
|
|
87
|
+ return;
|
|
|
88
|
+ }
|
|
|
89
|
+ dialog.showDialog({
|
|
|
90
|
+ dialogText: '您确定要从购物车中删除吗?',
|
|
|
91
|
+ hasFooter: {
|
|
|
92
|
+ leftBtnText: '取消',
|
|
|
93
|
+ rightBtnText: '确定'
|
39
|
}
|
94
|
}
|
40
|
- self.favGood($('.good-item .chk.edit.checked')).then(() => {
|
95
|
+ }, function() {
|
|
|
96
|
+ self.delGood($('.good-item .chk.edit.checked')).then(() => {
|
41
|
dialog.showDialog({
|
97
|
dialog.showDialog({
|
42
|
- dialogText: '收藏成功',
|
98
|
+ dialogText: '删除成功',
|
43
|
autoHide: true,
|
99
|
autoHide: true,
|
44
|
fast: true
|
100
|
fast: true
|
45
|
});
|
101
|
});
|
|
@@ -47,103 +103,74 @@ let goodObj = { |
|
@@ -47,103 +103,74 @@ let goodObj = { |
47
|
dialog.hideDialog();
|
103
|
dialog.hideDialog();
|
48
|
});
|
104
|
});
|
49
|
});
|
105
|
});
|
50
|
- $('.good-item').on('click', '.size-info', function(e) {
|
|
|
51
|
- let isGift = $(e.delegateTarget).hasClass('is-gift');
|
106
|
+ },
|
|
|
107
|
+ goodClick(e) {
|
|
|
108
|
+ if ($(e.delegateTarget).hasClass('in-valid') && !$(e.delegateTarget).hasClass('in-valid-low')) {
|
|
|
109
|
+ tip.show('商品已下架');
|
|
|
110
|
+ } else {
|
|
|
111
|
+ window.location.href = $(e.delegateTarget).data('link');
|
|
|
112
|
+ }
|
|
|
113
|
+ },
|
|
|
114
|
+ checkSelectClick(e) {
|
|
|
115
|
+ let self = this;
|
|
|
116
|
+
|
|
|
117
|
+ if (!$(e.currentTarget).hasClass('checked') && $(e.delegateTarget).find('.low-stocks').length > 0) {
|
|
|
118
|
+ tip.show('库存不足,无法购买');
|
|
|
119
|
+ return false;
|
|
|
120
|
+ }
|
|
|
121
|
+ self.selectGood($(e.currentTarget));
|
|
|
122
|
+ },
|
|
|
123
|
+ sizeInfoClick(e) {
|
|
|
124
|
+ let self = this;
|
|
|
125
|
+ let isGift = $(e.delegateTarget).hasClass('is-gift');
|
52
|
|
126
|
|
53
|
- self.openChosepanel(e, isGift);
|
127
|
+ self.openChosepanel(e, isGift);
|
|
|
128
|
+ },
|
|
|
129
|
+ favClick() {
|
|
|
130
|
+ let self = this;
|
|
|
131
|
+
|
|
|
132
|
+ if (!$('.good-item .chk.edit.checked').length) {
|
|
|
133
|
+ tip.show('请至少选择一件商品');
|
|
|
134
|
+ return;
|
|
|
135
|
+ }
|
|
|
136
|
+ self.favGood($('.good-item .chk.edit.checked')).then(() => {
|
|
|
137
|
+ dialog.showDialog({
|
|
|
138
|
+ dialogText: '收藏成功',
|
|
|
139
|
+ autoHide: true,
|
|
|
140
|
+ fast: true
|
|
|
141
|
+ });
|
|
|
142
|
+ }, () => {
|
|
|
143
|
+ dialog.hideDialog();
|
54
|
});
|
144
|
});
|
55
|
- $('.good-item').on('click', '.name,.color-size-row,.img', function(e) {
|
|
|
56
|
- if ($(e.delegateTarget).hasClass('in-valid') && !$(e.delegateTarget).hasClass('in-valid-low')) {
|
|
|
57
|
- tip.show('商品已下架');
|
145
|
+ },
|
|
|
146
|
+ checkedAllClick() {
|
|
|
147
|
+ if (self.handle.editMode) {
|
|
|
148
|
+ $(this).find('.chk.edit').toggleClass('checked');
|
|
|
149
|
+ if ($(this).find('.chk.edit').hasClass('checked')) {
|
|
|
150
|
+ $('.good-item .chk.edit').addClass('checked');
|
58
|
} else {
|
151
|
} else {
|
59
|
- window.location.href = $(e.delegateTarget).data('link');
|
152
|
+ $('.good-item .chk.edit').removeClass('checked');
|
60
|
}
|
153
|
}
|
61
|
- });
|
|
|
62
|
- $('.check-all').on('click', function() {
|
|
|
63
|
- if (self.handle.editMode) {
|
|
|
64
|
- $(this).find('.chk.edit').toggleClass('checked');
|
|
|
65
|
- if ($(this).find('.chk.edit').hasClass('checked')) {
|
|
|
66
|
- $('.good-item .chk.edit').addClass('checked');
|
|
|
67
|
- } else {
|
|
|
68
|
- $('.good-item .chk.edit').removeClass('checked');
|
|
|
69
|
- }
|
|
|
70
|
- } else {
|
|
|
71
|
- $(this).find('.chk.select').toggleClass('checked');
|
|
|
72
|
- let checked = $(this).find('.chk.select').hasClass('checked');
|
154
|
+ } else {
|
|
|
155
|
+ $(this).find('.chk.select').toggleClass('checked');
|
|
|
156
|
+ let checked = $(this).find('.chk.select').hasClass('checked');
|
73
|
|
157
|
|
74
|
- if (checked) {
|
|
|
75
|
- let promise = self.clearLowStock();
|
158
|
+ if (checked) {
|
|
|
159
|
+ let promise = self.clearLowStock();
|
76
|
|
160
|
|
77
|
- if (promise) {
|
|
|
78
|
- tip.show('您全选的商品中存在库存不足商品,已帮您自动取消勾选');
|
|
|
79
|
- promise.then(() => {
|
|
|
80
|
- self.selectGood($('.good-item:not(.low-stocks) .chk.select'), true);
|
|
|
81
|
- });
|
|
|
82
|
- } else {
|
161
|
+ if (promise) {
|
|
|
162
|
+ tip.show('您全选的商品中存在库存不足商品,已帮您自动取消勾选');
|
|
|
163
|
+ promise.then(() => {
|
83
|
self.selectGood($('.good-item:not(.low-stocks) .chk.select'), true);
|
164
|
self.selectGood($('.good-item:not(.low-stocks) .chk.select'), true);
|
84
|
- }
|
165
|
+ });
|
85
|
} else {
|
166
|
} else {
|
86
|
- self.selectGood($('.good-item .chk.select'), false);
|
167
|
+ self.selectGood($('.good-item:not(.low-stocks) .chk.select'), true);
|
87
|
}
|
168
|
}
|
88
|
-
|
|
|
89
|
- }
|
|
|
90
|
- });
|
|
|
91
|
- $('.btn-del').on('click', function() {
|
|
|
92
|
- if (!$('.good-item .chk.edit.checked').length) {
|
|
|
93
|
- tip.show('请至少选择一件商品');
|
|
|
94
|
- return;
|
169
|
+ } else {
|
|
|
170
|
+ self.selectGood($('.good-item .chk.select'), false);
|
95
|
}
|
171
|
}
|
96
|
- dialog.showDialog({
|
|
|
97
|
- dialogText: '您确定要从购物车中删除吗?',
|
|
|
98
|
- hasFooter: {
|
|
|
99
|
- leftBtnText: '取消',
|
|
|
100
|
- rightBtnText: '确定'
|
|
|
101
|
- }
|
|
|
102
|
- }, function() {
|
|
|
103
|
- self.delGood($('.good-item .chk.edit.checked')).then(() => {
|
|
|
104
|
- dialog.showDialog({
|
|
|
105
|
- dialogText: '删除成功',
|
|
|
106
|
- autoHide: true,
|
|
|
107
|
- fast: true
|
|
|
108
|
- });
|
|
|
109
|
- }, () => {
|
|
|
110
|
- dialog.hideDialog();
|
|
|
111
|
- });
|
|
|
112
|
- });
|
|
|
113
|
-
|
|
|
114
|
- });
|
|
|
115
|
- $('.btn-remove').on('click', function() {
|
|
|
116
|
- dialog.showDialog({
|
|
|
117
|
- dialogText: '您确定要清空失效商品吗?',
|
|
|
118
|
- hasFooter: {
|
|
|
119
|
- leftBtnText: '取消',
|
|
|
120
|
- rightBtnText: '确定'
|
|
|
121
|
- }
|
|
|
122
|
- }, function() {
|
|
|
123
|
- ((callback) => {
|
|
|
124
|
- let promise = self.removeAllDisabled();
|
|
|
125
|
-
|
|
|
126
|
- if (promise) {
|
|
|
127
|
- promise.then(() => {
|
|
|
128
|
- callback();
|
|
|
129
|
- }, () => {
|
|
|
130
|
- dialog.hideDialog();
|
|
|
131
|
- });
|
|
|
132
|
- } else {
|
|
|
133
|
- return callback();
|
|
|
134
|
- }
|
|
|
135
|
- })(() => {
|
|
|
136
|
- dialog.showDialog({
|
|
|
137
|
- dialogText: '清空成功',
|
|
|
138
|
- autoHide: true,
|
|
|
139
|
- fast: true
|
|
|
140
|
- });
|
|
|
141
|
- });
|
|
|
142
|
|
172
|
|
143
|
- });
|
|
|
144
|
-
|
|
|
145
|
- });
|
|
|
146
|
- self.clearLowStock();
|
173
|
+ }
|
147
|
},
|
174
|
},
|
148
|
selectGood(eles, selectAll) {
|
175
|
selectGood(eles, selectAll) {
|
149
|
let self = this;
|
176
|
let self = this;
|
|
@@ -207,25 +234,31 @@ let goodObj = { |
|
@@ -207,25 +234,31 @@ let goodObj = { |
207
|
return ele;
|
234
|
return ele;
|
208
|
});
|
235
|
});
|
209
|
|
236
|
|
210
|
- return $.ajax({
|
|
|
211
|
- type: 'post',
|
|
|
212
|
- url: '/cart/index/new/col',
|
|
|
213
|
- data: {
|
|
|
214
|
- skuList: JSON.stringify(skuData)
|
|
|
215
|
- }
|
|
|
216
|
- }).then((data) => {
|
|
|
217
|
- if (data.code === 200) {
|
|
|
218
|
- self.handle.refreshPage(data.data);
|
|
|
219
|
- } else if (data.code === 400) {
|
|
|
220
|
- tip.show('网络异常');
|
|
|
221
|
- } else if (data.code === 401) {
|
|
|
222
|
- tip.show(data.message);
|
|
|
223
|
- setTimeout(() => {
|
|
|
224
|
- window.location.href = data.data;
|
|
|
225
|
- }, 1000);
|
|
|
226
|
- }
|
|
|
227
|
- }, err => {
|
|
|
228
|
- tip.show(err.responseJSON ? err.responseJSON.message : '网络异常');
|
237
|
+ return new Promise((resolve, reject) => {
|
|
|
238
|
+ $.ajax({
|
|
|
239
|
+ type: 'post',
|
|
|
240
|
+ url: '/cart/index/new/col',
|
|
|
241
|
+ data: {
|
|
|
242
|
+ skuList: JSON.stringify(skuData)
|
|
|
243
|
+ }
|
|
|
244
|
+ }).then((data) => {
|
|
|
245
|
+ if (data.code === 200) {
|
|
|
246
|
+ self.handle.refreshPage(data.data);
|
|
|
247
|
+ return resolve();
|
|
|
248
|
+ } else if (data.code === 400) {
|
|
|
249
|
+ tip.show('网络异常');
|
|
|
250
|
+ return reject();
|
|
|
251
|
+ } else if (data.code === 401) {
|
|
|
252
|
+ tip.show(data.message);
|
|
|
253
|
+ setTimeout(() => {
|
|
|
254
|
+ window.location.href = data.data;
|
|
|
255
|
+ }, 1000);
|
|
|
256
|
+ return reject();
|
|
|
257
|
+ }
|
|
|
258
|
+ }, err => {
|
|
|
259
|
+ tip.show(err.responseJSON ? err.responseJSON.message : '网络异常');
|
|
|
260
|
+ return reject();
|
|
|
261
|
+ });
|
229
|
});
|
262
|
});
|
230
|
},
|
263
|
},
|
231
|
getSelectGoodData(eles, selectAll) {
|
264
|
getSelectGoodData(eles, selectAll) {
|
|
@@ -282,7 +315,7 @@ let goodObj = { |
|
@@ -282,7 +315,7 @@ let goodObj = { |
282
|
}
|
315
|
}
|
283
|
});
|
316
|
});
|
284
|
},
|
317
|
},
|
285
|
- modifyNum(e) {
|
318
|
+ modifyNumClick(e) {
|
286
|
let self = this;
|
319
|
let self = this;
|
287
|
|
320
|
|
288
|
if (self.handle.posting) {
|
321
|
if (self.handle.posting) {
|