Authored by biao

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

@@ -846,7 +846,16 @@ @@ -846,7 +846,16 @@
846 846
847 { 847 {
848 id: 1, 848 id: 1,
  849 + inValid: true, //是否是失效商品,
  850 +
  851 + showCheckbox: true, //是否显示checkbox【赠品和加价购不显示】
  852 + checked: true, //是否选中
  853 +
849 thumb: '', 854 thumb: '',
  855 +
  856 + isAdvanceBuy: true, //是否是加价购商品
  857 + isGift: ture, //是否是赠品
  858 +
850 name: '', 859 name: '',
851 color: '黄色', 860 color: '黄色',
852 size: 'L', 861 size: 'L',
1 -/**  
2 - * 购物车信息读取  
3 - * @author: liangzhifeng<zhifeng.liang@yoho.cn>  
4 - * @date: 2015/12/15  
5 - */  
6 -var info = window.cookie('cart-info');  
7 -  
8 -// info 必须是 JSON 字符串  
9 -try {  
10 - info = JSON.parse(info);  
11 -} catch (e) {  
12 - info = {  
13 - deliveryId: null,  
14 - deliveryTimeId: null,  
15 - paymentTypeId: null,  
16 - yohoCoin: null,  
17 - addressId: null,  
18 - couponCode: null,  
19 - couponValue: null,  
20 - invoice: null,  
21 - invoiceText: null,  
22 - invoiceType: null,  
23 - msg: null  
24 - };  
25 - window.setCookie('cart-info', JSON.stringify(info));  
26 -}  
27 -  
28 -exports.cartInfo = function(key, value) {  
29 - if (value === undefined) {  
30 - return info[key];  
31 - }  
32 - info[key] = value;  
33 - window.setCookie('cart-info', JSON.stringify(info));  
34 -};  
@@ -50,6 +50,10 @@ if ($('.cart-nav').length > 0) { @@ -50,6 +50,10 @@ if ($('.cart-nav').length > 0) {
50 //trigger lazyload 50 //trigger lazyload
51 $(window).trigger('scroll'); 51 $(window).trigger('scroll');
52 }); 52 });
  53 +
  54 + setTimeout(function() {
  55 + $('#presell-tip').addClass('hide');
  56 + }, 3000);
53 } 57 }
54 58
55 $('.btn-balance').on('touchend', function() { 59 $('.btn-balance').on('touchend', function() {
@@ -10,53 +10,42 @@ @@ -10,53 +10,42 @@
10 // 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框 10 // 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
11 11
12 var $ = require('jquery'), 12 var $ = require('jquery'),
13 - Handlebars = require('yoho.handlebars'),  
14 tip = require('../plugin/tip'), 13 tip = require('../plugin/tip'),
15 loading = require('../plugin/loading'); 14 loading = require('../plugin/loading');
16 15
17 -var panelTmpl,  
18 - $chosePanel = $('#chose-panel'), 16 +var $chosePanel = $('#chose-panel'),
19 $num, 17 $num,
20 $chosed, 18 $chosed,
  19 + $imgsThumb,
21 20
22 // re = /\d+/, 21 // re = /\d+/,
  22 +
  23 + $leftNum,
23 leftNum, 24 leftNum,
24 confirming, 25 confirming,
25 - hasChooseColor = false,  
26 - hasChooseSize = false,  
27 curColorIndex, 26 curColorIndex,
28 curSizeIndex, 27 curSizeIndex,
29 $curSizeRow, 28 $curSizeRow,
30 - $curSizeBlock = null,  
31 - $sizeRowList = $('.size-list ul');  
32 -  
33 -// 读取模板  
34 -$.get('/cart/index/giftinfoTpl', function(html) {  
35 - if (!html) {  
36 - tip.show('网络错误');  
37 - return;  
38 - }  
39 - panelTmpl = Handlebars.compile(html);  
40 -}).fail(function() {  
41 - tip.show('网络错误');  
42 -}); 29 + hasChooseColor,
  30 + hasChooseSize,
  31 + $curSizeBlock,
  32 + $sizeRowList,
  33 + cbFn,
  34 + $allChoseItems,
  35 + $yohoPage = $('.yoho-page');
43 36
44 //初始化购物车面板显示 37 //初始化购物车面板显示
45 function init() { 38 function init() {
46 -  
47 - //$colorList = $('.chose-panel .color-list ul>li');  
48 - //$sizeList = $('.chose-panel .size-list ul>li');  
49 - //firstColorId = $colorList.eq(0).data('id');  
50 - //$sizeList.each(function() {  
51 - // colorIndex = $(this).data('colorid');  
52 - //  
53 - // if (colorIndex === firstColorId) {  
54 - // $(this).removeClass('hide');  
55 - // }  
56 - //});  
57 -  
58 - var $firstRow = $sizeRowList.eq(0);  
59 - 39 + var $firstRow;
  40 +
  41 + hasChooseColor = false;
  42 + hasChooseSize = false;
  43 + $curSizeBlock = null;
  44 + $imgsThumb = $('.chose-panel').find('.thumb'),
  45 + $allChoseItems = $('.chose-items'),
  46 + $sizeRowList = $('.size-list ul'),
  47 + $leftNum = $('#left-num'),
  48 + $firstRow = $sizeRowList.eq(0);
60 $firstRow.toggleClass('hide'); 49 $firstRow.toggleClass('hide');
61 $curSizeRow = $firstRow; 50 $curSizeRow = $firstRow;
62 } 51 }
@@ -75,34 +64,64 @@ function checkColorSizeNum() { @@ -75,34 +64,64 @@ function checkColorSizeNum() {
75 return true; 64 return true;
76 } 65 }
77 66
78 -init();  
79 -  
80 -function show(data) {  
81 - if (data) {  
82 - $chosePanel.html(panelTmpl(data)); 67 +function show(html, cb) {
  68 + if (html) {
  69 + $chosePanel.html(html);
83 init(); 70 init();
84 } 71 }
85 $('.chose-panel').show(); 72 $('.chose-panel').show();
86 -  
87 - $('body').css('overflow', 'hidden');  
88 $num = $('#good-num'); 73 $num = $('#good-num');
  74 + cbFn = cb;
89 } 75 }
90 76
91 -////显示当前Panel  
92 -//function show() {  
93 -// $('.chose-panel').show();  
94 -//  
95 -// $('body').css('overflow', 'hidden');  
96 -// $num = $('#good-num');  
97 -//}  
98 -  
99 //隐藏当前Panel 77 //隐藏当前Panel
100 function hide() { 78 function hide() {
101 $('.chose-panel').hide(); 79 $('.chose-panel').hide();
102 - $('body').css('overflow', 'auto'); 80 + cbFn = null;
  81 +}
  82 +
  83 +//修改加入购物车的文字和背景
  84 +function updateConformButtonClassAndText() {
  85 + $chosed = $allChoseItems.find('.chosed');
  86 + if (2 === $chosed.closest('.zero-stock').length) {
  87 + $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
  88 + } else {
  89 + $('#chose-btn-sure').css('background-color', '#eb0313').html('确定');
  90 + }
  91 +}
  92 +
  93 +//重置颜色块的库存为0的样式
  94 +function resetColorZeroStock($siblingBlock) {
  95 + var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
  96 + i;
  97 +
  98 + if (!hasChooseSize) {
  99 + $siblingBlock.find('ul>li').each(function() {
  100 + $(this).removeClass('zero-stock');
  101 + if ('0' === $(this).data('num')) {
  102 + $(this).addClass('zero-stock');
  103 + }
  104 + });
  105 +
  106 + } else {
  107 + for (i = 0; i < numArray.length; i++) {
  108 + if ('0' === numArray[i]) {
  109 + $siblingBlock.find('.block').eq(i).addClass('zero-stock');
  110 + }
  111 + }
  112 + }
  113 +}
  114 +
  115 +// 选择了颜色切换商品图片
  116 +function changeGoodImgWhenClickColor() {
  117 + if (hasChooseColor && curColorIndex) {
  118 + $imgsThumb.addClass('hide').eq(curColorIndex).removeClass('hide');
  119 + }
103 } 120 }
104 121
105 -$('.yoho-page').on('touchstart', '.chose-panel', function(e) { 122 +init();
  123 +
  124 +$yohoPage.on('touchstart', '.chose-panel', function(e) {
106 var $cur = $(e.target); 125 var $cur = $(e.target);
107 126
108 if ($cur.closest('.main').length > 0) { 127 if ($cur.closest('.main').length > 0) {
@@ -113,12 +132,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -113,12 +132,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
113 hide(); 132 hide();
114 }); 133 });
115 134
116 -$('.color-list').on('touchstart', '.block', function(e) { 135 +$yohoPage.on('touchstart', '.color-list .block', function(e) {
117 var $this = $(this), 136 var $this = $(this),
118 - $that = $(e.target).closest('.chose-items'),  
119 index, 137 index,
120 - curSelectedSizeBlock,  
121 - $sizeChosed, 138 + curSizeBlock,
  139 + $preSiblingBlock,
122 scindex, 140 scindex,
123 curGoodNum; 141 curGoodNum;
124 142
@@ -127,50 +145,46 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -127,50 +145,46 @@ $('.color-list').on('touchstart', '.block', function(e) {
127 $this.siblings('.chosed').removeClass('chosed'); 145 $this.siblings('.chosed').removeClass('chosed');
128 index = $this.index(); 146 index = $this.index();
129 147
130 - $sizeChosed = $siblingBlock.find('.chosed');  
131 - scindex = $sizeChosed.index(); 148 + $preSiblingBlock = $siblingBlock.find('.chosed');
  149 + scindex = $preSiblingBlock.index();
132 $curSizeRow = $sizeRowList.eq(index); 150 $curSizeRow = $sizeRowList.eq(index);
133 151
134 // 当前颜色已经是选中状态,再点击时 152 // 当前颜色已经是选中状态,再点击时
135 if ($this.hasClass('chosed')) { 153 if ($this.hasClass('chosed')) {
136 154
137 //颜色原来已经是勾选时,要清空剩余件数的提示 155 //颜色原来已经是勾选时,要清空剩余件数的提示
138 - $that.find('.num .left-num').html('');  
139 - $('#left-num').val(0); 156 + $allChoseItems.find('.num .left-num').html('');
  157 + $leftNum.val(0);
140 hasChooseColor = false; 158 hasChooseColor = false;
141 159
142 // 当前颜色不是选中状态,选中时 160 // 当前颜色不是选中状态,选中时
143 } else { 161 } else {
144 hasChooseColor = true; 162 hasChooseColor = true;
145 163
146 - //根据颜色切换图片  
147 - if ($this.closest('.block-list').hasClass('color-list')) {  
148 - $('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');  
149 - }  
150 -  
151 //把当前选中颜色对应的尺码那一行显示出来 164 //把当前选中颜色对应的尺码那一行显示出来
152 $sizeRowList.addClass('hide'); 165 $sizeRowList.addClass('hide');
153 $curSizeRow.removeClass('hide').addClass('show'); 166 $curSizeRow.removeClass('hide').addClass('show');
154 167
155 // 之前选中的尺码去掉勾选样式 168 // 之前选中的尺码去掉勾选样式
156 - if ($sizeChosed.length > 0) {  
157 - $sizeChosed.removeClass('chosed');  
158 - curSelectedSizeBlock = $curSizeRow.children().get(scindex); 169 + if ($preSiblingBlock.length > 0) {
  170 + $preSiblingBlock.removeClass('chosed');
  171 +
159 } 172 }
160 173
  174 + curSizeBlock = $curSizeRow.children().get(scindex);
  175 +
161 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在) 176 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
162 - if (curSelectedSizeBlock) {  
163 - curGoodNum = $(curSelectedSizeBlock).data('num');  
164 - $(curSelectedSizeBlock).addClass('chosed'); 177 + if (curSizeBlock) {
  178 + curGoodNum = $(curSizeBlock).data('num');
  179 + $(curSizeBlock).addClass('chosed');
165 180
166 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式 181 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
167 if (curGoodNum > 0) { 182 if (curGoodNum > 0) {
168 - $that.find('.num .left-num').html('剩余' + curGoodNum + '件');  
169 - $('#left-num').val(curGoodNum); 183 + $allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
  184 + $leftNum.val(curGoodNum);
170 } else { 185 } else {
171 - $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');  
172 - $that.find('.num .left-num').html('');  
173 - $('#left-num').val(0); 186 + $allChoseItems.find('.num .left-num').html('');
  187 + $leftNum.val(0);
174 } 188 }
175 } 189 }
176 } 190 }
@@ -180,106 +194,31 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -180,106 +194,31 @@ $('.color-list').on('touchstart', '.block', function(e) {
180 curColorIndex = index; 194 curColorIndex = index;
181 195
182 // 设置按钮的样式和文字 196 // 设置按钮的样式和文字
183 - $chosed = $('.chose-items').find('.chosed');  
184 - if (2 === $chosed.closest('.zero-stock').length) {  
185 - $('#chose-btn-sure').css('background-color', '#c0c0c0');  
186 - $('#chose-btn-sure').html('已售罄');  
187 - } else {  
188 - $('#chose-btn-sure').css('background-color', '#eb0313');  
189 - $('#chose-btn-sure').html('确定');  
190 - }  
191 -  
192 - /**if ($chosed.length === 0) {  
193 - $this.closest('ul>li').each(function() {  
194 - $(this).removeClass('zero-stock');  
195 - if ('0' === $(this).data('num')) {  
196 - $(this).addClass('zero-stock');  
197 - }  
198 - });  
199 -  
200 - $siblingBlock.find('ul>li').each(function() {  
201 - $(this).removeClass('zero-stock');  
202 - if ('0' === $(this).data('num')) {  
203 - $(this).addClass('zero-stock');  
204 - }  
205 - });  
206 - } else if ($chosed.length === 1 && $this.hasClass('chosed')) {  
207 - $sizeList.addClass('hide');  
208 -  
209 - //切换尺码信息  
210 - $sizeList.each(function() {  
211 - colorIndex = $(this).data('colorid');  
212 - if (colorIndex === $this.data('id')) {  
213 - $(this).removeClass('hide');  
214 - }  
215 - });  
216 -  
217 - numArray = ($chosed.data('numstr') + '').split('/');  
218 - $siblingBlock.find('.block').removeClass('zero-stock');  
219 - for (i = 0; i < numArray.length; i++) {  
220 - if ('0' === numArray[i]) {  
221 - $siblingBlock.find('.block').eq(i).addClass('zero-stock');  
222 - }  
223 - }  
224 - } else if ($chosed.length === 1 && !$this.hasClass('chosed')) {  
225 - $('#chose-btn-sure').css('background-color', '#eb0313');  
226 - $('#chose-btn-sure').html('确定');  
227 -  
228 - $siblingBlock.find('ul>li').each(function() {  
229 - $(this).removeClass('zero-stock');  
230 - if ('0' === $(this).data('num')) {  
231 - $(this).addClass('zero-stock');  
232 - }  
233 - });  
234 - $that.find('.num .left-num').html('');  
235 - } else if ($chosed.length === 2) {  
236 - $siblingBlock.find('.block').removeClass('zero-stock');  
237 - for (i = 0; i < currentNumArray.length; i++) {  
238 - if ('0' === currentNumArray[i]) {  
239 - $siblingBlock.find('.block').eq(i).addClass('zero-stock');  
240 - }  
241 - }  
242 - numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');  
243 - $that.find('.num .left-num').html('剩余' + numArray[index] + '件');  
244 - if (2 === $chosed.closest('.zero-stock').length) {  
245 - $('#chose-btn-sure').css('background-color', '#c0c0c0');  
246 - $('#chose-btn-sure').html('已售罄');  
247 - } else {  
248 - $('#chose-btn-sure').css('background-color', '#eb0313');  
249 - $('#chose-btn-sure').html('确定');  
250 - }  
251 - }**/ 197 + updateConformButtonClassAndText();
252 198
  199 + // 修改颜色时修改商品图片
  200 + changeGoodImgWhenClickColor();
253 }); 201 });
254 202
255 -$('.size-list').on('touchstart', '.block', function(e) { 203 +$yohoPage.on('touchstart', '.size-list .block', function(e) {
256 var $this = $(this), 204 var $this = $(this),
257 - $that = $(e.target).closest('.chose-items'),  
258 index, 205 index,
259 - $colorChosed,  
260 curGoodNum; 206 curGoodNum;
261 207
262 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 208 var $siblingBlock = $this.closest('.block-list').siblings(':first');
263 209
264 $this.siblings('.chosed').removeClass('chosed'); 210 $this.siblings('.chosed').removeClass('chosed');
265 index = $this.index(); 211 index = $this.index();
266 -  
267 - $colorChosed = $siblingBlock.find('.chosed');  
268 $curSizeRow = $sizeRowList.eq(index); 212 $curSizeRow = $sizeRowList.eq(index);
269 213
270 // 当前尺码已经是选中状态,再点击时 214 // 当前尺码已经是选中状态,再点击时
271 if ($this.hasClass('chosed')) { 215 if ($this.hasClass('chosed')) {
272 216
273 //尺码原来已经是勾选时,要清空剩余件数的提示 217 //尺码原来已经是勾选时,要清空剩余件数的提示
274 - $that.find('.num .left-num').html(''); 218 + $allChoseItems.find('.num .left-num').html('');
275 $('#left-num').val(0); 219 $('#left-num').val(0);
276 hasChooseSize = false; 220 hasChooseSize = false;
277 221
278 - // 去掉已经选中颜色的 数量为0的样式  
279 - if ($colorChosed.length > 0) {  
280 - $colorChosed.removeClass('zero-stock').addClass('zero-stock');  
281 - }  
282 -  
283 // 当前尺码不是选中状态,选中时 222 // 当前尺码不是选中状态,选中时
284 } else { 223 } else {
285 hasChooseSize = true; 224 hasChooseSize = true;
@@ -291,15 +230,15 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -291,15 +230,15 @@ $('.size-list').on('touchstart', '.block', function(e) {
291 $curSizeBlock.removeClass('chosed'); 230 $curSizeBlock.removeClass('chosed');
292 } 231 }
293 232
294 - // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数 233 + // 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
295 if (curGoodNum > 0 && hasChooseColor) { 234 if (curGoodNum > 0 && hasChooseColor) {
296 - $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 235 + $allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
297 $('#left-num').val(curGoodNum); 236 $('#left-num').val(curGoodNum);
298 } else { 237 } else {
299 - $colorChosed.removeClass('zero-stock').addClass('zero-stock');  
300 - $that.find('.num .left-num').html(''); 238 + $allChoseItems.find('.num .left-num').html('');
301 $('#left-num').val(0); 239 $('#left-num').val(0);
302 } 240 }
  241 +
303 } 242 }
304 243
305 $this.toggleClass('chosed'); 244 $this.toggleClass('chosed');
@@ -307,83 +246,15 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -307,83 +246,15 @@ $('.size-list').on('touchstart', '.block', function(e) {
307 $curSizeBlock = $this; 246 $curSizeBlock = $this;
308 247
309 // 设置按钮的样式和文字 248 // 设置按钮的样式和文字
310 - $chosed = $('.chose-items').find('.chosed');  
311 - if (2 === $chosed.closest('.zero-stock').length) {  
312 - $('#chose-btn-sure').css('background-color', '#c0c0c0');  
313 - $('#chose-btn-sure').html('已售罄');  
314 - } else {  
315 - $('#chose-btn-sure').css('background-color', '#eb0313');  
316 - $('#chose-btn-sure').html('确定');  
317 - } 249 + updateConformButtonClassAndText();
318 250
319 - /**if ($chosed.length === 0) {  
320 - $this.closest('ul>li').each(function() {  
321 - $(this).removeClass('zero-stock');  
322 - if ('0' === $(this).data('num')) {  
323 - $(this).addClass('zero-stock');  
324 - }  
325 - });  
326 -  
327 - $siblingBlock.find('ul>li').each(function() {  
328 - $(this).removeClass('zero-stock');  
329 - if ('0' === $(this).data('num')) {  
330 - $(this).addClass('zero-stock');  
331 - }  
332 - });  
333 - } else if ($chosed.length === 1 && $this.hasClass('chosed')) {  
334 - if ($this.closest('.block-list').hasClass('color-list')) {  
335 -  
336 - $sizeList.addClass('hide');  
337 -  
338 - //切换尺码信息  
339 - $sizeList.each(function() {  
340 - colorIndex = $(this).data('colorid');  
341 - if (colorIndex === $this.data('id')) {  
342 - $(this).removeClass('hide');  
343 - }  
344 - });  
345 - }  
346 -  
347 - numArray = ($chosed.data('numstr') + '').split('/');  
348 - $siblingBlock.find('.block').removeClass('zero-stock');  
349 - for (i = 0; i < numArray.length; i++) {  
350 - if ('0' === numArray[i]) {  
351 - $siblingBlock.find('.block').eq(i).addClass('zero-stock');  
352 - }  
353 - }  
354 - } else if ($chosed.length === 1 && !$this.hasClass('chosed')) {  
355 - $('#chose-btn-sure').css('background-color', '#eb0313');  
356 - $('#chose-btn-sure').html('确定');  
357 -  
358 - $siblingBlock.find('ul>li').each(function() {  
359 - $(this).removeClass('zero-stock');  
360 - if ('0' === $(this).data('num')) {  
361 - $(this).addClass('zero-stock');  
362 - }  
363 - });  
364 - $that.find('.num .left-num').html('');  
365 - } else if ($chosed.length === 2) {  
366 - $siblingBlock.find('.block').removeClass('zero-stock');  
367 - for (i = 0; i < currentNumArray.length; i++) {  
368 - if ('0' === currentNumArray[i]) {  
369 - $siblingBlock.find('.block').eq(i).addClass('zero-stock');  
370 - }  
371 - }  
372 - numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');  
373 - $that.find('.num .left-num').html('剩余' + numArray[index] + '件');  
374 - if (2 === $chosed.closest('.zero-stock').length) {  
375 - $('#chose-btn-sure').css('background-color', '#c0c0c0');  
376 - $('#chose-btn-sure').html('已售罄');  
377 - } else {  
378 - $('#chose-btn-sure').css('background-color', '#eb0313');  
379 - $('#chose-btn-sure').html('确定');  
380 - }  
381 - }**/ 251 + // 重置颜色块的样式
  252 + resetColorZeroStock($siblingBlock);
382 253
383 }); 254 });
384 255
385 -$('.btn-minus').on('touchstart', function() {  
386 - var num = $num.val(); 256 +$yohoPage.on('touchstart', '.btn-minus', function() {
  257 + var num = parseInt($num.val(), 10);
387 258
388 leftNum = $('#left-num').val(); 259 leftNum = $('#left-num').val();
389 260
@@ -396,10 +267,8 @@ $('.btn-minus').on('touchstart', function() { @@ -396,10 +267,8 @@ $('.btn-minus').on('touchstart', function() {
396 } 267 }
397 268
398 $num.val(num - 1); 269 $num.val(num - 1);
399 -});  
400 -  
401 -$('.btn-plus').on('touchstart', function() {  
402 - var num = $num.val(); 270 +}).on('touchstart', '.btn-plus', function() {
  271 + var num = parseInt($num.val(), 10);
403 272
404 leftNum = $('#left-num').val(); 273 leftNum = $('#left-num').val();
405 274
@@ -414,9 +283,7 @@ $('.btn-plus').on('touchstart', function() { @@ -414,9 +283,7 @@ $('.btn-plus').on('touchstart', function() {
414 283
415 //TODO:库存数验证 284 //TODO:库存数验证
416 $num.val(num + 1); 285 $num.val(num + 1);
417 -});  
418 -  
419 -$('#chose-btn-sure').on('touchstart', function() { 286 +}).on('touchstart', '#chose-btn-sure', function() {
420 287
421 var productSku, 288 var productSku,
422 buyNumber = $('#good-num').val() - 0, 289 buyNumber = $('#good-num').val() - 0,
@@ -426,10 +293,12 @@ $('#chose-btn-sure').on('touchstart', function() { @@ -426,10 +293,12 @@ $('#chose-btn-sure').on('touchstart', function() {
426 numInCart = $('.num-tag').html() - 0, 293 numInCart = $('.num-tag').html() - 0,
427 num = $num.val(); 294 num = $num.val();
428 295
  296 + //颜色尺码没有选择
429 if (!checkColorSizeNum()) { 297 if (!checkColorSizeNum()) {
430 return; 298 return;
431 } 299 }
432 300
  301 + //TODO status change
433 if ($('#chose-btn-sure').html() === '已售罄') { 302 if ($('#chose-btn-sure').html() === '已售罄') {
434 return; 303 return;
435 } 304 }
@@ -464,10 +333,13 @@ $('#chose-btn-sure').on('touchstart', function() { @@ -464,10 +333,13 @@ $('#chose-btn-sure').on('touchstart', function() {
464 }).done(function(res) { 333 }).done(function(res) {
465 loading.hideLoadingMask(); 334 loading.hideLoadingMask();
466 if (res.code === 200) { 335 if (res.code === 200) {
467 - $('.num-tag').html(numInCart + buyNumber);  
468 - $('.num-tag').removeClass('hide'); 336 + $('.num-tag').html(numInCart + buyNumber).removeClass('hide');
469 confirming = false; 337 confirming = false;
470 hide(); 338 hide();
  339 +
  340 + if (cbFn) {
  341 + cbFn(res.location);
  342 + }
471 } 343 }
472 if (res.message) { 344 if (res.message) {
473 tip.show(res.message); 345 tip.show(res.message);
@@ -19,19 +19,13 @@ function getProductInfo(skn, promotionId) { @@ -19,19 +19,13 @@ function getProductInfo(skn, promotionId) {
19 $.get('/cart/index/giftinfo', { 19 $.get('/cart/index/giftinfo', {
20 skn: skn, 20 skn: skn,
21 promotionId: promotionId 21 promotionId: promotionId
22 - }).then(function(res) {  
23 - if (!res) { 22 + }).then(function(html) {
  23 + if (!html) {
24 tip.show('网络错误'); 24 tip.show('网络错误');
25 return; 25 return;
26 } 26 }
27 - if (res.code === 200) {  
28 - chosePanel.show({  
29 - cartInfo: res.data  
30 - });  
31 - } else {  
32 - tip.show(res.message || '网络错误');  
33 - }  
34 - }).fail(function() { 27 + chosePanel.show(html);
  28 + }, function() {
35 tip.show('网络错误'); 29 tip.show('网络错误');
36 }).always(function() { 30 }).always(function() {
37 loading.hideLoadingMask(); 31 loading.hideLoadingMask();
@@ -10,7 +10,8 @@ var $ = require('jquery'), @@ -10,7 +10,8 @@ var $ = require('jquery'),
10 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
11 11
12 var dialog = require('../me/dialog'), 12 var dialog = require('../me/dialog'),
13 - tip = require('../plugin/tip'); 13 + tip = require('../plugin/tip'),
  14 + orderInfo = require('./order-info').orderInfo;
14 15
15 var $selectAllBtn = $('.balance .checkbox'), 16 var $selectAllBtn = $('.balance .checkbox'),
16 cartType = $('#cartType').val(), 17 cartType = $('#cartType').val(),
@@ -106,13 +107,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -106,13 +107,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
106 autoHide: true, 107 autoHide: true,
107 fast: true 108 fast: true
108 }); 109 });
  110 + orderInfo('couponCode', null);
  111 + orderInfo('couponValue', null);
109 history.go(0); 112 history.go(0);
  113 + } else {
  114 + tip.show(data.message);
110 } 115 }
111 }, function() { 116 }, function() {
112 - dialog.showDialog({  
113 - autoHide: true,  
114 - dialogText: '网络异常'  
115 - }); 117 + tip.show('网络异常');
116 }); 118 });
117 }); 119 });
118 120
@@ -224,5 +226,3 @@ $selectAllBtn.on('touchend', function() { @@ -224,5 +226,3 @@ $selectAllBtn.on('touchend', function() {
224 $('.down').on('touchend', function() { 226 $('.down').on('touchend', function() {
225 chosePanel.show(); 227 chosePanel.show();
226 }); 228 });
227 -  
228 -  
@@ -78,7 +78,7 @@ function orderCompute() { @@ -78,7 +78,7 @@ function orderCompute() {
78 method: 'POST', 78 method: 'POST',
79 url: '/cart/index/orderCompute', 79 url: '/cart/index/orderCompute',
80 data: { 80 data: {
81 - cartType: orderInfo('cartType'), 81 + cartType: queryString.cartType || queryString.carttype || 'ordinary',
82 deliveryId: orderInfo('deliveryId'), 82 deliveryId: orderInfo('deliveryId'),
83 paymentTypeId: orderInfo('paymentTypeId'), 83 paymentTypeId: orderInfo('paymentTypeId'),
84 couponCode: orderInfo('couponCode'), 84 couponCode: orderInfo('couponCode'),
@@ -89,6 +89,7 @@ function orderCompute() { @@ -89,6 +89,7 @@ function orderCompute() {
89 89
90 if (!res) { 90 if (!res) {
91 tip.show('网络出错'); 91 tip.show('网络出错');
  92 + window.location.reload();
92 } else { 93 } else {
93 /*if (res.order_amount) { 94 /*if (res.order_amount) {
94 res.order_amount = (+res.order_amount).toFixed(2); 95 res.order_amount = (+res.order_amount).toFixed(2);
@@ -108,6 +109,7 @@ function orderCompute() { @@ -108,6 +109,7 @@ function orderCompute() {
108 } 109 }
109 }).fail(function() { 110 }).fail(function() {
110 tip.show('网络出错'); 111 tip.show('网络出错');
  112 + window.location.reload();
111 }); 113 });
112 } 114 }
113 115
@@ -7,9 +7,20 @@ @@ -7,9 +7,20 @@
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 orderInfo = require('./order-info').orderInfo; 8 orderInfo = require('./order-info').orderInfo;
9 9
  10 +var $confim = $('.confim-mask'),
  11 + deleteId;
  12 +
10 $('.address-item').on('touchend', function() { 13 $('.address-item').on('touchend', function() {
11 orderInfo('addressId', $(this).data('address-id')); 14 orderInfo('addressId', $(this).data('address-id'));
12 }).on('touchend', '.edit', function() { 15 }).on('touchend', '.edit', function() {
13 window.location.href = $(this).data('href'); 16 window.location.href = $(this).data('href');
14 return false; 17 return false;
  18 +}).on('touchend', '.del', function() {
  19 + deleteId = $(this).data('address-id');
  20 +});
  21 +
  22 +$confim.on('touchend', '.confim', function() {
  23 + if (orderInfo('addressId') === deleteId) {
  24 + orderInfo('addressId', null);
  25 + }
15 }); 26 });
@@ -36,6 +36,37 @@ @@ -36,6 +36,37 @@
36 li:first-child span { 36 li:first-child span {
37 border-right: 1px solid #e0e0e0; 37 border-right: 1px solid #e0e0e0;
38 } 38 }
  39 +
  40 + li:last-child {
  41 + position: relative;
  42 + }
  43 +
  44 + .presell-tip {
  45 + position: absolute;
  46 + z-index: 1;
  47 + left: -2rem;
  48 + top: 1.75rem;
  49 + }
  50 +
  51 + .triangle {
  52 + width: 0;
  53 + height: 0;
  54 + border-left: 8px solid transparent;
  55 + border-right: 8px solid transparent;
  56 + border-bottom: 12px solid #000;
  57 + margin-left: 6rem;
  58 + }
  59 +
  60 + .pt-content {
  61 + position: relative;
  62 + padding: 10px;
  63 + background: #000;
  64 + color: #fff;
  65 + font-size: 20px;
  66 + @include border-radius(5px);
  67 + text-align: center;
  68 + width: 7rem;
  69 + }
39 } 70 }
40 71
41 .login-info { 72 .login-info {
@@ -195,8 +226,6 @@ @@ -195,8 +226,6 @@
195 } 226 }
196 } 227 }
197 228
198 -}  
199 -.shopping-cart-zero{  
200 .cart-zero{ 229 .cart-zero{
201 width: 100%; 230 width: 100%;
202 height: auto; 231 height: auto;
1 {{> layout/header}} 1 {{> layout/header}}
2 - {{# shoppingCart}}  
3 - {{#if isEmptyCart}}  
4 - <div class="shopping-cart-zero yoho-page">  
5 - <div class="cart-zero">  
6 - <i class="iconfont">&#xe62c</i>  
7 - <p>您的购物车暂无商品</p>  
8 - <a href="/product/new">随便逛逛</a>  
9 - </div>  
10 - {{> product/recommend-for-you}}  
11 - </div>  
12 - {{^}}  
13 - <div id="mainCart" class="shopping-cart-page yoho-page">  
14 -  
15 -  
16 -  
17 - {{#if showLoginInfo}} 2 +<div id="mainCart" class="shopping-cart-page yoho-page">
  3 + {{# shoppingCart}}
  4 + {{#if showLoginInfo}}
18 <p class="login-info"> 5 <p class="login-info">
19 <span class="iconfont">&#xe628;</span> 6 <span class="iconfont">&#xe628;</span>
20 请您先 7 请您先
21 <a class="btn btn-login" href="{{signurl}}">登录</a> 8 <a class="btn btn-login" href="{{signurl}}">登录</a>
22 可以同步电脑和手机中的商品 9 可以同步电脑和手机中的商品
23 </p> 10 </p>
24 - {{^}}  
25 - {{#if cartNav}} 11 + {{/if}}
  12 + {{#if isEmptyCart}}
  13 + <div class="cart-zero">
  14 + <i class="iconfont">&#xe62c</i>
  15 + <p>您的购物车暂无商品</p>
  16 + <a href="/product/new">随便逛逛</a>
  17 + </div>
  18 + {{> product/recommend-for-you}}
  19 + {{^}}
  20 + {{#if cartNav}}
26 <ul class="cart-nav clearfix"> 21 <ul class="cart-nav clearfix">
27 <li class="active"> 22 <li class="active">
28 <span> 23 <span>
@@ -33,33 +28,33 @@ @@ -33,33 +28,33 @@
33 <span> 28 <span>
34 预售商品({{presellGoodsCount}}) 29 预售商品({{presellGoodsCount}})
35 </span> 30 </span>
  31 + <div id="presell-tip" class="presell-tip">
  32 + <div class="triangle"></div>
  33 + <p class="pt-content">预售商品点这里结算哦~</p>
  34 + </div>
36 </li> 35 </li>
37 </ul> 36 </ul>
38 - {{/if}}  
39 {{/if}} 37 {{/if}}
40 38
41 {{# commonCart}} 39 {{# commonCart}}
42 - <div class="cart-content common">  
43 - {{> cart/cart-content}}  
44 - </div> 40 + <div class="cart-content common">
  41 + {{> cart/cart-content}}
  42 + </div>
45 {{/ commonCart}} 43 {{/ commonCart}}
46 44
47 {{# preSellCart}} 45 {{# preSellCart}}
48 - <div class="cart-content presell hide">  
49 - <p class="presell-info">  
50 - <span class="iconfont">&#xe61a;</span>  
51 - <span class="txt">预售商品全场包邮,到货后立即发货</span>  
52 - <span class="txt">预售商品不参加活动,不可使用优惠券</span>  
53 - </p>  
54 - {{> cart/cart-content}}  
55 - </div> 46 + <div class="cart-content presell hide">
  47 + <p class="presell-info">
  48 + <span class="iconfont">&#xe61a;</span>
  49 + <span class="txt">预售商品全场包邮,到货后立即发货</span>
  50 + <span class="txt">预售商品不参加活动,不可使用优惠券</span>
  51 + </p>
  52 + {{> cart/cart-content}}
  53 + </div>
56 {{/ preSellCart}} 54 {{/ preSellCart}}
57 -  
58 - </div>  
59 {{/if}} 55 {{/if}}
60 56
61 <input id="cartType" type="hidden" value="{{cartType}}"> 57 <input id="cartType" type="hidden" value="{{cartType}}">
62 - {{/ shoppingCart}}  
63 -  
64 - {{> cart/chose-panel}} 58 + {{/ shoppingCart}}
  59 +</div>
65 {{> layout/footer}} 60 {{> layout/footer}}
@@ -65,11 +65,18 @@ @@ -65,11 +65,18 @@
65 </li> 65 </li>
66 <li class="coin" data-yoho-coin="{{yohoCoin}}"> 66 <li class="coin" data-yoho-coin="{{yohoCoin}}">
67 <span class="title">YOHO币</span> 67 <span class="title">YOHO币</span>
68 - <span class="desc">可抵¥{{yohoCoin}}</span>  
69 - <span class="coin-check">  
70 - <em>- ¥ {{yohoCoin}}</em>  
71 - <i class="iconfont checkbox icon-cb-checked"></i>  
72 - </span> 68 +
  69 + {{#if yohoCoin}}
  70 + <span class="desc">可抵¥{{yohoCoin}}</span>
  71 + <span class="coin-check">
  72 + <em>- ¥ {{yohoCoin}}</em>
  73 + <i class="iconfont checkbox icon-cb-checked"></i>
  74 + </span>
  75 + {{^}}
  76 + <span class="not-used coin-check">
  77 + 无YOHO币可用
  78 + </span>
  79 + {{/if}}
73 </li> 80 </li>
74 81
75 {{#if invoice}} 82 {{#if invoice}}
1 -<div class="shopping-cart-good clearfix" data-id={{id}}>  
2 - {{#if isSoldOut}} 1 +<div class="shopping-cart-good clearfix" data-id="{{id}}">
  2 + {{#if inValid}}
3 <span class="few-tag-expire">失效</span> 3 <span class="few-tag-expire">失效</span>
4 - {{^}}  
5 - {{#if isSelected}}  
6 - <span class="checkbox icon-cb-checked iconfont"></span>  
7 - {{^}}  
8 - <span class="checkbox icon-checkbox iconfont"></span>  
9 - {{/if}} 4 + {{/if}}
  5 +
  6 + {{#if showCheckbox}}
  7 + <span class="checkbox{{#if checked}} icon-cb-checked{{^}} icon-checkbox{{/if}}iconfont"></span>
10 {{/if}} 8 {{/if}}
11 9
12 <div class="info"> 10 <div class="info">
13 - <img class="thumb lazy" data-original={{thumb}}> 11 + <img class="thumb lazy" data-original="{{thumb}}">
14 {{#if isAdvanceBuy}} 12 {{#if isAdvanceBuy}}
15 <p class="few-tag plus-tag">加价购</p> 13 <p class="few-tag plus-tag">加价购</p>
16 - {{^}}  
17 - {{#if isGift}} 14 + {{/if}}
  15 + {{#if isGift}}
18 <p class="few-tag gift-tag">赠品</p> 16 <p class="few-tag gift-tag">赠品</p>
19 - {{/if}}  
20 {{/if}} 17 {{/if}}
21 - </a>  
22 18
23 <div class="deps show"> 19 <div class="deps show">
24 <p class="name row">{{name}}</p> 20 <p class="name row">{{name}}</p>
@@ -67,15 +63,5 @@ @@ -67,15 +63,5 @@
67 </p> 63 </p>
68 {{/if}} 64 {{/if}}
69 </div> 65 </div>
70 - <div class="calculate-num hide">  
71 - <div class="calculate">  
72 - <p><i class="iconfont cut">&#xe625;</i><span>{{count}}</span><i class="iconfont add">&#xe624;</i></p>  
73 - <p><span>颜色:{{color}}尺码:{{size}}{{name}}</span><i class="iconfont down">&#xe616;</i></p>  
74 - </div>  
75 - <p><span class="price"> ¥{{price}}</span></p>  
76 - <span class="count">  
77 - ×{{count}}  
78 - </span>  
79 - </div>  
80 </div> 66 </div>
81 </div> 67 </div>
@@ -186,7 +186,7 @@ class DetailModel @@ -186,7 +186,7 @@ class DetailModel
186 // 商品的尺码列表 186 // 商品的尺码列表
187 if (isset($value['goodsSizeBoList'])) { 187 if (isset($value['goodsSizeBoList'])) {
188 foreach ($value['goodsSizeBoList'] as $size) { 188 foreach ($value['goodsSizeBoList'] as $size) {
189 - $sizeList[$value['colorId']][] = array( 189 + $sizeList[$value['productSkc']][] = array(
190 'id' => $size['id'], 190 'id' => $size['id'],
191 'skuId' => $size['goodsSizeSkuId'], 191 'skuId' => $size['goodsSizeSkuId'],
192 'goodsId' => $size['goodsId'], 192 'goodsId' => $size['goodsId'],
@@ -196,7 +196,7 @@ class DetailModel @@ -196,7 +196,7 @@ class DetailModel
196 ); 196 );
197 $colorStorageNum += intval($size['goodsSizeStorageNum']); 197 $colorStorageNum += intval($size['goodsSizeStorageNum']);
198 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/'; 198 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
199 - $colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum']; 199 + $colorStorageGroup[$size['sizeName']][$value['productSkc']] = $size['goodsSizeStorageNum'];
200 } 200 }
201 201
202 // 颜色分组 202 // 颜色分组
@@ -214,9 +214,9 @@ class DetailModel @@ -214,9 +214,9 @@ class DetailModel
214 $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60)); 214 $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
215 215
216 // 添加尺码对应的各个颜色的库存量 216 // 添加尺码对应的各个颜色的库存量
217 - foreach ($sizeList as $colorId => $sizeArr) { 217 + foreach ($sizeList as $skc => $sizeArr) {
218 foreach ($sizeArr as $key => $value) { 218 foreach ($sizeArr as $key => $value) {
219 - $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']])); 219 + $sizeList[$skc][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
220 } 220 }
221 } 221 }
222 222
@@ -226,7 +226,7 @@ class DetailModel @@ -226,7 +226,7 @@ class DetailModel
226 226
227 // 格式化尺码对应的各个颜色分组 227 // 格式化尺码对应的各个颜色分组
228 foreach ($colorGroup as $value) { 228 foreach ($colorGroup as $value) {
229 - $sizeGroup[]['size'] = $sizeList[ $value['id'] ]; 229 + $sizeGroup[]['size'] = $sizeList[ $value['skcId'] ];
230 } 230 }
231 231
232 // 商品图: 多个 232 // 商品图: 多个
@@ -215,7 +215,9 @@ class IndexController extends AbstractAction @@ -215,7 +215,9 @@ class IndexController extends AbstractAction
215 $result = CartModel::giftProductData($skn, $promotionId); 215 $result = CartModel::giftProductData($skn, $promotionId);
216 } 216 }
217 217
218 - $this->_view->display('gift-info', $result); 218 + $this->_view->display('gift-info', array(
  219 + 'cartInfo' => $result['data']
  220 + ));
219 } 221 }
220 222
221 /** 223 /**
@@ -269,7 +271,7 @@ class IndexController extends AbstractAction @@ -269,7 +271,7 @@ class IndexController extends AbstractAction
269 $this->auditJumpLogin(); 271 $this->auditJumpLogin();
270 272
271 $this->setTitle('确认订单'); 273 $this->setTitle('确认订单');
272 - $this->setNavHeader('确认订单'); 274 + $this->setNavHeader('确认订单', true, false); // 不显示右上角home按钮
273 275
274 // 购物车商品为空跳转到购物车页面 276 // 购物车商品为空跳转到购物车页面
275 $shoppingKey = Helpers::getShoppingKeyByCookie(); 277 $shoppingKey = Helpers::getShoppingKeyByCookie();