Authored by 周少峰

shop dec info

... ... @@ -6,11 +6,13 @@
'use strict';
const _ = require('lodash');
// const helpers = global.yoho.helpers;
const helpers = global.yoho.helpers;
// const queryString = require('querystring');
const newProductsName = '新品上架 NEW';
const hotProductsName = '人气单品 HOT';
const shopRecommentName = '经典推荐';
const shopListUrl = '/shoplist';
/**
... ... @@ -104,9 +106,9 @@ const goodsTabBar = (data, shopId) => {
const shopTopBanner = (data) => {
return {
shopTopBanner: {
banner: data[0]['shopSrc'] || '',
detailSrc: data[0]['detailSrc'] || '',
isShowShopName: data[0]['isShowShopName'] === 'Y'
banner: data[0].shopSrc || '',
detailSrc: data[0].detailSrc || '',
isShowShopName: data[0].isShowShopName === 'Y'
}
};
... ... @@ -144,6 +146,25 @@ const navigationBar = (data, shopId) => {
};
/**
* 资源位大图
* @param type $data
* @return type []
*/
const largeSlideImg = (data) => {
let dest = [];
console.log(data);
_.forEach(data, (value) => {
dest.push({
img: value.data[0].src,
url: helpers.urlFormat(value.data[0].url)
});
});
return {largeSlideImg: dest};
};
/**
* 资源位小图
* @param data 装修数据
* @returns {{}}
... ... @@ -153,24 +174,49 @@ const oneRowTwoColImages = (data) => {
_.forEach(data, (value) => {
dest.push({
img: value.data.src,
url: value.data.url
img: value.data[0].src,
url: helpers.urlFormat(value.data[0].url)
});
});
return {oneRowTwoColImages: dest};
};
return [
{
img: data[0]['data']['src'],
url: data[0]['data']['url']
},
{
img: data[1]['data']['src'],
url: data[1]['data']['url']
/**
* 经典推荐
* @param type $data
* @return type []
*/
const recommend = (data) => {
let dest = [];
_.forEach(data, (value) => {
dest.push({
enName: value.enName,
name: value.name,
img: value.src,
title: value.title,
url: helpers.urlFormat(value.url)
});
});
return {
recommend: {
title: dest[0].title || shopRecommentName,
list: dest
}
];
};
};
/**
* 品牌一览
* @param type $data
* @return type []
*/
// const brandBrowse = (params) => {
// };
/**
* 店铺装修楼层数据
* @param data 装修数据
* @returns {{}}
... ... @@ -182,6 +228,8 @@ exports.getShopDecorator = (data, params, shopId) => {
};
_.forEach(data.list, (value) => {
let tabBar;
switch (value.resource_name) {
case 'signboard':
break;
... ... @@ -192,8 +240,9 @@ exports.getShopDecorator = (data, params, shopId) => {
dest.hotSingle = hotProducts(JSON.parse(value.resource_data));
break;
case 'goodsTabBar':
Object.assign(dest.newArrivel, {navs: goodsTabBar(JSON.parse(value.resource_data))['new']});
Object.assign(dest.hotSingle, {navs: goodsTabBar(JSON.parse(value.resource_data))['hot']});
tabBar = goodsTabBar(JSON.parse(value.resource_data));
Object.assign(dest.newArrivel, {navs: tabBar.new});
Object.assign(dest.hotSingle, {navs: tabBar.hot});
break;
case 'shopTopBanner':
Object.assign(dest, shopTopBanner(JSON.parse(value.resource_data)));
... ... @@ -201,9 +250,15 @@ exports.getShopDecorator = (data, params, shopId) => {
case 'navigationBar':
Object.assign(dest, navigationBar(JSON.parse(value.resource_data), shopId));
break;
case 'largeSlideImg':
Object.assign(dest, largeSlideImg(JSON.parse(value.resource_data)));
break;
case 'oneRowTwoColImages':
Object.assign(dest, oneRowTwoColImages(JSON.parse(value.resource_data), shopId));
break;
case 'recommend':
Object.assign(dest, recommend(JSON.parse(value.resource_data), shopId));
break;
default:
break;
}
... ...