Authored by OF1706

mini dev node new

... ... @@ -98,6 +98,35 @@ const miniCart = (req, res, next) => {
};
/**
* 首页迷你购物车删除数据信息
* @param req
* @param res
* @param next
*/
const delCartGoods = (req, res, next) => {
let uid = req.user.uid;
let shoppingKey = helper.getShoppingKeyByCookie(req);
let productSku = req.query.product_sku;
let buyNumber = req.query.product_num || 1;
let callback = req.query.callback;
let skuList = {};
skuList[productSku] = parseInt(buyNumber);
service.removeFromCart(uid, shoppingKey, JSON.stringify(skuList))
.then(ret => {
if (ret && ret.code === 200 && _.has(ret, 'data.goods_count')) {
ret.data.total_goods_num = ret.data.goods_count;
return res.send(callback + '(' + JSON.stringify(ret) + ')');
} else {
return res.send(callback + '(' + JSON.stringify(ret) + ')');
}
})
.catch(next);
};
/**
* 我的购物车
*/
const cart = (req, res, next) => {
... ... @@ -441,5 +470,6 @@ module.exports = {
swapGift,
queryUserPromotionGift,
getCoupons,
miniCart
miniCart,
delCartGoods
};
... ...
... ... @@ -105,11 +105,10 @@ const selectGoods = (uid, sku, shoppingKey /* , hasPromotion*/) => {
* @param bool $hasPromotion 是否有促销ID
* @return array 接口返回的数据
*/
const removeFromCart = (uid, shoppingKey, skuList /* , hasPromotion*/) =>{
const removeFromCart = (uid, shoppingKey, skuList , hasPromotion) =>{
let param = {
// method: hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove',
method: 'app.Shopping.removeAndQryCart',
method: hasPromotion ? 'app.Shopping.removeAndQryCart' : 'app.Shopping.remove',
product_sku_list: skuList
};
... ...
... ... @@ -594,6 +594,10 @@ const removeFromCart = (uid, shoppingKey, skuList, hasPromotion, cartDelList) =>
let ret = yield cartApi.removeFromCart(uid, shoppingKey, skuList, hasPromotion);
if(!hasPromotion) {
return ret;
}
if (ret && ret.code) {
result = {
code: ret.code,
... ...
... ... @@ -47,5 +47,6 @@ router.get('/cart/queryPromotionGift', cart.queryUserPromotionGift);
router.get('/cart/togetherProduct', cart.getTogetherProduct);
router.get('/cart/recommendProduct', cart.getRecommendProductAction);
router.get('/cart/minicart', cart.miniCart);
router.get('/cart/del', cart.delCartGoods);
module.exports = router;
... ...
... ... @@ -6,23 +6,6 @@
<a href="{{listUrl}}">去购物</a>
</div>
</div>
<div class="dev-revocation {{#unless deleteShop}}none{{/unless}}">
<table>
{{# deleteShop}}
<tr data-productnum="{{productNum}}" data-productsku="{{productSku}}">
<td style="width:35%; text-align: left;">成功删除<a class="title" href="{{link}}"
target="_blank">{{productTitle}}</a>
</td>
<td style="width:14%;"><span class="productPrice">{{productPrice}}</span></td>
<td style="width:15%;">{{productNum}}</td>
<td style="width:16%;"></td>
<td style="width:11.8%; border-right: none; text-align: right;">
<a href="javascript:void(0);"><span class="goBack">撤销本次删除</span></a>
</td>
</tr>
{{/ deleteShop}}
</table>
</div>
{{^}}
<!-- 购物车商品列表 -->
<div class="pay-wapper">
... ...
... ... @@ -418,7 +418,7 @@ function delCartGoods(data, callback) {
product_num: data.num
};
$.getJSON('//www.yohobuy.com/common/delCartGoods/?callback=?', param, function(jsonData) {
$.getJSON('//www.yohobuy.com/cart/cart/del?callback=?', param, function(jsonData) {
var strG = '';
if (jsonData.code === 200) {
... ...