|
@@ -6,6 +6,7 @@ const _ = require('lodash'); |
|
@@ -6,6 +6,7 @@ const _ = require('lodash'); |
6
|
|
6
|
|
7
|
const detailModel = require('../models/detail');
|
7
|
const detailModel = require('../models/detail');
|
8
|
const newDetailModel = require('../models/new-detail');
|
8
|
const newDetailModel = require('../models/new-detail');
|
|
|
9
|
+const listModel = require('../models/list');
|
9
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
10
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
10
|
|
11
|
|
11
|
const newDetail = {
|
12
|
const newDetail = {
|
|
@@ -115,6 +116,27 @@ const newDetail = { |
|
@@ -115,6 +116,27 @@ const newDetail = { |
115
|
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
|
116
|
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
|
116
|
return res.json(result);
|
117
|
return res.json(result);
|
117
|
}).catch(next);
|
118
|
}).catch(next);
|
|
|
119
|
+ },
|
|
|
120
|
+
|
|
|
121
|
+ /**
|
|
|
122
|
+ * 商品收藏/取消收藏
|
|
|
123
|
+ */
|
|
|
124
|
+ favoriteProduct(req, res, next) {
|
|
|
125
|
+ let allowOrigin = _.get(req, 'headers.origin', null) ?
|
|
|
126
|
+ req.headers.origin : req.protocol + '://' + req.headers.host;
|
|
|
127
|
+
|
|
|
128
|
+ res.setHeader('Access-Control-Allow-Origin', allowOrigin);
|
|
|
129
|
+ res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
|
130
|
+
|
|
|
131
|
+ if (req.body.opt === 'ok') {
|
|
|
132
|
+ listModel.setFavorite(req.body.id, req.user.uid, 'product').then(result => {
|
|
|
133
|
+ return res.json(result);
|
|
|
134
|
+ }).catch(next);
|
|
|
135
|
+ } else {
|
|
|
136
|
+ listModel.setFavoriteCancel(req.body.id, req.user.uid, 'product').then(result => {
|
|
|
137
|
+ return res.json(result);
|
|
|
138
|
+ }).catch(next);
|
|
|
139
|
+ }
|
118
|
}
|
140
|
}
|
119
|
};
|
141
|
};
|
120
|
|
142
|
|