Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
jinhu.tung
9 years ago
Commit
5b2067305307233d02acfdc54d21fa9b17299f98
1 parent
f3944455
send good to favorite
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
8 deletions
apps/shopping/controllers/cart.js
apps/shopping/router.js
public/js/shopping/cart.js
public/js/shopping/cart.page.js
apps/shopping/controllers/cart.js
View file @
5b20673
...
...
@@ -113,5 +113,13 @@ exports.removeProduct = (req, res) => {
// TODO
res
.
json
({
code
:
'0'
})
}
\ No newline at end of file
});
};
// 收藏商品
exports
.
sendToFavorite
=
(
req
,
res
)
=>
{
// TODO
res
.
json
({
code
:
'0'
});
}
...
...
apps/shopping/router.js
View file @
5b20673
...
...
@@ -16,6 +16,7 @@ router.get('/cart', cartCtrl.index);
router
.
get
(
'/cart/product/check_inventory'
,
cartCtrl
.
checkInventory
);
router
.
post
(
'/cart/product/:productId/change_num'
,
cartCtrl
.
changeProductNum
);
router
.
delete
(
'/cart/product/:productId'
,
cartCtrl
.
removeProduct
);
router
.
post
(
'/cart/product/:productId/send_to_favorite'
,
cartCtrl
.
sendToFavorite
);
module
.
exports
=
router
;
...
...
public/js/shopping/cart.js
View file @
5b20673
...
...
@@ -95,19 +95,41 @@ var Cart = {
var
dialog
=
new
_confirm
({
content
:
'您确定要从购物车中删除该商品吗?'
,
cb
:
function
()
{
console
.
log
(
'confirm:'
,
productId
)
console
.
log
(
'confirm:'
,
productId
)
;
Util
.
ajax
({
url
:
'/shopping/cart/product/'
+
productId
,
type
:
'DELETE'
,
success
:
function
(
res
)
{
if
(
res
.
code
===
'0'
)
{
if
(
res
.
code
===
'0'
)
{
dialog
.
close
();
}
},
fail
:
function
()
{
fail
:
function
()
{
// TODO
}
})
});
}
}).
show
();
},
// 移入收藏夹
sendToFavorite
:
function
(
productId
)
{
var
dialog
=
new
_confirm
({
content
:
'确定要将该商品从购物车中移入收藏吗?<br/>移入收藏后该商品将不在购物车中显示'
,
cb
:
function
()
{
console
.
log
(
'confirm:'
,
productId
);
Util
.
ajax
({
url
:
'/shopping/cart/product/'
+
productId
+
'/send_to_favorite'
,
type
:
'POST'
,
success
:
function
(
res
)
{
if
(
res
.
code
===
'0'
)
{
dialog
.
close
();
}
},
fail
:
function
()
{
// TODO
}
});
}
}).
show
();
}
...
...
public/js/shopping/cart.page.js
View file @
5b20673
...
...
@@ -82,10 +82,13 @@ $(function() {
// 变动商品数量
Stepper
.
init
();
console
.
log
(
$
(
'.remove-item'
))
// 删除商品
$
(
'.remove-item'
).
on
(
'click'
,
function
()
{
console
.
log
(
111
)
Cart
.
removePro
(
$
(
this
).
attr
(
'data-productId'
));
});
// 移入收藏夹
$
(
'.send-to-favorite'
).
on
(
'click'
,
function
()
{
Cart
.
sendToFavorite
(
$
(
this
).
attr
(
'data-productId'
));
});
});
...
...
Please
register
or
login
to post a comment