Authored by Lynnic

购物车逻辑修改

@@ -14,7 +14,20 @@ var $ = require('jquery'); @@ -14,7 +14,20 @@ var $ = require('jquery');
14 var $num, 14 var $num,
15 $chosed, 15 $chosed,
16 re = /\d+/, 16 re = /\d+/,
17 - leftNum; 17 + leftNum,
  18 + $colorList = $('.color-list ul>li'),
  19 + $sizeList = $('.size-list ul>li'),
  20 + firstColorId = $colorList.eq(0).data('id');
  21 +
  22 +//初始化购物车面板显示
  23 +$sizeList.each(function() {
  24 + var id = $(this).data('colorid');
  25 +
  26 +
  27 + if (id === firstColorId) {
  28 + $(this).removeClass('hide');
  29 + }
  30 +});
18 31
19 // confirm; 32 // confirm;
20 33
@@ -39,6 +52,8 @@ var $num, @@ -39,6 +52,8 @@ var $num,
39 // $num = $('#good-num'); 52 // $num = $('#good-num');
40 // } 53 // }
41 54
  55 +
  56 +
42 function show() { 57 function show() {
43 $('.chose-panel').show(); 58 $('.chose-panel').show();
44 59
@@ -63,12 +78,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -63,12 +78,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
63 remove(); 78 remove();
64 }).on('touchstart', '#chose-btn-sure', function() { 79 }).on('touchstart', '#chose-btn-sure', function() {
65 80
66 - // var  
67 - // // goodId,  
68 - // // skuId,  
69 - // skcId = $('.color-list li.chosed').data('skcid'),  
70 - // colorIndex = $('.color-list li.chosed').index(),  
71 - // skuArray = $('.size-list').data('skustr').split('/'); 81 + // var productSku,
  82 + // buyNumber = $('#good-num') - 0;
  83 + // promotionId,
  84 + // goodsType,
  85 + // isEdit;
72 86
73 // //确定 87 // //确定
74 // $chosed = $('.block-list>ul>li.chosed'); 88 // $chosed = $('.block-list>ul>li.chosed');
@@ -83,7 +97,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -83,7 +97,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
83 // loading.showLoadingMask(); 97 // loading.showLoadingMask();
84 // $.ajax({ 98 // $.ajax({
85 // method: 'POST', 99 // method: 'POST',
86 - // url: '/product/detail/xxxx', 100 + // url: '/cart/index/add',
87 // data: { 101 // data: {
88 // product_id: productId, 102 // product_id: productId,
89 // content: content 103 // content: content
@@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
8 right: 0; 8 right: 0;
9 background: rgba(0,0,0,.3); 9 background: rgba(0,0,0,.3);
10 z-index:3; 10 z-index:3;
11 - 11 +
  12 +
12 .main { 13 .main {
13 position: absolute; 14 position: absolute;
14 height: pxToRem(610px); 15 height: pxToRem(610px);
@@ -85,6 +86,10 @@ @@ -85,6 +86,10 @@
85 top: 20rem / $pxConvertRem; 86 top: 20rem / $pxConvertRem;
86 } 87 }
87 } 88 }
  89 +
  90 + .size-list li.hide {
  91 + display: none;
  92 + }
88 93
89 .block { 94 .block {
90 float: left; 95 float: left;
1 - 1 +{{#cartInfo}}
2 <div class="chose-panel"> 2 <div class="chose-panel">
3 <div class="main"> 3 <div class="main">
4 <div class="infos"> 4 <div class="infos">
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 36
37 <ul class="clearfix" data-type="size" > 37 <ul class="clearfix" data-type="size" >
38 {{# sizes}} 38 {{# sizes}}
39 - <li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}"> 39 + <li class="block hide {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
40 {{name}} 40 {{name}}
41 </li> 41 </li>
42 {{/ sizes}} 42 {{/ sizes}}
@@ -62,3 +62,4 @@ @@ -62,3 +62,4 @@
62 </div> 62 </div>
63 </div> 63 </div>
64 </div> 64 </div>
  65 +{{/cartInfo}}