item.js
841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* 商品详情页controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/4
*/
'use strict';
const _ = require('lodash');
const Item = require('../models/item');
const index = (req, res, next) => {
Item.getProductItemData(req.params, req.url, req.user.uid).then(result => {
if (_.isEmpty(result)) {
return next();
}
result.page = 'item';
res.display('item', result);
}).catch(next);
};
const getProductInfo = (req, res, next) => {
const productId = req.query.productId;
const skn = req.query.skn;
let uid;
if (req.user && req.user.uid) {
uid = req.user.uid;
}
Item.getProductInfo(productId, skn, uid).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
index, // 组件demo页
getProductInfo
};