Authored by uedxwg

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -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,18 +87,19 @@ function updateConformButtonClassAndText() { @@ -90,18 +87,19 @@ 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'); 95 $(this).removeClass('zero-stock');
99 - if ('0' === $(this).data('num')) { 96 + if (0 === $(this).data('num')) {
100 $(this).addClass('zero-stock'); 97 $(this).addClass('zero-stock');
101 } 98 }
102 }); 99 });
103 100
104 } else { 101 } else {
  102 + numArray = ($curSizeBlock.data('numstr') + '').split('/');
105 for (i = 0; i < numArray.length; i++) { 103 for (i = 0; i < numArray.length; i++) {
106 if ('0' === numArray[i]) { 104 if ('0' === numArray[i]) {
107 $siblingBlock.find('.block').eq(i).addClass('zero-stock'); 105 $siblingBlock.find('.block').eq(i).addClass('zero-stock');
@@ -130,12 +128,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { @@ -130,12 +128,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
130 hide(); 128 hide();
131 }); 129 });
132 130
133 -$yohoPage.on('touchstart', '.color-list .block', function(e) { 131 +$yohoPage.on('touchstart', '.color-list .block', function() {
134 var $this = $(this), 132 var $this = $(this),
135 index, 133 index,
136 curSizeBlock, 134 curSizeBlock,
137 $preSiblingBlock, 135 $preSiblingBlock,
138 - scindex, 136 + $curSizeRow,
  137 + numArray,
  138 + i,
139 curGoodNum; 139 curGoodNum;
140 140
141 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 141 var $siblingBlock = $this.closest('.block-list').siblings(':first');
@@ -144,7 +144,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { @@ -144,7 +144,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
144 index = $this.index(); 144 index = $this.index();
145 145
146 $preSiblingBlock = $siblingBlock.find('.chosed'); 146 $preSiblingBlock = $siblingBlock.find('.chosed');
147 - scindex = $preSiblingBlock.index();  
148 $curSizeRow = $sizeRowList.eq(index); 147 $curSizeRow = $sizeRowList.eq(index);
149 148
150 // 当前颜色已经是选中状态,再点击时 149 // 当前颜色已经是选中状态,再点击时
@@ -155,6 +154,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { @@ -155,6 +154,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
155 $leftNum.val(0); 154 $leftNum.val(0);
156 hasChooseColor = false; 155 hasChooseColor = false;
157 156
  157 + $this.removeClass('zero-stock');
  158 + if ($curSizeBlock) {
  159 + numArray = ($curSizeBlock.data('numstr') + '').split('/');
  160 + for (i = 0; i < numArray.length; i++) {
  161 + if ('0' === numArray[i]) {
  162 + $('.color-list .block').eq(i).addClass('zero-stock');
  163 + }
  164 + }
  165 + }
  166 +
158 // 当前颜色不是选中状态,选中时 167 // 当前颜色不是选中状态,选中时
159 } else { 168 } else {
160 hasChooseColor = true; 169 hasChooseColor = true;
@@ -166,7 +175,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { @@ -166,7 +175,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
166 // 之前选中的尺码去掉勾选样式 175 // 之前选中的尺码去掉勾选样式
167 if ($preSiblingBlock.length > 0) { 176 if ($preSiblingBlock.length > 0) {
168 $preSiblingBlock.removeClass('chosed'); 177 $preSiblingBlock.removeClass('chosed');
169 - curSizeBlock = $curSizeRow.children().get(scindex); 178 + curSizeBlock = $curSizeRow.children().get(curSizeIndex);
170 } 179 }
171 180
172 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在) 181 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
@@ -194,11 +203,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { @@ -194,11 +203,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
194 203
195 // 修改颜色时修改商品图片 204 // 修改颜色时修改商品图片
196 changeGoodImgWhenClickColor(); 205 changeGoodImgWhenClickColor();
197 -});  
198 -  
199 -$yohoPage.on('touchstart', '.size-list .block', function(e) { 206 +}).on('touchstart', '.size-list .block', function() {
200 var $this = $(this), 207 var $this = $(this),
201 index, 208 index,
  209 + $curSizeRow,
202 curGoodNum; 210 curGoodNum;
203 211
204 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 212 var $siblingBlock = $this.closest('.block-list').siblings(':first');
@@ -246,7 +254,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) { @@ -246,7 +254,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) {
246 254
247 // 重置颜色块的样式 255 // 重置颜色块的样式
248 resetColorZeroStock($siblingBlock); 256 resetColorZeroStock($siblingBlock);
249 -  
250 }); 257 });
251 258
252 $yohoPage.on('touchstart', '.btn-minus', function() { 259 $yohoPage.on('touchstart', '.btn-minus', function() {
@@ -342,7 +349,6 @@ $yohoPage.on('touchstart', '#chose-btn-sure', function() { @@ -342,7 +349,6 @@ $yohoPage.on('touchstart', '#chose-btn-sure', function() {
342 if (res.code === 200) { 349 if (res.code === 200) {
343 $('.num-tag').html(numInCart + buyNumber).removeClass('hide'); 350 $('.num-tag').html(numInCart + buyNumber).removeClass('hide');
344 confirming = false; 351 confirming = false;
345 - hide();  
346 352
347 if (cbFn) { 353 if (cbFn) {
348 cbFn(); 354 cbFn();
@@ -351,6 +357,8 @@ $yohoPage.on('touchstart', '#chose-btn-sure', function() { @@ -351,6 +357,8 @@ $yohoPage.on('touchstart', '#chose-btn-sure', function() {
351 if (res.message) { 357 if (res.message) {
352 tip.show(res.message); 358 tip.show(res.message);
353 } 359 }
  360 +
  361 + hide();
354 }).fail(function() { 362 }).fail(function() {
355 tip.show('网络出了点问题~'); 363 tip.show('网络出了点问题~');
356 }).always(function() { 364 }).always(function() {