套餐 加入购物车,shoppingKey 不存在,设置key
Showing
1 changed file
with
24 additions
and
0 deletions
@@ -555,6 +555,30 @@ const addBundle = (req, res, next) => { | @@ -555,6 +555,30 @@ const addBundle = (req, res, next) => { | ||
555 | } | 555 | } |
556 | 556 | ||
557 | service.addBundleData(params).then(result => { | 557 | service.addBundleData(params).then(result => { |
558 | + | ||
559 | + // 设置加入购物车凭证到客户端浏览器 | ||
560 | + if (!shoppingKey && _.get(result, 'data.shopping_key')) { | ||
561 | + | ||
562 | + res.cookie('_SPK', result.data.shopping_key, { | ||
563 | + expires: new Date(Date.now() + 86400 * 360), | ||
564 | + domain: config.cookieDomain | ||
565 | + }); | ||
566 | + } | ||
567 | + | ||
568 | + // 更新头部购物车COOKIE | ||
569 | + if (_.get(result, 'data.shopping_key')) { | ||
570 | + | ||
571 | + res.cookie('_g', JSON.stringify({ | ||
572 | + _k: result.data.shopping_key, | ||
573 | + _nac: result.data.goods_count, | ||
574 | + _ac: 0, | ||
575 | + _r: 1 | ||
576 | + }), { | ||
577 | + expires: new Date(Date.now() + 86400 * 360), | ||
578 | + domain: config.cookieDomain | ||
579 | + }); | ||
580 | + } | ||
581 | + | ||
558 | res.json(result); | 582 | res.json(result); |
559 | }).catch(next); | 583 | }).catch(next); |
560 | }; | 584 | }; |
-
Please register or login to post a comment