Authored by 郝肖肖

套餐 加入购物车,shoppingKey 不存在,设置key

... ... @@ -555,6 +555,30 @@ const addBundle = (req, res, next) => {
}
service.addBundleData(params).then(result => {
// 设置加入购物车凭证到客户端浏览器
if (!shoppingKey && _.get(result, 'data.shopping_key')) {
res.cookie('_SPK', result.data.shopping_key, {
expires: new Date(Date.now() + 86400 * 360),
domain: config.cookieDomain
});
}
// 更新头部购物车COOKIE
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.json(result);
}).catch(next);
};
... ...