Merge branch 'feature/cart' of http://git.dev.yoho.cn/web/yohobuy into feature/cart
Showing
1 changed file
with
21 additions
and
14 deletions
@@ -20,7 +20,8 @@ var $num, | @@ -20,7 +20,8 @@ var $num, | ||
20 | $colorList = $('.color-list ul>li'), | 20 | $colorList = $('.color-list ul>li'), |
21 | $sizeList = $('.size-list ul>li'), | 21 | $sizeList = $('.size-list ul>li'), |
22 | firstColorId = $colorList.eq(0).data('id'), | 22 | firstColorId = $colorList.eq(0).data('id'), |
23 | - colorIndex; | 23 | + colorIndex, |
24 | + confirming; | ||
24 | 25 | ||
25 | //初始化购物车面板显示 | 26 | //初始化购物车面板显示 |
26 | $sizeList.each(function() { | 27 | $sizeList.each(function() { |
@@ -31,7 +32,7 @@ $sizeList.each(function() { | @@ -31,7 +32,7 @@ $sizeList.each(function() { | ||
31 | } | 32 | } |
32 | }); | 33 | }); |
33 | 34 | ||
34 | -// confirm; | 35 | + |
35 | 36 | ||
36 | // var tpl; | 37 | // var tpl; |
37 | 38 | ||
@@ -81,41 +82,47 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | @@ -81,41 +82,47 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | ||
81 | }).on('touchstart', '#chose-btn-sure', function() { | 82 | }).on('touchstart', '#chose-btn-sure', function() { |
82 | 83 | ||
83 | var productSku, | 84 | var productSku, |
84 | - buyNumber = $('#good-num') - 0; | 85 | + buyNumber = $('#good-num').val() - 0, |
86 | + | ||
87 | + promotionId, | ||
88 | + isEdit = 0, | ||
89 | + numInCart = $('.num-tag').html() - 0; | ||
85 | 90 | ||
86 | - // promotionId, | ||
87 | - // goodsType, | 91 | + // goodsType, |
88 | // isEdit; | 92 | // isEdit; |
89 | 93 | ||
90 | $chosed = $('.block-list>ul>li.chosed'); | 94 | $chosed = $('.block-list>ul>li.chosed'); |
91 | 95 | ||
92 | if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { | 96 | if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { |
93 | productSku = $sizeList.closest('.chosed').data('skuid'); | 97 | productSku = $sizeList.closest('.chosed').data('skuid'); |
98 | + promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id'); | ||
99 | + if (confirming) { | ||
100 | + return false; | ||
101 | + } | ||
94 | 102 | ||
95 | - // if (confirm) { | ||
96 | - // return false; | ||
97 | - // } | ||
98 | - | ||
99 | - // confirm = true; | 103 | + confirming = true; |
100 | loading.showLoadingMask(); | 104 | loading.showLoadingMask(); |
101 | $.ajax({ | 105 | $.ajax({ |
102 | method: 'POST', | 106 | method: 'POST', |
103 | url: '/cart/index/add', | 107 | url: '/cart/index/add', |
104 | data: { | 108 | data: { |
105 | productSku: productSku, | 109 | productSku: productSku, |
106 | - buyNumber: buyNumber | 110 | + buyNumber: buyNumber, |
111 | + promotionId: promotionId, | ||
112 | + isEdit: isEdit | ||
107 | } | 113 | } |
108 | }).done(function(res) { | 114 | }).done(function(res) { |
109 | if (res.code === 200) { | 115 | if (res.code === 200) { |
110 | loading.hideLoadingMask(); | 116 | loading.hideLoadingMask(); |
111 | - | ||
112 | - // confirm = false; | 117 | + $('.num-tag').html(numInCart + buyNumber); |
118 | + $('.num-tag').removeClass('hide'); | ||
119 | + confirming = false; | ||
113 | remove(); | 120 | remove(); |
114 | } | 121 | } |
115 | }).fail(function() { | 122 | }).fail(function() { |
116 | tip.show('网络出了点问题~'); | 123 | tip.show('网络出了点问题~'); |
117 | 124 | ||
118 | - // confirm = false; | 125 | + confirming = false; |
119 | }); | 126 | }); |
120 | } | 127 | } |
121 | 128 |
-
Please register or login to post a comment