Authored by 周少峰

Merge branch 'feature/cartAdd' of git.yoho.cn:fe/yohobuy-node into feature/cartAdd

... ... @@ -127,7 +127,7 @@ const delCartGoods = (req, res, next) => {
};
/**
* 加入购物车
* 加入购物车 商品详情页
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
... ... @@ -153,7 +153,8 @@ const cartAddIndex = (req, res) => {
uid, shoppingKey);
// 设置加入购物车凭证到客户端浏览器
if (!shoppingKey && result && result.data && result.data.shopping_key) {
if (!shoppingKey && _.get(result, 'data.shopping_key')) {
res.cookie('_SPK', result.data.shopping_key, {
expires: new Date(Date.now() + 86400 * 360),
domain: config.cookieDomain
... ... @@ -161,8 +162,17 @@ const cartAddIndex = (req, res) => {
}
// 更新头部购物车COOKIE
if (result && result.code === 200) {
yield setShoppingCookie(req, res); //eslint-disable-line
if (_.get(result, 'data.shopping_key')) {
res.cookie('_g', JSON.stringify({
_k: result.data.shopping_key,
_nac: result.data.goods_count,
_ac: 0,
_r: 1
}), {
expires: new Date(Date.now() + 86400 * 360),
domain: config.cookieDomain
});
}
res.send(result);
... ...
... ... @@ -17,7 +17,7 @@ const easypay = require(`${cRoot}/easypay`);
const ensure = require(`${cRoot}/order-ensure`);
router.get('/index/getProductInfo', cart.getProductInfo);
router.post('/cart/index/add', cart.cartAddIndex);
router.post('/cart/index/add', cart.cartAddIndex); // 加入购物车 商品详情页
router.get('/coupon/list', cart.getCoupons); // 优惠券列表
... ...