Authored by jinhu.tung

good is not enought

... ... @@ -273,6 +273,7 @@ const modifyProductNum = (options) => {
const uid = options.uid;
const shoppingKey = options.shoppingKey;
const sku = options.sku;
const goodType = options.goodType;
let params = {
product_sku: options.sku
... ... @@ -304,14 +305,22 @@ const modifyProductNum = (options) => {
});
}
if (sku) {
_.merge(params, {
product_sku: sku
});
}
return getCartData(shoppingKey, uid).then(function(result) {
console.log('getCartData--pre-callback-result:', result);
console.log('modifyProductNum---params:', params);
if(goodType === 'advance') {
// 检查库存量
} else if(goodType === 'ordinary') {
// 检查库存量
}
return api.get('', params);
});
};
module.exports = {
... ...
... ... @@ -15,7 +15,6 @@ const order = require(`${cRoot}/order`); // 下单
// 购物车
router.get('/cart', cartCtrl.index);
router.get('/cart/product/check_inventory', cartCtrl.checkInventory);
router.post('/cart/product/change_num', cartCtrl.changeProductNum);
router.delete('/cart/product/remove', cartCtrl.removeProduct);
router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite);
... ...
... ... @@ -7,8 +7,7 @@
{{^}}
{{> cart/empty-cart}}
{{/if}}
{{!-- <button id="add_to_cart1">添加到购物车 980874 number 1</button>
<button id="add_to_cart2">添加到购物车 980870 number 2</button> --}}
{{!-- <button id="add_to_cart1">添加到购物车 1413600 number 1</button> --}}
</div>
</div>
<script id="edit-color-size-tpl" type="text/html">
... ...
<div class="stepper" data-productId={{productId}}>
<div class="stepper" data-productType={{goods_type}}>
<div class="minus action">
<span class="iconfont">&#xe621;</span>
</div>
... ...
... ... @@ -86,7 +86,7 @@ $(function() {
// TODO=>
// $('#add_to_cart1').on('click', function() {
// Cart.addToCart({
// productSku: '870896',
// productSku: '1413600',
// buyNumber: 1
// });
// });
... ...
... ... @@ -10,7 +10,7 @@ var $ = require('yoho-jquery');
var Stepper = {
// 减少商品数量
decrease: function(sku, currNum) {
decrease: function(goodType, sku, currNum) {
if (parseInt(currNum, 10) <= 1) {
// return callback(1);
} else {
... ... @@ -19,7 +19,8 @@ var Stepper = {
type: 'POST',
data: {
changeType: 'DECREASE',
sku: sku
sku: sku,
goodType: goodType
// changeTo: parseInt(currNum, 10) - 1
},
... ... @@ -34,13 +35,14 @@ var Stepper = {
},
// 增加商品数量
increase: function(sku) {
increase: function(goodType, sku) {
Util.ajax({
url: '/shopping/cart/product/change_num',
type: 'POST',
data: {
changeType: 'INCREASE',
sku: sku
sku: sku,
goodType: goodType
// changeTo: parseInt(currNum, 10) + 1
},
... ... @@ -60,7 +62,8 @@ var Stepper = {
init: function() {
var _this = this,
$target,
sku;
sku,
goodType;
var steppers = $('.stepper'),
$input,
... ... @@ -85,7 +88,8 @@ var Stepper = {
if (!$target.hasClass('disable')) {
sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku;
_this.decrease(sku, currNum, function(num, changed) {
goodType = $target.parent().attr('data-producttype');
_this.decrease(goodType, sku, currNum, function(num, changed) {
if (num === 1) {
$input.val(1);
$target.addClass('disable');
... ... @@ -111,7 +115,8 @@ var Stepper = {
if (!$target.hasClass('disable')) {
sku = $.parseJSON($target.parents('ul').children().first().attr('data-product_info')).product_sku;
_this.increase(sku, currNum, function(num, changed, overflow) {
goodType = $target.parent().attr('data-producttype');
_this.increase(goodType, sku, currNum, function(num, changed, overflow) {
if (overflow) {
$target.addClass('disable');
}
... ...