Toggle navigation
Toggle navigation
This project
Loading...
Sign in
chenchao
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
269896b9aa33babe92926fbb62156df9bf278518
1 parent
2c88d62d
购物车尺码颜色选择
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
static/js/cart/chose-panel.js
static/js/cart/chose-panel.js
View file @
269896b
...
...
@@ -21,13 +21,13 @@ var panelTmpl,
re
=
/
\d
+/
,
leftNum
,
$sizeList
,
colorIndex
,
confirming
,
hasChooseColor
=
false
,
hasChooseSize
=
false
,
curColorIndex
,
curSizeIndex
,
$curSizeRow
,
$curSizeBlock
=
null
,
$sizeRowList
=
$
(
'.size-list ul'
);
// 读取模板
...
...
@@ -102,7 +102,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
curSelectedSizeBlock
,
$sizeChosed
,
scindex
,
i
;
curGoodNum
;
var
$siblingBlock
=
$this
.
closest
(
'.block-list'
).
siblings
(
':first'
);
...
...
@@ -141,11 +141,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
curSelectedSizeBlock
=
$curSizeRow
.
children
().
get
(
scindex
);
if
(
curSelectedSizeBlock
)
{
var
curGoodNum
=
$
(
curSelectedSizeBlock
).
data
(
'num'
);
curGoodNum
=
$
(
curSelectedSizeBlock
).
data
(
'num'
);
$
(
curSelectedSizeBlock
).
addClass
(
'chosed'
);
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if
(
curGoodNum
>
0
)
{
if
(
curGoodNum
>
0
)
{
$that
.
find
(
'.num .left-num'
).
html
(
'剩余'
+
curGoodNum
+
'件'
);
}
else
{
$
(
curSelectedSizeBlock
).
removeClass
(
'zero-stock'
).
addClass
(
'zero-stock'
);
...
...
@@ -234,12 +234,10 @@ $('.color-list').on('touchstart', '.block', function(e) {
$
(
'.size-list'
).
on
(
'touchstart'
,
'.block'
,
function
(
e
)
{
var
$this
=
$
(
this
),
$that
=
$
(
e
.
target
).
closest
(
'.chose-items'
),
numArray
,
index
,
curSelectedSizeBlock
,
$colorChosed
,
selectedColorindex
,
i
;
curGoodNum
;
var
$siblingBlock
=
$this
.
closest
(
'.block-list'
).
siblings
(
':first'
);
...
...
@@ -266,15 +264,15 @@ $('.size-list').on('touchstart', '.block', function(e) {
}
else
{
hasChooseSize
=
true
;
var
curGoodNum
=
$this
.
data
(
'num'
);
curGoodNum
=
$this
.
data
(
'num'
);
// 之前选中的尺码去掉勾选样式
if
(
preSelectedSizeBlock
)
{
$
(
preSelectedSizeBlock
).
removeClass
(
'chosed'
);
if
(
$curSizeBlock
)
{
$curSizeBlock
.
removeClass
(
'chosed'
);
}
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
if
(
curGoodNum
>
0
)
{
if
(
curGoodNum
>
0
)
{
$that
.
find
(
'.num .left-num'
).
html
(
'剩余'
+
curGoodNum
+
'件'
);
}
else
{
$colorChosed
.
removeClass
(
'zero-stock'
).
addClass
(
'zero-stock'
);
...
...
@@ -284,6 +282,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
$this
.
toggleClass
(
'chosed'
);
curSizeIndex
=
index
;
$curSizeBlock
=
$this
;
// 设置按钮的样式和文字
$chosed
=
$
(
'.chose-items'
).
find
(
'.chosed'
);
...
...
Please
register
or
login
to post a comment