Authored by jinhu.tung

send good to favorite

... ... @@ -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'
});
}
... ...
... ... @@ -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;
... ...
... ... @@ -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();
}
... ...
... ... @@ -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'));
});
});
... ...