|
@@ -22,7 +22,6 @@ var $chosePanel = $('#chose-panel'), |
|
@@ -22,7 +22,6 @@ var $chosePanel = $('#chose-panel'), |
22
|
confirming,
|
22
|
confirming,
|
23
|
curColorIndex,
|
23
|
curColorIndex,
|
24
|
curSizeIndex,
|
24
|
curSizeIndex,
|
25
|
- $curSizeRow,
|
|
|
26
|
hasChooseColor,
|
25
|
hasChooseColor,
|
27
|
hasChooseSize,
|
26
|
hasChooseSize,
|
28
|
$curSizeBlock,
|
27
|
$curSizeBlock,
|
|
@@ -34,8 +33,6 @@ var $chosePanel = $('#chose-panel'), |
|
@@ -34,8 +33,6 @@ var $chosePanel = $('#chose-panel'), |
34
|
|
33
|
|
35
|
//初始化购物车面板显示
|
34
|
//初始化购物车面板显示
|
36
|
function init() {
|
35
|
function init() {
|
37
|
- var $firstRow;
|
|
|
38
|
-
|
|
|
39
|
hasChooseColor = false;
|
36
|
hasChooseColor = false;
|
40
|
hasChooseSize = false;
|
37
|
hasChooseSize = false;
|
41
|
$curSizeBlock = null;
|
38
|
$curSizeBlock = null;
|
|
@@ -44,9 +41,7 @@ function init() { |
|
@@ -44,9 +41,7 @@ function init() { |
44
|
$allChoseItems = $('.chose-items');
|
41
|
$allChoseItems = $('.chose-items');
|
45
|
$sizeRowList = $('.size-list ul');
|
42
|
$sizeRowList = $('.size-list ul');
|
46
|
$leftNum = $('#left-num');
|
43
|
$leftNum = $('#left-num');
|
47
|
- $firstRow = $sizeRowList.eq(0);
|
|
|
48
|
- $firstRow.toggleClass('hide');
|
|
|
49
|
- $curSizeRow = $firstRow;
|
44
|
+ $sizeRowList.eq(0).toggleClass('hide');
|
50
|
}
|
45
|
}
|
51
|
|
46
|
|
52
|
function checkColorSizeNum() {
|
47
|
function checkColorSizeNum() {
|
|
@@ -69,6 +64,7 @@ function show(html, cb) { |
|
@@ -69,6 +64,7 @@ function show(html, cb) { |
69
|
init();
|
64
|
init();
|
70
|
}
|
65
|
}
|
71
|
$('.chose-panel').show();
|
66
|
$('.chose-panel').show();
|
|
|
67
|
+ $('body').css('overflow', 'hidden');
|
72
|
$num = $('#good-num');
|
68
|
$num = $('#good-num');
|
73
|
cbFn = cb;
|
69
|
cbFn = cb;
|
74
|
}
|
70
|
}
|
|
@@ -76,6 +72,7 @@ function show(html, cb) { |
|
@@ -76,6 +72,7 @@ function show(html, cb) { |
76
|
//隐藏当前Panel
|
72
|
//隐藏当前Panel
|
77
|
function hide() {
|
73
|
function hide() {
|
78
|
$('.chose-panel').hide();
|
74
|
$('.chose-panel').hide();
|
|
|
75
|
+ $('body').css('overflow', 'auto');
|
79
|
}
|
76
|
}
|
80
|
|
77
|
|
81
|
//修改加入购物车的文字和背景
|
78
|
//修改加入购物车的文字和背景
|
|
@@ -90,21 +87,25 @@ function updateConformButtonClassAndText() { |
|
@@ -90,21 +87,25 @@ function updateConformButtonClassAndText() { |
90
|
|
87
|
|
91
|
//重置颜色块的库存为0的样式
|
88
|
//重置颜色块的库存为0的样式
|
92
|
function resetColorZeroStock($siblingBlock) {
|
89
|
function resetColorZeroStock($siblingBlock) {
|
93
|
- var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
|
90
|
+ var numArray,
|
94
|
i;
|
91
|
i;
|
95
|
|
92
|
|
96
|
if (!hasChooseSize) {
|
93
|
if (!hasChooseSize) {
|
97
|
$siblingBlock.find('ul>li').each(function() {
|
94
|
$siblingBlock.find('ul>li').each(function() {
|
98
|
- $(this).removeClass('zero-stock');
|
|
|
99
|
- if ('0' === $(this).data('num')) {
|
95
|
+ if (0 === $(this).data('num')) {
|
100
|
$(this).addClass('zero-stock');
|
96
|
$(this).addClass('zero-stock');
|
|
|
97
|
+ } else {
|
|
|
98
|
+ $(this).removeClass('zero-stock');
|
101
|
}
|
99
|
}
|
102
|
});
|
100
|
});
|
103
|
|
101
|
|
104
|
} else {
|
102
|
} else {
|
|
|
103
|
+ numArray = ($curSizeBlock.data('numstr') + '').split('/');
|
105
|
for (i = 0; i < numArray.length; i++) {
|
104
|
for (i = 0; i < numArray.length; i++) {
|
106
|
if ('0' === numArray[i]) {
|
105
|
if ('0' === numArray[i]) {
|
107
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
106
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
107
|
+ } else {
|
|
|
108
|
+ $siblingBlock.find('.block').eq(i).removeClass('zero-stock');
|
108
|
}
|
109
|
}
|
109
|
}
|
110
|
}
|
110
|
}
|
111
|
}
|
|
@@ -130,12 +131,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { |
|
@@ -130,12 +131,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { |
130
|
hide();
|
131
|
hide();
|
131
|
});
|
132
|
});
|
132
|
|
133
|
|
133
|
-$yohoPage.on('touchstart', '.color-list .block', function(e) {
|
134
|
+$yohoPage.on('touchstart', '.color-list .block', function() {
|
134
|
var $this = $(this),
|
135
|
var $this = $(this),
|
135
|
index,
|
136
|
index,
|
136
|
curSizeBlock,
|
137
|
curSizeBlock,
|
137
|
$preSiblingBlock,
|
138
|
$preSiblingBlock,
|
138
|
- scindex,
|
139
|
+ $curSizeRow,
|
|
|
140
|
+ numArray,
|
|
|
141
|
+ i,
|
139
|
curGoodNum;
|
142
|
curGoodNum;
|
140
|
|
143
|
|
141
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
144
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
@@ -144,7 +147,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
|
@@ -144,7 +147,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
144
|
index = $this.index();
|
147
|
index = $this.index();
|
145
|
|
148
|
|
146
|
$preSiblingBlock = $siblingBlock.find('.chosed');
|
149
|
$preSiblingBlock = $siblingBlock.find('.chosed');
|
147
|
- scindex = $preSiblingBlock.index();
|
|
|
148
|
$curSizeRow = $sizeRowList.eq(index);
|
150
|
$curSizeRow = $sizeRowList.eq(index);
|
149
|
|
151
|
|
150
|
// 当前颜色已经是选中状态,再点击时
|
152
|
// 当前颜色已经是选中状态,再点击时
|
|
@@ -155,6 +157,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
|
@@ -155,6 +157,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
155
|
$leftNum.val(0);
|
157
|
$leftNum.val(0);
|
156
|
hasChooseColor = false;
|
158
|
hasChooseColor = false;
|
157
|
|
159
|
|
|
|
160
|
+ $this.removeClass('zero-stock');
|
|
|
161
|
+ if ($curSizeBlock) {
|
|
|
162
|
+ numArray = ($curSizeBlock.data('numstr') + '').split('/');
|
|
|
163
|
+ for (i = 0; i < numArray.length; i++) {
|
|
|
164
|
+ if ('0' === numArray[i]) {
|
|
|
165
|
+ $('.color-list .block').eq(i).addClass('zero-stock');
|
|
|
166
|
+ }
|
|
|
167
|
+ }
|
|
|
168
|
+ }
|
|
|
169
|
+
|
158
|
// 当前颜色不是选中状态,选中时
|
170
|
// 当前颜色不是选中状态,选中时
|
159
|
} else {
|
171
|
} else {
|
160
|
hasChooseColor = true;
|
172
|
hasChooseColor = true;
|
|
@@ -166,7 +178,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
|
@@ -166,7 +178,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
166
|
// 之前选中的尺码去掉勾选样式
|
178
|
// 之前选中的尺码去掉勾选样式
|
167
|
if ($preSiblingBlock.length > 0) {
|
179
|
if ($preSiblingBlock.length > 0) {
|
168
|
$preSiblingBlock.removeClass('chosed');
|
180
|
$preSiblingBlock.removeClass('chosed');
|
169
|
- curSizeBlock = $curSizeRow.children().get(scindex);
|
181
|
+ curSizeBlock = $curSizeRow.children().get(curSizeIndex);
|
170
|
}
|
182
|
}
|
171
|
|
183
|
|
172
|
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
|
184
|
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
|
|
@@ -194,11 +206,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
|
@@ -194,11 +206,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
194
|
|
206
|
|
195
|
// 修改颜色时修改商品图片
|
207
|
// 修改颜色时修改商品图片
|
196
|
changeGoodImgWhenClickColor();
|
208
|
changeGoodImgWhenClickColor();
|
197
|
-});
|
|
|
198
|
-
|
|
|
199
|
-$yohoPage.on('touchstart', '.size-list .block', function(e) {
|
209
|
+}).on('touchstart', '.size-list .block', function() {
|
200
|
var $this = $(this),
|
210
|
var $this = $(this),
|
201
|
index,
|
211
|
index,
|
|
|
212
|
+ $curSizeRow,
|
202
|
curGoodNum;
|
213
|
curGoodNum;
|
203
|
|
214
|
|
204
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
215
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
@@ -246,7 +257,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) { |
|
@@ -246,7 +257,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) { |
246
|
|
257
|
|
247
|
// 重置颜色块的样式
|
258
|
// 重置颜色块的样式
|
248
|
resetColorZeroStock($siblingBlock);
|
259
|
resetColorZeroStock($siblingBlock);
|
249
|
-
|
|
|
250
|
});
|
260
|
});
|
251
|
|
261
|
|
252
|
$yohoPage.on('touchstart', '.btn-minus', function() {
|
262
|
$yohoPage.on('touchstart', '.btn-minus', function() {
|
|
@@ -332,7 +342,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
@@ -332,7 +342,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
332
|
if (res.code === 200) {
|
342
|
if (res.code === 200) {
|
333
|
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
|
343
|
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
|
334
|
confirming = false;
|
344
|
confirming = false;
|
335
|
- hide();
|
|
|
336
|
|
345
|
|
337
|
if (cbFn) {
|
346
|
if (cbFn) {
|
338
|
cbFn();
|
347
|
cbFn();
|
|
@@ -341,6 +350,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
@@ -341,6 +350,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
341
|
if (res.message) {
|
350
|
if (res.message) {
|
342
|
tip.show(res.message);
|
351
|
tip.show(res.message);
|
343
|
}
|
352
|
}
|
|
|
353
|
+
|
|
|
354
|
+ hide();
|
344
|
}).fail(function() {
|
355
|
}).fail(function() {
|
345
|
tip.show('网络出了点问题~');
|
356
|
tip.show('网络出了点问题~');
|
346
|
}).always(function() {
|
357
|
}).always(function() {
|