|
@@ -11,7 +11,7 @@ const headerModel = require('../../../doraemon/models/header'); |
|
@@ -11,7 +11,7 @@ const headerModel = require('../../../doraemon/models/header'); |
11
|
const _ = require('lodash');
|
11
|
const _ = require('lodash');
|
12
|
const helpers = global.yoho.helpers;
|
12
|
const helpers = global.yoho.helpers;
|
13
|
const productProcess = require(`${utils}/product-process`);
|
13
|
const productProcess = require(`${utils}/product-process`);
|
14
|
-const redShopPrcs = require(`${utils}/redshop-process`);
|
14
|
+const shopPrcs = require(`${utils}/shop-process`);
|
15
|
const co = require('bluebird').coroutine;
|
15
|
const co = require('bluebird').coroutine;
|
16
|
|
16
|
|
17
|
const shop = {
|
17
|
const shop = {
|
|
@@ -38,9 +38,17 @@ const shop = { |
|
@@ -38,9 +38,17 @@ const shop = { |
38
|
let shopInfoApi = (yield shopModel.getShopInfo(shopId, uid)) || {};
|
38
|
let shopInfoApi = (yield shopModel.getShopInfo(shopId, uid)) || {};
|
39
|
let shopInfo = _.get(shopInfoApi, 'data', {});
|
39
|
let shopInfo = _.get(shopInfoApi, 'data', {});
|
40
|
|
40
|
|
|
|
41
|
+ // 红人店铺
|
41
|
if (shopInfo && shopInfo.is_red_shop === 1) {
|
42
|
if (shopInfo && shopInfo.is_red_shop === 1) {
|
42
|
- shopInfo.shopId = _.get(shopInfo, 'shops_id', '');
|
43
|
+ shopInfo.isRedShop = true;
|
43
|
}
|
44
|
}
|
|
|
45
|
+
|
|
|
46
|
+ // 店铺,非红人店铺,跳转店铺列表
|
|
|
47
|
+ if (shopInfo && shopInfo.is_red_shop !== 1) {
|
|
|
48
|
+ shopInfo.isShop = true;
|
|
|
49
|
+ }
|
|
|
50
|
+
|
|
|
51
|
+ // 可能没有店铺信息,跳转店铺列表
|
44
|
req.shopInfo = shopInfo;
|
52
|
req.shopInfo = shopInfo;
|
45
|
} else if (domain) {
|
53
|
} else if (domain) {
|
46
|
let domainInfo = (yield shopModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
|
54
|
let domainInfo = (yield shopModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
|
|
@@ -55,11 +63,11 @@ const shop = { |
|
@@ -55,11 +63,11 @@ const shop = { |
55
|
}
|
63
|
}
|
56
|
}
|
64
|
}
|
57
|
|
65
|
|
58
|
- if (req.shopInfo.shopId) { // 店铺
|
66
|
+ if (req.shopInfo.isRedShop) { // 店铺
|
59
|
return shop.redShop(req, res, next);
|
67
|
return shop.redShop(req, res, next);
|
60
|
} else if (req.shopInfo.id) { // 品牌,id 来自 domainInfo
|
68
|
} else if (req.shopInfo.id) { // 品牌,id 来自 domainInfo
|
61
|
return shop.brand(req, res, next);
|
69
|
return shop.brand(req, res, next);
|
62
|
- } else if (shopId) { // 没有查到店铺数据但是有 shopId 的请求
|
70
|
+ } else if (shopId) { // 非红人店铺非品牌
|
63
|
return shop.list(req, res, next);
|
71
|
return shop.list(req, res, next);
|
64
|
} else { // 什么都没有,去首页
|
72
|
} else { // 什么都没有,去首页
|
65
|
return res.redirect(helpers.urlFormat('', {go: '-1'}));
|
73
|
return res.redirect(helpers.urlFormat('', {go: '-1'}));
|
|
@@ -122,8 +130,7 @@ const shop = { |
|
@@ -122,8 +130,7 @@ const shop = { |
122
|
};
|
130
|
};
|
123
|
|
131
|
|
124
|
co(function* () {
|
132
|
co(function* () {
|
125
|
- let [banner, brandInfo, goodsListApi] = yield Promise.all([
|
|
|
126
|
- shopModel.getBrandBanner(brandId),
|
133
|
+ let [brandInfo, goodsListApi] = yield Promise.all([
|
127
|
shopModel.getBrandIntro(brandId, uid),
|
134
|
shopModel.getBrandIntro(brandId, uid),
|
128
|
searchModel.getBrandGoods(searchParam)
|
135
|
searchModel.getBrandGoods(searchParam)
|
129
|
]);
|
136
|
]);
|
|
@@ -131,7 +138,6 @@ const shop = { |
|
@@ -131,7 +138,6 @@ const shop = { |
131
|
let title = brandInfo.title;
|
138
|
let title = brandInfo.title;
|
132
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
139
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
133
|
|
140
|
|
134
|
- brandInfo.banner = banner;
|
|
|
135
|
|
141
|
|
136
|
res.render('newshop/shop-brand', {
|
142
|
res.render('newshop/shop-brand', {
|
137
|
module: 'product',
|
143
|
module: 'product',
|
|
@@ -145,7 +151,6 @@ const shop = { |
|
@@ -145,7 +151,6 @@ const shop = { |
145
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
151
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
146
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
152
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
147
|
brandId: brandId,
|
153
|
brandId: brandId,
|
148
|
- brandInfo: brandInfo,
|
|
|
149
|
goodsList: goodsList,
|
154
|
goodsList: goodsList,
|
150
|
shopPage: true,
|
155
|
shopPage: true,
|
151
|
_noLazy: true,
|
156
|
_noLazy: true,
|
|
@@ -158,7 +163,7 @@ const shop = { |
|
@@ -158,7 +163,7 @@ const shop = { |
158
|
* 红人店铺
|
163
|
* 红人店铺
|
159
|
*/
|
164
|
*/
|
160
|
redShop(req, res, next) {
|
165
|
redShop(req, res, next) {
|
161
|
- let shopId = req.shopInfo.shopId;
|
166
|
+ let shopId = req.shopInfo.shops_id;
|
162
|
let channel = req.yoho.channel || 'boys';
|
167
|
let channel = req.yoho.channel || 'boys';
|
163
|
let uid = req.user.uid || 0;
|
168
|
let uid = req.user.uid || 0;
|
164
|
let udid = req.sessionID || 'yoho';
|
169
|
let udid = req.sessionID || 'yoho';
|
|
@@ -178,11 +183,11 @@ const shop = { |
|
@@ -178,11 +183,11 @@ const shop = { |
178
|
let banner = _.get(bannerData, 'data.banner');
|
183
|
let banner = _.get(bannerData, 'data.banner');
|
179
|
let shopInfo = req.shopInfo;
|
184
|
let shopInfo = req.shopInfo;
|
180
|
let favCount = _.get(favCountData, 'data[0].approximateCount', '2.1w');
|
185
|
let favCount = _.get(favCountData, 'data[0].approximateCount', '2.1w');
|
181
|
- let decoratorsAll = redShopPrcs.floor(_.get(decoratorsData, 'data.modules', []));
|
|
|
182
|
- let category = redShopPrcs.category(_.get(categoryData, 'data', []), shopId);
|
186
|
+ let decoratorsAll = shopPrcs.floor(_.get(decoratorsData, 'data.modules', []));
|
|
|
187
|
+ let category = shopPrcs.category(_.get(categoryData, 'data', []), shopId);
|
183
|
|
188
|
|
184
|
let goodsListBySkn = yield searchModel.searchProductBySkn(decoratorsAll.skns);
|
189
|
let goodsListBySkn = yield searchModel.searchProductBySkn(decoratorsAll.skns);
|
185
|
- let decorators = redShopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn);
|
190
|
+ let decorators = shopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn);
|
186
|
|
191
|
|
187
|
shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', {shop_id: shopId});
|
192
|
shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', {shop_id: shopId});
|
188
|
|
193
|
|
|
@@ -224,8 +229,9 @@ const shop = { |
|
@@ -224,8 +229,9 @@ const shop = { |
224
|
*/
|
229
|
*/
|
225
|
list(req, res, next) {
|
230
|
list(req, res, next) {
|
226
|
co(function* () {
|
231
|
co(function* () {
|
227
|
- let title = '店铺商品列表';
|
|
|
228
|
let shopId = req.query.shop_id;
|
232
|
let shopId = req.query.shop_id;
|
|
|
233
|
+ let shopInfo = req.shopInfo || {};
|
|
|
234
|
+ let title = shopInfo.shop_name || '店铺商品列表';
|
229
|
let searchParam = {
|
235
|
let searchParam = {
|
230
|
isApp: req.yoho.isApp,
|
236
|
isApp: req.yoho.isApp,
|
231
|
shop_id: shopId,
|
237
|
shop_id: shopId,
|
|
@@ -238,6 +244,15 @@ const shop = { |
|
@@ -238,6 +244,15 @@ const shop = { |
238
|
let goodsListApi = yield searchModel.getShopGoods(searchParam);
|
244
|
let goodsListApi = yield searchModel.getShopGoods(searchParam);
|
239
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
245
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
240
|
|
246
|
|
|
|
247
|
+ if (shopInfo.isShop) {
|
|
|
248
|
+ let shopDecorator = yield shopModel.getShopDecorator(shopId);
|
|
|
249
|
+ let shopDecoratorList = _.get(shopDecorator, 'list', []);
|
|
|
250
|
+
|
|
|
251
|
+ if (shopDecoratorList) {
|
|
|
252
|
+ shopInfo.banner = shopPrcs.getShopBanner(shopDecoratorList);
|
|
|
253
|
+ }
|
|
|
254
|
+ }
|
|
|
255
|
+
|
241
|
res.render('newshop/shop-list', {
|
256
|
res.render('newshop/shop-list', {
|
242
|
module: 'product',
|
257
|
module: 'product',
|
243
|
page: 'shop-list',
|
258
|
page: 'shop-list',
|
|
@@ -250,6 +265,7 @@ const shop = { |
|
@@ -250,6 +265,7 @@ const shop = { |
250
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
265
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
251
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
266
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
252
|
shopId: shopId,
|
267
|
shopId: shopId,
|
|
|
268
|
+ shopInfo: shopInfo,
|
253
|
goodsList: goodsList,
|
269
|
goodsList: goodsList,
|
254
|
shopPage: true,
|
270
|
shopPage: true,
|
255
|
_noLazy: true,
|
271
|
_noLazy: true,
|