Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
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
Email Patches
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
4f45ed26bf9808972d8b7e3a0fdc57be9057239d
1 parent
b6e4da12
购物车功能开发
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
41 deletions
static/js/cart/good.js
template/m.yohobuy.com/partials/cart/cart-content.phtml
static/js/cart/good.js
View file @
4f45ed2
...
...
@@ -32,13 +32,39 @@ if ($names.length > 0) {
//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 +75,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 +90,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 +121,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 +155,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,7 +231,6 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
goodsList
.
push
(
new
GoodInfo
(
goodInfo
));
});
console
.
log
(
goodsList
);
requestUpdateAllGoodsCheckStatus
(
goodsList
,
handlerAfterTouch
);
}
...
...
template/m.yohobuy.com/partials/cart/cart-content.phtml
View file @
4f45ed2
...
...
@@ -3,9 +3,9 @@
{{> cart/good}}
{{/ goods}}
{{#
$
notValidGoods}}
{{# notValidGoods}}
{{> cart/good}}
{{/
$
notValidGoods}}
{{/ notValidGoods}}
</div>
...
...
Please
register
or
login
to post a comment