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,44 +441,47 @@ const getShopData = (req, shopId, uid, isApp) => {
let shopData = {};
let channel = req.yoho.channel;
return Promise.all([
_getShopDecorator(shopId),
_getShopInfo(shopId, uid),
searchModel.getFilterData({
shop_id: shopId,
gender: '1,3', // TODO TAR 获取性别
channel: channel,
brand: '' // TODO TAR 获取品牌
}),
searchModel.getSearchData({
shop_id: shopId,
gender: '1,3', // TODO TAR 获取性别
channel: channel,
brand: '' // TODO TAR 获取品牌
})
]).then((result) => {
shopData = {
decorator: result[0], // 店铺装修资源数据
shopInfo: result[1] // 店铺信息
};
return _getShopInfo(shopId, uid).then(shopInfoResult => {
// 店铺使用基础模板,返回品牌页面
if (shopData.shopInfo.shopTemplateType && parseInt(shopData.shopInfo.shopTemplateType, 10) === 1) {
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult.shopTemplateType && parseInt(shopInfoResult.shopTemplateType, 10) === 1) {
return {
goBrand: shopData.shopInfo
goBrand: shopInfoResult
};
}
// 店铺分类
return _getShopCategory(shopId, channel).then((shopCategory) => {
shopData = _.assign({
shopCategory: shopCategory
}, shopData);
return Promise.all([
_getShopDecorator(shopId),
searchModel.getFilterData({
shop_id: shopId,
gender: '1,3', // TODO TAR 获取性别
channel: channel,
brand: '' // TODO TAR 获取品牌
}),
searchModel.getSearchData({
shop_id: shopId,
gender: '1,3', // TODO TAR 获取性别
channel: channel,
brand: '' // TODO TAR 获取品牌
})
]).then((result) => {
shopData = {
decorator: result[0], // 店铺装修资源数据
shopInfo: shopInfoResult // 店铺信息
};
// 店铺分类
return _getShopCategory(shopId, channel).then((shopCategory) => {
shopData = _.assign({
shopCategory: shopCategory
}, shopData);
// noinspection JSCheckFunctionSignatures
return Object.assign(_formShopData(shopData, shopId, isApp),
{filter: result[2]}, {goods: result[3]}); // TODO TAR 获取筛选数据和商品数据数据校验
// noinspection JSCheckFunctionSignatures
return Object.assign(_formShopData(shopData, shopId, isApp),
{filter: result[2]}, {goods: result[3]}); // TODO TAR 获取筛选数据和商品数据数据校验
});
});
});
};
... ...