Authored by 郭成尧

'shop-use-api-modified'

... ... @@ -14,9 +14,9 @@ const helpers = global.yoho.helpers;
/**
* 店铺基础模板
*/
const _baseShop = (req, res, data) => {
const _baseShop = (req, res, shopInfo) => {
listModel.getBaseShopData(Object.assign(req.query, data)).then(result => {
listModel.getBaseShopData(req.query, shopInfo).then(result => {
res.render('search/goods-list', {
module: 'product',
... ... @@ -65,7 +65,7 @@ const _shop = (req, res, shopId) => {
});
}
listModel.getShopData(req, shopId, uid, isApp).then((result) => {
listModel.getShopData(req, shopId, uid, isApp).then(result => {
if (result.goBrand) {
// 跳转基础模板
... ...
... ... @@ -310,6 +310,7 @@ const _formShopData = (data, shopId, isApp) => {
};
formatData = _.assign({
shopIntro: data.shopInfo.shopIntro,
logoImg: data.shopInfo.shopLogo,
storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '',
collect: data.shopInfo.isFavorite === 'Y',
... ... @@ -387,9 +388,11 @@ const _formShopData = (data, shopId, isApp) => {
/**
* 使用基础模板的店铺首页
* @param params
* @param shopInfo
* @returns {*|Promise.<TResult>}
*/
const getBaseShopData = (params) => {
const getBaseShopData = (params, shopInfo) => {
let finalResult = {
cartUrl: helpers.urlFormat('/cart/index/index')
};
... ... @@ -406,7 +409,11 @@ const getBaseShopData = (params) => {
finalResult = _.assign(finalResult, {
baseShopHome: {
banner: _.get(banner, 'banner[0].shopSrc', '')
appVersion: _.get(params, 'app_version', ''),
id: params.shop_id,
intro: shopInfo.shopIntro,
isBaseShop: true,
banner: _.get(banner[0], 'shopSrc', '')
}
});
}
... ... @@ -434,9 +441,17 @@ const getShopData = (req, shopId, uid, isApp) => {
let shopData = {};
let channel = req.yoho.channel;
return _getShopInfo(shopId, uid).then(shopInfoResult => {
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult.shopTemplateType && parseInt(shopInfoResult.shopTemplateType, 10) === 1) {
return {
goBrand: shopInfoResult
};
}
return Promise.all([
_getShopDecorator(shopId),
_getShopInfo(shopId, uid),
searchModel.getFilterData({
shop_id: shopId,
gender: '1,3', // TODO TAR 获取性别
... ... @@ -452,16 +467,9 @@ const getShopData = (req, shopId, uid, isApp) => {
]).then((result) => {
shopData = {
decorator: result[0], // 店铺装修资源数据
shopInfo: result[1] // 店铺信息
shopInfo: shopInfoResult // 店铺信息
};
// 店铺使用基础模板,返回品牌页面
if (shopData.shopInfo.shopTemplateType && parseInt(shopData.shopInfo.shopTemplateType, 10) === 1) {
return {
goBrand: shopData.shopInfo
};
}
// 店铺分类
return _getShopCategory(shopId, channel).then((shopCategory) => {
shopData = _.assign({
... ... @@ -473,6 +481,8 @@ const getShopData = (req, shopId, uid, isApp) => {
{filter: result[2]}, {goods: result[3]}); // TODO TAR 获取筛选数据和商品数据数据校验
});
});
});
};
/**
... ...