...
|
...
|
@@ -2,6 +2,8 @@ |
|
|
* Created by targaryen on 2016/11/28.
|
|
|
*/
|
|
|
'use strict';
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
const mRoot = '../models';
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const bundleModel = require(`${mRoot}/bundle`);
|
...
|
...
|
@@ -36,6 +38,8 @@ exports.detail = (req, res, next) => { |
|
|
* 套餐加入购物车
|
|
|
*/
|
|
|
exports.addToCart = (req, res, next) => {
|
|
|
let shoppingKey = req.cookies._SPK || '';
|
|
|
|
|
|
bundleModel.addToCart({
|
|
|
uid: req.user.uid,
|
|
|
activity_id: req.body.activity_id,
|
...
|
...
|
@@ -43,6 +47,11 @@ exports.addToCart = (req, res, next) => { |
|
|
shopping_key: req.cookies._SPK || '',
|
|
|
userAgent: req.get('User-Agent')
|
|
|
}).then(result => {
|
|
|
if (!shoppingKey && _.has(result, 'data.shopping_key')) {
|
|
|
res.cookie('_SPK', result.data.shopping_key, {
|
|
|
expires: new Date(Date.now() + 86400 * 360)
|
|
|
});
|
|
|
}
|
|
|
return res.json(result);
|
|
|
}).catch(next);
|
|
|
}; |
...
|
...
|
|