|
@@ -6,6 +6,7 @@ |
|
@@ -6,6 +6,7 @@ |
6
|
const mRoot = '../models';
|
6
|
const mRoot = '../models';
|
7
|
const utils = '../../../utils';
|
7
|
const utils = '../../../utils';
|
8
|
const listModel = require(`${mRoot}/list`);
|
8
|
const listModel = require(`${mRoot}/list`);
|
|
|
9
|
+const shopModel = require(`${mRoot}/shop`);
|
9
|
const searchModel = require(`${mRoot}/search`);
|
10
|
const searchModel = require(`${mRoot}/search`);
|
10
|
const redsShopModel = require(`${mRoot}/popular-shop`);
|
11
|
const redsShopModel = require(`${mRoot}/popular-shop`);
|
11
|
const headerModel = require('../../../doraemon/models/header');
|
12
|
const headerModel = require('../../../doraemon/models/header');
|
|
@@ -14,6 +15,25 @@ const helpers = global.yoho.helpers; |
|
@@ -14,6 +15,25 @@ const helpers = global.yoho.helpers; |
14
|
const productProcess = require(`${utils}/product-process`);
|
15
|
const productProcess = require(`${utils}/product-process`);
|
15
|
|
16
|
|
16
|
|
17
|
|
|
|
18
|
+/**
|
|
|
19
|
+ * 从 useragent 获取 uid
|
|
|
20
|
+ * @returns {*}
|
|
|
21
|
+ * @private
|
|
|
22
|
+ */
|
|
|
23
|
+const _getUidFromUserAgent = (req) => {
|
|
|
24
|
+ let userAgent = _.split(req.headers['user-agent'], ';');
|
|
|
25
|
+ let uidString = '';
|
|
|
26
|
+
|
|
|
27
|
+ _.forEach(userAgent, value => {
|
|
|
28
|
+ if (_.startsWith(value, 'uid')) {
|
|
|
29
|
+ uidString = value;
|
|
|
30
|
+ return;
|
|
|
31
|
+ }
|
|
|
32
|
+ });
|
|
|
33
|
+
|
|
|
34
|
+ return _.split(uidString, '=')[1];
|
|
|
35
|
+};
|
|
|
36
|
+
|
17
|
const shop = {
|
37
|
const shop = {
|
18
|
index(req, res, next) {
|
38
|
index(req, res, next) {
|
19
|
let params = Object.assign({}, req.query);
|
39
|
let params = Object.assign({}, req.query);
|
|
@@ -66,7 +86,10 @@ const shop = { |
|
@@ -66,7 +86,10 @@ const shop = { |
66
|
shop.shop(req, res, next);
|
86
|
shop.shop(req, res, next);
|
67
|
return false;
|
87
|
return false;
|
68
|
} else if (req.query.from === 'search') {
|
88
|
} else if (req.query.from === 'search') {
|
69
|
- return Promise.all([listModel.getBrandShops(brandId, req), searchModel.getSearchData(searchParam)]).then(shopResult => {
|
89
|
+ return Promise.all([
|
|
|
90
|
+ listModel.getBrandShops(brandId, req),
|
|
|
91
|
+ searchModel.getSearchData(searchParam)
|
|
|
92
|
+ ]).then(shopResult => {
|
70
|
let brandShop = shopResult[0];
|
93
|
let brandShop = shopResult[0];
|
71
|
let newGoods = shopResult[1];
|
94
|
let newGoods = shopResult[1];
|
72
|
|
95
|
|
|
@@ -97,7 +120,10 @@ const shop = { |
|
@@ -97,7 +120,10 @@ const shop = { |
97
|
title: result.name,
|
120
|
title: result.name,
|
98
|
id: result.id
|
121
|
id: result.id
|
99
|
};
|
122
|
};
|
100
|
- return Promise.all([listModel.getBrandBanner(brandId), searchModel.getSearchData(searchParam)]).then(brandResult => {
|
123
|
+ return Promise.all([
|
|
|
124
|
+ listModel.getBrandBanner(brandId),
|
|
|
125
|
+ searchModel.getSearchData(searchParam)
|
|
|
126
|
+ ]).then(brandResult => {
|
101
|
let brandBanner = brandResult[0];
|
127
|
let brandBanner = brandResult[0];
|
102
|
let newGoods = brandResult[1];
|
128
|
let newGoods = brandResult[1];
|
103
|
|
129
|
|
|
@@ -184,8 +210,12 @@ const shop = { |
|
@@ -184,8 +210,12 @@ const shop = { |
184
|
}
|
210
|
}
|
185
|
|
211
|
|
186
|
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
|
212
|
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
|
187
|
- if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
|
|
|
188
|
- return Promise.all([listModel.getBaseShopData(req.query, shopInfo), searchModel.getSearchData(searchParam)]).then(fResult => {
|
213
|
+ if (shopInfoResult && shopInfoResult.shop_template_type &&
|
|
|
214
|
+ parseInt(shopInfoResult.shop_template_type, 10) === 1) {
|
|
|
215
|
+ return Promise.all([
|
|
|
216
|
+ listModel.getBaseShopData(req.query, shopInfo),
|
|
|
217
|
+ searchModel.getSearchData(searchParam)
|
|
|
218
|
+ ]).then(fResult => {
|
189
|
let baseShop = fResult[0];
|
219
|
let baseShop = fResult[0];
|
190
|
let newGoods = fResult[1];
|
220
|
let newGoods = fResult[1];
|
191
|
|
221
|
|
|
@@ -205,8 +235,10 @@ const shop = { |
|
@@ -205,8 +235,10 @@ const shop = { |
205
|
showDownloadApp: true,
|
235
|
showDownloadApp: true,
|
206
|
pageFooter: true,
|
236
|
pageFooter: true,
|
207
|
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
|
237
|
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
|
208
|
- keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
|
|
|
209
|
- description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
238
|
+ keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' +
|
|
|
239
|
+ shopInfo.shop_name + '潮流服装服饰',
|
|
|
240
|
+ description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name +
|
|
|
241
|
+ '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
210
|
shopId: shopId,
|
242
|
shopId: shopId,
|
211
|
shopPage: true,
|
243
|
shopPage: true,
|
212
|
_noLazy: true,
|
244
|
_noLazy: true,
|
|
@@ -217,7 +249,10 @@ const shop = { |
|
@@ -217,7 +249,10 @@ const shop = { |
217
|
});
|
249
|
});
|
218
|
} else {
|
250
|
} else {
|
219
|
// 经典装修店铺
|
251
|
// 经典装修店铺
|
220
|
- return Promise.all([listModel.getShopDecorator(shopId).then(), listModel.getShopCategoryApi(shopId, channel)]).then(fResult => {
|
252
|
+ return Promise.all([
|
|
|
253
|
+ listModel.getShopDecorator(shopId).then(),
|
|
|
254
|
+ listModel.getShopCategoryApi(shopId, channel)
|
|
|
255
|
+ ]).then(fResult => {
|
221
|
|
256
|
|
222
|
let shopDeco = fResult[0];
|
257
|
let shopDeco = fResult[0];
|
223
|
let shopCategory = fResult[1];
|
258
|
let shopCategory = fResult[1];
|
|
@@ -230,7 +265,8 @@ const shop = { |
|
@@ -230,7 +265,8 @@ const shop = { |
230
|
|
265
|
|
231
|
let result = listModel.formShopData(shopData, shopId, isApp);
|
266
|
let result = listModel.formShopData(shopData, shopId, isApp);
|
232
|
|
267
|
|
233
|
- result = _.assign(result, pageHeader, {shopId: shopId, coverChannel: channel, seoResult: seoResult});
|
268
|
+ result = _.assign(result, pageHeader,
|
|
|
269
|
+ {shopId: shopId, coverChannel: channel, seoResult: seoResult});
|
234
|
|
270
|
|
235
|
res.render('newshop/shop-classics', {
|
271
|
res.render('newshop/shop-classics', {
|
236
|
module: 'product',
|
272
|
module: 'product',
|
|
@@ -349,28 +385,31 @@ const shop = { |
|
@@ -349,28 +385,31 @@ const shop = { |
349
|
banner, brand, introData, decoratorsData,
|
385
|
banner, brand, introData, decoratorsData,
|
350
|
time3: [0, 1, 2]
|
386
|
time3: [0, 1, 2]
|
351
|
});
|
387
|
});
|
352
|
- });
|
388
|
+ }).catch(next);
|
353
|
|
389
|
|
354
|
- }
|
|
|
355
|
-};
|
390
|
+ },
|
356
|
|
391
|
|
357
|
-/**
|
|
|
358
|
- * 从 useragent 获取 uid
|
|
|
359
|
- * @returns {*}
|
|
|
360
|
- * @private
|
|
|
361
|
- */
|
|
|
362
|
-const _getUidFromUserAgent = (req) => {
|
|
|
363
|
- let userAgent = _.split(req.headers['user-agent'], ';');
|
|
|
364
|
- let uidString = '';
|
392
|
+ /**
|
|
|
393
|
+ * 店铺全部品牌页面
|
|
|
394
|
+ */
|
|
|
395
|
+ allBrand(req, res, next) {
|
|
|
396
|
+ let shopId = req.query.shop_id;
|
365
|
|
397
|
|
366
|
- _.forEach(userAgent, value => {
|
|
|
367
|
- if (_.startsWith(value, 'uid')) {
|
|
|
368
|
- uidString = value;
|
|
|
369
|
- return;
|
398
|
+ if (!shopId) {
|
|
|
399
|
+ return next();
|
370
|
}
|
400
|
}
|
371
|
- });
|
|
|
372
|
|
401
|
|
373
|
- return _.split(uidString, '=')[1];
|
402
|
+ shopModel.getShopBrands(req.query.shop_id).then(result => {
|
|
|
403
|
+ res.render('newshop/all-brand', {
|
|
|
404
|
+ result: result,
|
|
|
405
|
+ pageHeader: headerModel.setNav({
|
|
|
406
|
+ navTitle: '品牌'
|
|
|
407
|
+ }),
|
|
|
408
|
+ module: 'product',
|
|
|
409
|
+ page: 'all-brand',
|
|
|
410
|
+ });
|
|
|
411
|
+ }).catch(next);
|
|
|
412
|
+ }
|
374
|
};
|
413
|
};
|
375
|
|
414
|
|
376
|
module.exports = shop; |
415
|
module.exports = shop; |