Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
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
Plain Diff
Browse Files
Authored by
毕凯
9 years ago
Commit
1b46ae63cc85202108d3948bfa8ef3c0b3db7d76
2 parents
12d10b4d
8de80e6e
Merge branch 'feature/cart' into develop
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
53 deletions
static/js/cart/good.js
template/m.yohobuy.com/partials/cart/cart-content.phtml
static/js/cart/good.js
View file @
1b46ae6
...
...
@@ -29,16 +29,56 @@ if ($names.length > 0) {
$names
[
0
].
mlellipsis
(
2
);
}
//获取当前购物车类型
function
getCartType
()
{
var
$navItem
=
$
(
'.cart-nav '
).
find
(
'li'
),
type
=
'ordinary'
;
if
(
$navItem
.
eq
(
0
).
hasClass
(
'active'
))
{
type
=
'ordinary'
;
}
else
{
type
=
'advance'
;
}
return
type
;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$
(
'.cart-goods'
).
on
(
'touchstart'
,
'.checkbox'
,
function
()
{
var
$this
=
$
(
this
),
id
=
$
(
this
).
closest
(
'.shopping-cart-good'
).
data
(
'id'
);
$good
=
$this
.
closest
(
'.shopping-cart-good'
),
id
=
$good
.
data
(
'id'
);
var
goodsList
=
[],
goodInfo
=
{},
isSelected
=
true
;
if
(
$this
.
hasClass
(
'icon-cb-checked'
))
{
isSelected
=
true
;
}
else
{
isSelected
=
false
;
}
function
GoodInfo
(
properties
)
{
this
.
goods_type
=
properties
.
goods_type
;
this
.
buy_number
=
properties
.
buy_number
;
this
.
product_sku
=
properties
.
product_sku
;
this
.
selected
=
properties
.
selected
;
}
goodInfo
.
goods_type
=
getCartType
();
goodInfo
.
selected
=
isSelected
?
'Y'
:
'N'
;
goodInfo
.
product_sku
=
id
;
goodInfo
.
buy_number
=
$good
.
find
(
'.count'
).
eq
(
0
).
text
().
trim
().
replace
(
'×'
,
''
);
goodsList
.
push
(
new
GoodInfo
(
goodInfo
));
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/select'
,
type
:
'post'
,
url
:
'select'
,
data
:
{
id
:
id
skuList
:
JSON
.
stringify
(
goodsList
)
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
...
...
@@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
$
.
ajax
({
type
:
'GET'
,
url
:
'
/cart/index/
getCartData'
,
url
:
'getCartData'
,
data
:
{
skuList
:
JSON
.
stringfy
(
id
)
id
:
id
},
success
:
function
(
data
)
{
if
(
data
)
{
...
...
@@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
tip
.
show
(
'网络错误'
);
}
});
}
else
if
(
data
.
code
===
2
00
)
{
}
else
if
(
data
.
code
===
4
00
)
{
tip
.
show
(
'网络错误'
);
}
}).
fail
(
function
()
{
...
...
@@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
e
.
stopPropagation
();
//手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板
//docTouchEvt();
//
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
//
//$(document).on('touchstart', docTouchEvt);
dialog
.
showDialog
({
dialogText
:
'您确定要从购物车中删除吗?'
,
hasFooter
:
{
...
...
@@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
// .on('touchstart', '.opt-panel', function() {
// var $this = $(this),
// id = $this.closest('.shopping-cart-good').data('id'),
// url;
//
// if ($this.closest('.put-in-favorite').length > 0) {
//
// //移入收藏夹
// url = '/shoppingCart/col';
// } else {
//
// //删除
// url = '/shoppingCart/del';
// }
//
// $.ajax({
// type: 'POST',
// url: url,
// data: {
// id: id
// }
// });
//})
function
requestUpdateAllGoodsCheckStatus
(
theGoods
,
successHandeler
)
{
if
(
requesting
)
{
return
;
...
...
@@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
goodsList
.
push
(
new
GoodInfo
(
goodInfo
));
});
console
.
log
(
goodsList
);
requestUpdateAllGoodsCheckStatus
(
goodsList
,
handlerAfterTouch
);
}
//获取当前购物车类型
function
getCartType
()
{
var
$navItem
=
$
(
'.cart-nav '
).
find
(
'li'
),
type
=
'ordinary'
;
if
(
$navItem
.
eq
(
0
).
hasClass
(
'active'
))
{
type
=
'ordinary'
;
}
else
{
type
=
'advance'
;
}
return
type
;
}
//是否要全选
function
willBeSelected
()
{
...
...
template/m.yohobuy.com/partials/cart/cart-content.phtml
View file @
1b46ae6
...
...
@@ -3,9 +3,9 @@
{{> cart/good}}
{{/ goods}}
{{#
$
notValidGoods}}
{{# notValidGoods}}
{{> cart/good}}
{{/
$
notValidGoods}}
{{/ notValidGoods}}
</div>
...
...
Please
register
or
login
to post a comment