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
Email Patches
Plain Diff
Browse Files
Authored by
biao
9 years ago
Commit
523379fe23b1b9e9bb85be8c65e6f09419168fec
1 parent
6a8c8aa6
购物车中赠品或者加价购的商品增加编辑功能. code review by 张振
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
12 deletions
static/js/cart/chose-panel.js
static/js/cart/good.js
static/js/cart/chose-panel.js
View file @
523379f
...
...
@@ -99,6 +99,17 @@ function checkColorSizeNum() {
return
true
;
}
//禁用数字编辑
function
disableNumEdit
()
{
var
$numBtn
=
$
(
'.chose-panel'
).
find
(
'.num .btn>.iconfont'
);
//添加disabled样式
$numBtn
.
hasClass
(
'disabled'
)
?
null
:
$numBtn
.
addClass
(
'disabled'
);
$yohoPage
.
off
(
'touchstart'
,
'.btn-minus'
);
$yohoPage
.
off
(
'touchstart'
,
'.btn-plus'
);
}
function
show
(
html
,
cb
)
{
var
scrollPosition
=
[
...
...
@@ -116,8 +127,7 @@ function show(html, cb) {
if
(
html
)
{
$chosePanel
.
html
(
html
);
if
(
$
(
'#promotionId'
).
val
()
!==
''
)
{
$yohoPage
.
off
(
'touchstart'
,
'.btn-minus'
);
$yohoPage
.
off
(
'touchstart'
,
'.btn-plus'
);
disableNumEdit
();
}
init
();
}
...
...
@@ -497,4 +507,5 @@ exports.init = init;
exports
.
show
=
show
;
exports
.
remove
=
removePannel
;
exports
.
setEditModeWithSknId
=
setEditModeWithSknId
;
exports
.
disableNumEdit
=
disableNumEdit
;
...
...
static/js/cart/good.js
View file @
523379f
...
...
@@ -16,6 +16,9 @@ var dialog = require('../me/dialog'),
var
$selectAllBtn
=
$
(
'.balance .checkbox'
),
requesting
=
false
;
//上次编辑的商品skn
var
previousEditSkn
;
ellipsis
.
init
();
lazyLoad
({
...
...
@@ -86,11 +89,12 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
*
* @param {Bool} isSelected. 所要编辑的商品是否被选中
*
* @return false;
* @param {Bool} isEditNum. 所要编辑的商品是否被选中
*
* @return false or undefined
*
*/
function
showEditPannelWithSku
(
html
,
id
,
isSelected
)
{
function
showEditPannelWithSku
(
html
,
id
,
isSelected
,
isEditNum
)
{
if
(
html
.
length
<
2
)
{
tip
.
show
(
'出错啦!'
);
return
false
;
...
...
@@ -100,21 +104,47 @@ function showEditPannelWithSku(html, id, isSelected) {
chosePanel
.
remove
();
$
(
html
).
appendTo
(
'#mainCart'
);
chosePanel
.
init
();
chosePanel
.
setEditModeWithSknId
(
id
,
isSelected
);
chosePanel
.
show
();
return
false
;
if
(
!
isEditNum
)
{
chosePanel
.
disableNumEdit
();
}
chosePanel
.
show
();
}
$
(
'.icon-edit'
).
on
(
'touchstart'
,
function
(
e
)
{
var
$this
=
$
(
this
),
$checkBox
=
$this
.
closest
(
'.info'
).
siblings
(
'.checkbox'
);
skn
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'skn'
);
var
$checkBox
,
$tag
;
var
id
,
count
,
canEditNum
;
//如果点击的是上次编辑的商品,直接显示chose-pannel
if
(
skn
===
previousEditSkn
)
{
chosePanel
.
show
();
return
;
}
previousEditSkn
=
skn
;
$checkBox
=
$this
.
closest
(
'.info'
).
siblings
(
'.checkbox'
);
$tag
=
$this
.
closest
(
'.deps'
).
siblings
(
'.few-tag'
);
id
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'id'
);
count
=
$this
.
data
(
'count'
);
var
skn
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'skn'
),
id
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'id'
),
count
=
$this
.
data
(
'count'
);
//加价购或者赠品不能编辑数量
canEditNum
=
$tag
.
hasClass
(
'gift-tag'
)
||
$tag
.
hasClass
(
'plus-tag'
)
?
false
:
true
;
e
.
stopPropagation
();
...
...
@@ -128,7 +158,7 @@ $('.icon-edit').on('touchstart', function(e) {
buy_num
:
count
},
success
:
function
(
res
)
{
showEditPannelWithSku
(
res
,
id
,
$checkBox
.
hasClass
(
'icon-cb-checked'
));
showEditPannelWithSku
(
res
,
id
,
$checkBox
.
hasClass
(
'icon-cb-checked'
)
,
canEditNum
);
},
error
:
function
()
{
tip
.
show
(
'网络异常'
);
...
...
Please
register
or
login
to post a comment