shop.js
2.32 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/7/26
* Time: 10:34
*/
'use strict';
const mRoot = '../models';
const shopModel = require(`${mRoot}/shop`);
module.exports = {
/* 品牌店铺页面 */
index: (req, res) => {
res.render('shop/index', {
module: 'product',
page: 'shop',
domain: req.params.domain,
shopId: req.query.id
});
},
/* 获取品牌店铺介绍 */
getShopInfo: (req, res, next) => {
shopModel.getShopData({
domain: req.query.domain,
shopId: req.query.shopId,
uid: req.user.uid
}).then(result => {
res.json(result);
}).catch(next);
},
/* 获取商品列表 */
getBrandShopGoods: (req, res, next) => {
shopModel.getBrandShopGoodsData({
domain: req.query.domain,
sort: req.query.sort,
page: req.query.page,
channel: req.query.channel || 'men',
gender: '1,2,3', // 店铺 不分 性别
brand: req.query.brand,
shopId: req.query.id,
order: req.query.order || 's_t_desc',
limit: req.query.limit || '60',
color: req.query.color,
price: req.query.priceRange,
size: req.query.size,
pd: req.query.pd,
tagsFilter: req.query.tagsFilter
}).then(result => {
res.json(result);
}).catch(next);
},
/* 收藏品牌或者店铺 */
collectShop: (req, res, next) => {
if (!req.user.uid) {
return res.json({
code: 403,
message: '未登录'
});
}
shopModel.collectShopData({
id: req.body.isBlkShop ? req.body.shopId : req.body.brandId,
favId: req.body.isBlkShop ? req.body.shopId : req.body.brandId,
uid: req.user.uid,
type: req.body.isBlkShop ? 'shop' : 'brand',
isFav: req.body.isFav
}).then(result => {
res.json(result);
}).catch(next);
},
/* 品牌店铺分享页面 */
shopShare: (req, res) => {
res.render('shop/share', {
module: 'product',
page: 'shop-share',
domain: req.params.domain,
shopId: req.query.id
});
}
};