Authored by jinhu.tung

good is not enought

@@ -273,6 +273,7 @@ const modifyProductNum = (options) => { @@ -273,6 +273,7 @@ const modifyProductNum = (options) => {
273 const uid = options.uid; 273 const uid = options.uid;
274 const shoppingKey = options.shoppingKey; 274 const shoppingKey = options.shoppingKey;
275 const sku = options.sku; 275 const sku = options.sku;
  276 + const goodType = options.goodType;
276 277
277 let params = { 278 let params = {
278 product_sku: options.sku 279 product_sku: options.sku
@@ -304,14 +305,22 @@ const modifyProductNum = (options) => { @@ -304,14 +305,22 @@ const modifyProductNum = (options) => {
304 }); 305 });
305 } 306 }
306 307
307 - if (sku) {  
308 - _.merge(params, {  
309 - product_sku: sku  
310 - });  
311 - } 308 + _.merge(params, {
  309 + product_sku: sku
  310 + });
  311 +
  312 + return getCartData(shoppingKey, uid).then(function(result) {
  313 + console.log('getCartData--pre-callback-result:', result);
  314 + console.log('modifyProductNum---params:', params);
  315 + if(goodType === 'advance') {
  316 + // 检查库存量
  317 + } else if(goodType === 'ordinary') {
  318 + // 检查库存量
  319 + }
  320 + return api.get('', params);
  321 + });
  322 +
312 323
313 - console.log('modifyProductNum---params:', params);  
314 - return api.get('', params);  
315 }; 324 };
316 325
317 module.exports = { 326 module.exports = {
@@ -15,7 +15,6 @@ const order = require(`${cRoot}/order`); // 下单 @@ -15,7 +15,6 @@ const order = require(`${cRoot}/order`); // 下单
15 15
16 // 购物车 16 // 购物车
17 router.get('/cart', cartCtrl.index); 17 router.get('/cart', cartCtrl.index);
18 -router.get('/cart/product/check_inventory', cartCtrl.checkInventory);  
19 router.post('/cart/product/change_num', cartCtrl.changeProductNum); 18 router.post('/cart/product/change_num', cartCtrl.changeProductNum);
20 router.delete('/cart/product/remove', cartCtrl.removeProduct); 19 router.delete('/cart/product/remove', cartCtrl.removeProduct);
21 router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite); 20 router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite);
@@ -7,8 +7,7 @@ @@ -7,8 +7,7 @@
7 {{^}} 7 {{^}}
8 {{> cart/empty-cart}} 8 {{> cart/empty-cart}}
9 {{/if}} 9 {{/if}}
10 -{{!-- <button id="add_to_cart1">添加到购物车 980874 number 1</button>  
11 - <button id="add_to_cart2">添加到购物车 980870 number 2</button> --}} 10 + {{!-- <button id="add_to_cart1">添加到购物车 1413600 number 1</button> --}}
12 </div> 11 </div>
13 </div> 12 </div>
14 <script id="edit-color-size-tpl" type="text/html"> 13 <script id="edit-color-size-tpl" type="text/html">
1 -<div class="stepper" data-productId={{productId}}> 1 +<div class="stepper" data-productType={{goods_type}}>
2 <div class="minus action"> 2 <div class="minus action">
3 <span class="iconfont">&#xe621;</span> 3 <span class="iconfont">&#xe621;</span>
4 </div> 4 </div>
@@ -86,7 +86,7 @@ $(function() { @@ -86,7 +86,7 @@ $(function() {
86 // TODO=> 86 // TODO=>
87 // $('#add_to_cart1').on('click', function() { 87 // $('#add_to_cart1').on('click', function() {
88 // Cart.addToCart({ 88 // Cart.addToCart({
89 - // productSku: '870896', 89 + // productSku: '1413600',
90 // buyNumber: 1 90 // buyNumber: 1
91 // }); 91 // });
92 // }); 92 // });
@@ -10,7 +10,7 @@ var $ = require('yoho-jquery'); @@ -10,7 +10,7 @@ var $ = require('yoho-jquery');
10 10
11 var Stepper = { 11 var Stepper = {
12 // 减少商品数量 12 // 减少商品数量
13 - decrease: function(sku, currNum) { 13 + decrease: function(goodType, sku, currNum) {
14 if (parseInt(currNum, 10) <= 1) { 14 if (parseInt(currNum, 10) <= 1) {
15 // return callback(1); 15 // return callback(1);
16 } else { 16 } else {
@@ -19,7 +19,8 @@ var Stepper = { @@ -19,7 +19,8 @@ var Stepper = {
19 type: 'POST', 19 type: 'POST',
20 data: { 20 data: {
21 changeType: 'DECREASE', 21 changeType: 'DECREASE',
22 - sku: sku 22 + sku: sku,
  23 + goodType: goodType
23 24
24 // changeTo: parseInt(currNum, 10) - 1 25 // changeTo: parseInt(currNum, 10) - 1
25 }, 26 },
@@ -34,13 +35,14 @@ var Stepper = { @@ -34,13 +35,14 @@ var Stepper = {
34 }, 35 },
35 36
36 // 增加商品数量 37 // 增加商品数量
37 - increase: function(sku) { 38 + increase: function(goodType, sku) {
38 Util.ajax({ 39 Util.ajax({
39 url: '/shopping/cart/product/change_num', 40 url: '/shopping/cart/product/change_num',
40 type: 'POST', 41 type: 'POST',
41 data: { 42 data: {
42 changeType: 'INCREASE', 43 changeType: 'INCREASE',
43 - sku: sku 44 + sku: sku,
  45 + goodType: goodType
44 46
45 // changeTo: parseInt(currNum, 10) + 1 47 // changeTo: parseInt(currNum, 10) + 1
46 }, 48 },
@@ -60,7 +62,8 @@ var Stepper = { @@ -60,7 +62,8 @@ var Stepper = {
60 init: function() { 62 init: function() {
61 var _this = this, 63 var _this = this,
62 $target, 64 $target,
63 - sku; 65 + sku,
  66 + goodType;
64 67
65 var steppers = $('.stepper'), 68 var steppers = $('.stepper'),
66 $input, 69 $input,
@@ -85,7 +88,8 @@ var Stepper = { @@ -85,7 +88,8 @@ var Stepper = {
85 88
86 if (!$target.hasClass('disable')) { 89 if (!$target.hasClass('disable')) {
87 sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku; 90 sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku;
88 - _this.decrease(sku, currNum, function(num, changed) { 91 + goodType = $target.parent().attr('data-producttype');
  92 + _this.decrease(goodType, sku, currNum, function(num, changed) {
89 if (num === 1) { 93 if (num === 1) {
90 $input.val(1); 94 $input.val(1);
91 $target.addClass('disable'); 95 $target.addClass('disable');
@@ -111,7 +115,8 @@ var Stepper = { @@ -111,7 +115,8 @@ var Stepper = {
111 115
112 if (!$target.hasClass('disable')) { 116 if (!$target.hasClass('disable')) {
113 sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku; 117 sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku;
114 - _this.increase(sku, currNum, function(num, changed, overflow) { 118 + goodType = $target.parent().attr('data-producttype');
  119 + _this.increase(goodType, sku, currNum, function(num, changed, overflow) {
115 if (overflow) { 120 if (overflow) {
116 $target.addClass('disable'); 121 $target.addClass('disable');
117 } 122 }