...
|
...
|
@@ -6,6 +6,7 @@ |
|
|
const mRoot = '../models';
|
|
|
const utils = '../../../utils';
|
|
|
const listModel = require(`${mRoot}/list`);
|
|
|
const shopModel = require(`${mRoot}/shop`);
|
|
|
const searchModel = require(`${mRoot}/search`);
|
|
|
const redsShopModel = require(`${mRoot}/popular-shop`);
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
...
|
...
|
@@ -14,6 +15,25 @@ const helpers = global.yoho.helpers; |
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 从 useragent 获取 uid
|
|
|
* @returns {*}
|
|
|
* @private
|
|
|
*/
|
|
|
const _getUidFromUserAgent = (req) => {
|
|
|
let userAgent = _.split(req.headers['user-agent'], ';');
|
|
|
let uidString = '';
|
|
|
|
|
|
_.forEach(userAgent, value => {
|
|
|
if (_.startsWith(value, 'uid')) {
|
|
|
uidString = value;
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return _.split(uidString, '=')[1];
|
|
|
};
|
|
|
|
|
|
const shop = {
|
|
|
index(req, res, next) {
|
|
|
let params = Object.assign({}, req.query);
|
...
|
...
|
@@ -66,7 +86,10 @@ const shop = { |
|
|
shop.shop(req, res, next);
|
|
|
return false;
|
|
|
} else if (req.query.from === 'search') {
|
|
|
return Promise.all([listModel.getBrandShops(brandId, req), searchModel.getSearchData(searchParam)]).then(shopResult => {
|
|
|
return Promise.all([
|
|
|
listModel.getBrandShops(brandId, req),
|
|
|
searchModel.getSearchData(searchParam)
|
|
|
]).then(shopResult => {
|
|
|
let brandShop = shopResult[0];
|
|
|
let newGoods = shopResult[1];
|
|
|
|
...
|
...
|
@@ -105,7 +128,10 @@ const shop = { |
|
|
title: result.name,
|
|
|
id: result.id
|
|
|
};
|
|
|
return Promise.all([listModel.getBrandBanner(brandId), searchModel.getSearchData(searchParam)]).then(brandResult => {
|
|
|
return Promise.all([
|
|
|
listModel.getBrandBanner(brandId),
|
|
|
searchModel.getSearchData(searchParam)
|
|
|
]).then(brandResult => {
|
|
|
let brandBanner = brandResult[0];
|
|
|
let newGoods = brandResult[1];
|
|
|
|
...
|
...
|
@@ -193,8 +219,12 @@ const shop = { |
|
|
}
|
|
|
|
|
|
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
|
|
|
if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
|
|
|
return Promise.all([listModel.getBaseShopData(req.query, shopInfo), searchModel.getSearchData(searchParam)]).then(fResult => {
|
|
|
if (shopInfoResult && shopInfoResult.shop_template_type &&
|
|
|
parseInt(shopInfoResult.shop_template_type, 10) === 1) {
|
|
|
return Promise.all([
|
|
|
listModel.getBaseShopData(req.query, shopInfo),
|
|
|
searchModel.getSearchData(searchParam)
|
|
|
]).then(fResult => {
|
|
|
let baseShop = fResult[0];
|
|
|
let newGoods = fResult[1];
|
|
|
|
...
|
...
|
@@ -214,8 +244,10 @@ const shop = { |
|
|
showDownloadApp: true,
|
|
|
pageFooter: true,
|
|
|
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
|
|
|
keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
|
|
|
description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
|
|
keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' +
|
|
|
shopInfo.shop_name + '潮流服装服饰',
|
|
|
description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name +
|
|
|
'潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
|
|
shopId: shopId,
|
|
|
shopPage: true,
|
|
|
_noLazy: true,
|
...
|
...
|
@@ -226,7 +258,10 @@ const shop = { |
|
|
});
|
|
|
} else {
|
|
|
// 经典装修店铺
|
|
|
return Promise.all([listModel.getShopDecorator(shopId).then(), listModel.getShopCategoryApi(shopId, channel)]).then(fResult => {
|
|
|
return Promise.all([
|
|
|
listModel.getShopDecorator(shopId).then(),
|
|
|
listModel.getShopCategoryApi(shopId, channel)
|
|
|
]).then(fResult => {
|
|
|
|
|
|
let shopDeco = fResult[0];
|
|
|
let shopCategory = fResult[1];
|
...
|
...
|
@@ -239,7 +274,8 @@ const shop = { |
|
|
|
|
|
let result = listModel.formShopData(shopData, shopId, isApp);
|
|
|
|
|
|
result = _.assign(result, pageHeader, {shopId: shopId, coverChannel: channel, seoResult: seoResult});
|
|
|
result = _.assign(result, pageHeader,
|
|
|
{shopId: shopId, coverChannel: channel, seoResult: seoResult});
|
|
|
|
|
|
res.render('newshop/shop-classics', {
|
|
|
module: 'product',
|
...
|
...
|
@@ -358,28 +394,31 @@ const shop = { |
|
|
banner, brand, introData, decoratorsData,
|
|
|
time3: [0, 1, 2]
|
|
|
});
|
|
|
});
|
|
|
}).catch(next);
|
|
|
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 从 useragent 获取 uid
|
|
|
* @returns {*}
|
|
|
* @private
|
|
|
*/
|
|
|
const _getUidFromUserAgent = (req) => {
|
|
|
let userAgent = _.split(req.headers['user-agent'], ';');
|
|
|
let uidString = '';
|
|
|
/**
|
|
|
* 店铺全部品牌页面
|
|
|
*/
|
|
|
allBrand(req, res, next) {
|
|
|
let shopId = req.query.shop_id;
|
|
|
|
|
|
_.forEach(userAgent, value => {
|
|
|
if (_.startsWith(value, 'uid')) {
|
|
|
uidString = value;
|
|
|
return;
|
|
|
if (!shopId) {
|
|
|
return next();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return _.split(uidString, '=')[1];
|
|
|
shopModel.getShopBrands(req.query.shop_id).then(result => {
|
|
|
res.render('newshop/all-brand', {
|
|
|
result: result,
|
|
|
pageHeader: headerModel.setNav({
|
|
|
navTitle: '品牌'
|
|
|
}),
|
|
|
module: 'product',
|
|
|
page: 'all-brand',
|
|
|
});
|
|
|
}).catch(next);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = shop; |
...
|
...
|
|