Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
d2cdc30badb2a52e694f38d8ee337229b62fe581
2 parents
d94db176
ec0164e9
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into test
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
17 deletions
static/js/cart/chose-panel.js
static/js/cart/chose-panel.js
View file @
d2cdc30
...
...
@@ -22,7 +22,6 @@ var $chosePanel = $('#chose-panel'),
confirming
,
curColorIndex
,
curSizeIndex
,
$curSizeRow
,
hasChooseColor
,
hasChooseSize
,
$curSizeBlock
,
...
...
@@ -34,8 +33,6 @@ var $chosePanel = $('#chose-panel'),
//初始化购物车面板显示
function
init
()
{
var
$firstRow
;
hasChooseColor
=
false
;
hasChooseSize
=
false
;
$curSizeBlock
=
null
;
...
...
@@ -44,9 +41,7 @@ function init() {
$allChoseItems
=
$
(
'.chose-items'
);
$sizeRowList
=
$
(
'.size-list ul'
);
$leftNum
=
$
(
'#left-num'
);
$firstRow
=
$sizeRowList
.
eq
(
0
);
$firstRow
.
toggleClass
(
'hide'
);
$curSizeRow
=
$firstRow
;
$sizeRowList
.
eq
(
0
).
toggleClass
(
'hide'
);
}
function
checkColorSizeNum
()
{
...
...
@@ -69,6 +64,7 @@ function show(html, cb) {
init
();
}
$
(
'.chose-panel'
).
show
();
$
(
'body'
).
css
(
'overflow'
,
'hidden'
);
$num
=
$
(
'#good-num'
);
cbFn
=
cb
;
}
...
...
@@ -76,6 +72,7 @@ function show(html, cb) {
//隐藏当前Panel
function
hide
()
{
$
(
'.chose-panel'
).
hide
();
$
(
'body'
).
css
(
'overflow'
,
'auto'
);
}
//修改加入购物车的文字和背景
...
...
@@ -90,18 +87,19 @@ function updateConformButtonClassAndText() {
//重置颜色块的库存为0的样式
function
resetColorZeroStock
(
$siblingBlock
)
{
var
numArray
=
(
$curSizeBlock
.
data
(
'numstr'
)
+
''
).
split
(
'/'
)
,
var
numArray
,
i
;
if
(
!
hasChooseSize
)
{
$siblingBlock
.
find
(
'ul>li'
).
each
(
function
()
{
$
(
this
).
removeClass
(
'zero-stock'
);
if
(
'0'
===
$
(
this
).
data
(
'num'
))
{
if
(
0
===
$
(
this
).
data
(
'num'
))
{
$
(
this
).
addClass
(
'zero-stock'
);
}
});
}
else
{
numArray
=
(
$curSizeBlock
.
data
(
'numstr'
)
+
''
).
split
(
'/'
);
for
(
i
=
0
;
i
<
numArray
.
length
;
i
++
)
{
if
(
'0'
===
numArray
[
i
])
{
$siblingBlock
.
find
(
'.block'
).
eq
(
i
).
addClass
(
'zero-stock'
);
...
...
@@ -130,12 +128,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
hide
();
});
$yohoPage
.
on
(
'touchstart'
,
'.color-list .block'
,
function
(
e
)
{
$yohoPage
.
on
(
'touchstart'
,
'.color-list .block'
,
function
()
{
var
$this
=
$
(
this
),
index
,
curSizeBlock
,
$preSiblingBlock
,
scindex
,
$curSizeRow
,
numArray
,
i
,
curGoodNum
;
var
$siblingBlock
=
$this
.
closest
(
'.block-list'
).
siblings
(
':first'
);
...
...
@@ -144,7 +144,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
index
=
$this
.
index
();
$preSiblingBlock
=
$siblingBlock
.
find
(
'.chosed'
);
scindex
=
$preSiblingBlock
.
index
();
$curSizeRow
=
$sizeRowList
.
eq
(
index
);
// 当前颜色已经是选中状态,再点击时
...
...
@@ -155,6 +154,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
$leftNum
.
val
(
0
);
hasChooseColor
=
false
;
$this
.
removeClass
(
'zero-stock'
);
if
(
$curSizeBlock
)
{
numArray
=
(
$curSizeBlock
.
data
(
'numstr'
)
+
''
).
split
(
'/'
);
for
(
i
=
0
;
i
<
numArray
.
length
;
i
++
)
{
if
(
'0'
===
numArray
[
i
])
{
$
(
'.color-list .block'
).
eq
(
i
).
addClass
(
'zero-stock'
);
}
}
}
// 当前颜色不是选中状态,选中时
}
else
{
hasChooseColor
=
true
;
...
...
@@ -166,7 +175,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 之前选中的尺码去掉勾选样式
if
(
$preSiblingBlock
.
length
>
0
)
{
$preSiblingBlock
.
removeClass
(
'chosed'
);
curSizeBlock
=
$curSizeRow
.
children
().
get
(
sci
ndex
);
curSizeBlock
=
$curSizeRow
.
children
().
get
(
curSizeI
ndex
);
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
...
...
@@ -194,11 +203,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor
();
});
$yohoPage
.
on
(
'touchstart'
,
'.size-list .block'
,
function
(
e
)
{
}).
on
(
'touchstart'
,
'.size-list .block'
,
function
()
{
var
$this
=
$
(
this
),
index
,
$curSizeRow
,
curGoodNum
;
var
$siblingBlock
=
$this
.
closest
(
'.block-list'
).
siblings
(
':first'
);
...
...
@@ -246,7 +254,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) {
// 重置颜色块的样式
resetColorZeroStock
(
$siblingBlock
);
});
$yohoPage
.
on
(
'touchstart'
,
'.btn-minus'
,
function
()
{
...
...
@@ -332,7 +339,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if
(
res
.
code
===
200
)
{
$
(
'.num-tag'
).
html
(
numInCart
+
buyNumber
).
removeClass
(
'hide'
);
confirming
=
false
;
hide
();
if
(
cbFn
)
{
cbFn
();
...
...
@@ -341,6 +347,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if
(
res
.
message
)
{
tip
.
show
(
res
.
message
);
}
hide
();
}).
fail
(
function
()
{
tip
.
show
(
'网络出了点问题~'
);
}).
always
(
function
()
{
...
...
Please
register
or
login
to post a comment