...
|
...
|
@@ -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');
|
|
|
}
|
...
|
...
|
|