Authored by 郭成尧

'base-shop-banner-show'

... ... @@ -15,44 +15,22 @@ const helpers = global.yoho.helpers;
* 店铺基础模板
*/
const _baseShop = (req, res, data) => {
let params = Object.assign({
cartUrl: helpers.urlFormat('/cart/index/index')
}, req.query);
Promise.all([listModel.getShopDecorator(data.shopsId), listModel.getShopBrands(data.shopsId)]).then((result) => {
result[0] = result[0] || {};
_.forEach(result[0], (item) => {
if (item.resourceName === 'shopTopBanner_base') {
let banner = JSON.parse(item.resourceData);
params = _.assign({
shopBanner: {
banner: banner[0].shopSrc
}
}, params);
}
});
if (data.multBrandShopType === '2') {
// 转义店铺
params.shop_id = data.shopsId;
} else {
params.brand = result[1];
}
listModel.getBaseShopData(Object.assign(req.query, data)).then(result => {
res.render('search/goods-list', {
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: data.shopName
navTitle: result.shopName
}),
title: data.shopName,
goodList: params,
title: result.shopName,
goodList: result,
showDownloadApp: true,
pageFooter: true
});
});
};
/**
... ... @@ -88,7 +66,7 @@ const _shop = (req, res, shopId) => {
}
listModel.getShopData(req, shopId, uid, isApp).then((result) => {
if (result.goBrand) {
if (true) {
// 跳转基础模板
_baseShop(req, res, result.goBrand);
} else {
... ...
... ... @@ -365,7 +365,45 @@ const _formShopData = (data, shopId, isApp) => {
};
/**
* 新店铺首页
* 使用基础模板的店铺首页
* @param params
* @returns {*|Promise.<TResult>}
*/
const getBaseShopData = (params) => {
let finalResult = {
cartUrl: helpers.urlFormat('/cart/index/index')
};
return api.all([
_getShopDecorator(params.shop_id),
getShopBrands(params.shop_id)
]).then(result => {
result[0] = result[0] || {};
_.forEach(result[0].list, item => {
if (item.resourceName === 'shopTopBanner_base') {
let banner = JSON.parse(item.resourceData);
finalResult = _.assign(finalResult, {
shopBanner: {
banner: banner[0].shopSrc
}
});
}
});
if (params.multBrandShopType === '2') {
// 转义店铺
finalResult.shop_id = params.shop_id;
} else {
finalResult.brand = result[1];
}
return finalResult;
});
};
/**
* 使用经典模板的店铺首页
* @param {object} req
* @param {int} shopId 店铺id
* @param {int} uid 用户id
... ... @@ -397,7 +435,7 @@ const getShopData = (req, shopId, uid, isApp) => {
};
// 店铺使用基础模板,返回品牌页面
if (shopData.shopInfo.shopTemplateType && shopData.shopInfo.shopTemplateType === '1') {
if (shopData.shopInfo.shopTemplateType && parseInt(shopData.shopInfo.shopTemplateType, 10) === 1) {
return {
goBrand: shopData.shopInfo
};
... ... @@ -607,6 +645,7 @@ const getShopBrands = (shopId) => {
module.exports = {
getBaseShopData,
getShopData,
getBrandLogoByDomain,
getBrandIntro,
... ...