|
@@ -12,7 +12,11 @@ var $ = require('jquery'); |
|
@@ -12,7 +12,11 @@ var $ = require('jquery'); |
12
|
// var $page = $('.yoho-page');
|
12
|
// var $page = $('.yoho-page');
|
13
|
|
13
|
|
14
|
var $num,
|
14
|
var $num,
|
15
|
- $chosed;
|
15
|
+ $chosed,
|
|
|
16
|
+ re = /\d+/,
|
|
|
17
|
+ leftNum;
|
|
|
18
|
+
|
|
|
19
|
+// confirm;
|
16
|
|
20
|
|
17
|
// var tpl;
|
21
|
// var tpl;
|
18
|
|
22
|
|
|
@@ -37,6 +41,7 @@ var $num, |
|
@@ -37,6 +41,7 @@ var $num, |
37
|
|
41
|
|
38
|
function show() {
|
42
|
function show() {
|
39
|
$('.chose-panel').show();
|
43
|
$('.chose-panel').show();
|
|
|
44
|
+
|
40
|
$('body').css('overflow', 'hidden');
|
45
|
$('body').css('overflow', 'hidden');
|
41
|
$num = $('#good-num');
|
46
|
$num = $('#good-num');
|
42
|
}
|
47
|
}
|
|
@@ -58,10 +63,44 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
@@ -58,10 +63,44 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
58
|
remove();
|
63
|
remove();
|
59
|
}).on('touchstart', '#chose-btn-sure', function() {
|
64
|
}).on('touchstart', '#chose-btn-sure', function() {
|
60
|
|
65
|
|
61
|
- //确定
|
|
|
62
|
-}).on('touchstart', '.block', function(e) {
|
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('/');
|
|
|
72
|
+
|
|
|
73
|
+ // //确定
|
|
|
74
|
+ // $chosed = $('.block-list>ul>li.chosed');
|
|
|
75
|
+
|
|
|
76
|
+ // if (2 === $chosed.length && 2 !== $chosed.closest('.zero-stock').length) {
|
|
|
77
|
+
|
|
|
78
|
+ // if (confirm) {
|
|
|
79
|
+ // return false;
|
|
|
80
|
+ // }
|
|
|
81
|
+
|
|
|
82
|
+ // confirm = true;
|
|
|
83
|
+ // loading.showLoadingMask();
|
|
|
84
|
+ // $.ajax({
|
|
|
85
|
+ // method: 'POST',
|
|
|
86
|
+ // url: '/product/detail/xxxx',
|
|
|
87
|
+ // data: {
|
|
|
88
|
+ // product_id: productId,
|
|
|
89
|
+ // content: content
|
|
|
90
|
+ // }
|
|
|
91
|
+ // }).done(function(res) {
|
|
|
92
|
+ // if (res.code === 200) {
|
|
|
93
|
+ // loading.hideLoadingMask();
|
|
|
94
|
+ // confirm = false;
|
|
|
95
|
+ // remove();
|
|
|
96
|
+ // }
|
|
|
97
|
+ // }).fail(function() {
|
|
|
98
|
+ // tip.show('网络出了点问题~');
|
|
|
99
|
+ // confirm = false;
|
|
|
100
|
+ // });
|
|
|
101
|
+ // }
|
63
|
|
102
|
|
64
|
- //尺寸颜色点选
|
103
|
+}).on('touchstart', '.block', function(e) {
|
65
|
var $this = $(this),
|
104
|
var $this = $(this),
|
66
|
$that = $(e.target).closest('.chose-items'),
|
105
|
$that = $(e.target).closest('.chose-items'),
|
67
|
numArray,
|
106
|
numArray,
|
|
@@ -104,6 +143,9 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
@@ -104,6 +143,9 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
104
|
}
|
143
|
}
|
105
|
}
|
144
|
}
|
106
|
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
|
145
|
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
|
|
|
146
|
+ $('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
147
|
+ $('#chose-btn-sure').html('确定');
|
|
|
148
|
+
|
107
|
$siblingBlock.find('ul>li').each(function() {
|
149
|
$siblingBlock.find('ul>li').each(function() {
|
108
|
$(this).removeClass('zero-stock');
|
150
|
$(this).removeClass('zero-stock');
|
109
|
if (0 === $(this).data('num') - 0) {
|
151
|
if (0 === $(this).data('num') - 0) {
|
|
@@ -123,19 +165,23 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
@@ -123,19 +165,23 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
123
|
if (2 === $chosed.closest('.zero-stock').length) {
|
165
|
if (2 === $chosed.closest('.zero-stock').length) {
|
124
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
166
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
125
|
$('#chose-btn-sure').html('已售罄');
|
167
|
$('#chose-btn-sure').html('已售罄');
|
|
|
168
|
+ } else {
|
|
|
169
|
+ $('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
170
|
+ $('#chose-btn-sure').html('确定');
|
126
|
}
|
171
|
}
|
127
|
}
|
172
|
}
|
128
|
|
173
|
|
129
|
}).on('touchstart', '.btn-minus', function() {
|
174
|
}).on('touchstart', '.btn-minus', function() {
|
130
|
var num = +$num.val(),
|
175
|
var num = +$num.val(),
|
131
|
- $chosed = $('.block-list>ul>li.chosed');
|
176
|
+ $chosed = $('.block-list>ul>li.chosed'),
|
|
|
177
|
+ leftNum = re.exec($('.num .left-num').html());
|
132
|
|
178
|
|
133
|
//若颜色和尺码没有被同时选中,则不能点击
|
179
|
//若颜色和尺码没有被同时选中,则不能点击
|
134
|
if ($chosed.length < 2) {
|
180
|
if ($chosed.length < 2) {
|
135
|
return;
|
181
|
return;
|
136
|
}
|
182
|
}
|
137
|
|
183
|
|
138
|
- if (num === 0) {
|
184
|
+ if (num === 1 || 0 === leftNum - 0) {
|
139
|
return;
|
185
|
return;
|
140
|
}
|
186
|
}
|
141
|
|
187
|
|
|
@@ -147,6 +193,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
@@ -147,6 +193,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
147
|
if ($('.block-list>ul>li.chosed').length < 2) {
|
193
|
if ($('.block-list>ul>li.chosed').length < 2) {
|
148
|
return;
|
194
|
return;
|
149
|
}
|
195
|
}
|
|
|
196
|
+ leftNum = re.exec($('.num .left-num').html());
|
|
|
197
|
+ if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
|
|
|
198
|
+ return;
|
|
|
199
|
+ }
|
150
|
|
200
|
|
151
|
//TODO:库存数验证
|
201
|
//TODO:库存数验证
|
152
|
$num.val(num + 1);
|
202
|
$num.val(num + 1);
|