Authored by 周少峰

shop dec info

@@ -6,11 +6,13 @@ @@ -6,11 +6,13 @@
6 'use strict'; 6 'use strict';
7 const _ = require('lodash'); 7 const _ = require('lodash');
8 8
9 -// const helpers = global.yoho.helpers; 9 +const helpers = global.yoho.helpers;
  10 +
10 // const queryString = require('querystring'); 11 // const queryString = require('querystring');
11 12
12 const newProductsName = '新品上架 NEW'; 13 const newProductsName = '新品上架 NEW';
13 const hotProductsName = '人气单品 HOT'; 14 const hotProductsName = '人气单品 HOT';
  15 +const shopRecommentName = '经典推荐';
14 const shopListUrl = '/shoplist'; 16 const shopListUrl = '/shoplist';
15 17
16 /** 18 /**
@@ -104,9 +106,9 @@ const goodsTabBar = (data, shopId) => { @@ -104,9 +106,9 @@ const goodsTabBar = (data, shopId) => {
104 const shopTopBanner = (data) => { 106 const shopTopBanner = (data) => {
105 return { 107 return {
106 shopTopBanner: { 108 shopTopBanner: {
107 - banner: data[0]['shopSrc'] || '',  
108 - detailSrc: data[0]['detailSrc'] || '',  
109 - isShowShopName: data[0]['isShowShopName'] === 'Y' 109 + banner: data[0].shopSrc || '',
  110 + detailSrc: data[0].detailSrc || '',
  111 + isShowShopName: data[0].isShowShopName === 'Y'
110 } 112 }
111 }; 113 };
112 114
@@ -144,6 +146,25 @@ const navigationBar = (data, shopId) => { @@ -144,6 +146,25 @@ const navigationBar = (data, shopId) => {
144 }; 146 };
145 147
146 /** 148 /**
  149 + * 资源位大图
  150 + * @param type $data
  151 + * @return type []
  152 + */
  153 +const largeSlideImg = (data) => {
  154 + let dest = [];
  155 +
  156 + console.log(data);
  157 + _.forEach(data, (value) => {
  158 + dest.push({
  159 + img: value.data[0].src,
  160 + url: helpers.urlFormat(value.data[0].url)
  161 + });
  162 + });
  163 +
  164 + return {largeSlideImg: dest};
  165 +};
  166 +
  167 +/**
147 * 资源位小图 168 * 资源位小图
148 * @param data 装修数据 169 * @param data 装修数据
149 * @returns {{}} 170 * @returns {{}}
@@ -153,24 +174,49 @@ const oneRowTwoColImages = (data) => { @@ -153,24 +174,49 @@ const oneRowTwoColImages = (data) => {
153 174
154 _.forEach(data, (value) => { 175 _.forEach(data, (value) => {
155 dest.push({ 176 dest.push({
156 - img: value.data.src,  
157 - url: value.data.url 177 + img: value.data[0].src,
  178 + url: helpers.urlFormat(value.data[0].url)
158 }); 179 });
159 }); 180 });
  181 + return {oneRowTwoColImages: dest};
  182 +};
160 183
161 - return [  
162 - {  
163 - img: data[0]['data']['src'],  
164 - url: data[0]['data']['url']  
165 - },  
166 - {  
167 - img: data[1]['data']['src'],  
168 - url: data[1]['data']['url'] 184 +/**
  185 + * 经典推荐
  186 + * @param type $data
  187 + * @return type []
  188 + */
  189 +const recommend = (data) => {
  190 + let dest = [];
  191 +
  192 + _.forEach(data, (value) => {
  193 + dest.push({
  194 + enName: value.enName,
  195 + name: value.name,
  196 + img: value.src,
  197 + title: value.title,
  198 + url: helpers.urlFormat(value.url)
  199 + });
  200 + });
  201 +
  202 + return {
  203 + recommend: {
  204 + title: dest[0].title || shopRecommentName,
  205 + list: dest
169 } 206 }
170 - ]; 207 + };
171 }; 208 };
172 209
173 /** 210 /**
  211 + * 品牌一览
  212 + * @param type $data
  213 + * @return type []
  214 + */
  215 +// const brandBrowse = (params) => {
  216 +
  217 +// };
  218 +
  219 +/**
174 * 店铺装修楼层数据 220 * 店铺装修楼层数据
175 * @param data 装修数据 221 * @param data 装修数据
176 * @returns {{}} 222 * @returns {{}}
@@ -182,6 +228,8 @@ exports.getShopDecorator = (data, params, shopId) => { @@ -182,6 +228,8 @@ exports.getShopDecorator = (data, params, shopId) => {
182 }; 228 };
183 229
184 _.forEach(data.list, (value) => { 230 _.forEach(data.list, (value) => {
  231 + let tabBar;
  232 +
185 switch (value.resource_name) { 233 switch (value.resource_name) {
186 case 'signboard': 234 case 'signboard':
187 break; 235 break;
@@ -192,8 +240,9 @@ exports.getShopDecorator = (data, params, shopId) => { @@ -192,8 +240,9 @@ exports.getShopDecorator = (data, params, shopId) => {
192 dest.hotSingle = hotProducts(JSON.parse(value.resource_data)); 240 dest.hotSingle = hotProducts(JSON.parse(value.resource_data));
193 break; 241 break;
194 case 'goodsTabBar': 242 case 'goodsTabBar':
195 - Object.assign(dest.newArrivel, {navs: goodsTabBar(JSON.parse(value.resource_data))['new']});  
196 - Object.assign(dest.hotSingle, {navs: goodsTabBar(JSON.parse(value.resource_data))['hot']}); 243 + tabBar = goodsTabBar(JSON.parse(value.resource_data));
  244 + Object.assign(dest.newArrivel, {navs: tabBar.new});
  245 + Object.assign(dest.hotSingle, {navs: tabBar.hot});
197 break; 246 break;
198 case 'shopTopBanner': 247 case 'shopTopBanner':
199 Object.assign(dest, shopTopBanner(JSON.parse(value.resource_data))); 248 Object.assign(dest, shopTopBanner(JSON.parse(value.resource_data)));
@@ -201,9 +250,15 @@ exports.getShopDecorator = (data, params, shopId) => { @@ -201,9 +250,15 @@ exports.getShopDecorator = (data, params, shopId) => {
201 case 'navigationBar': 250 case 'navigationBar':
202 Object.assign(dest, navigationBar(JSON.parse(value.resource_data), shopId)); 251 Object.assign(dest, navigationBar(JSON.parse(value.resource_data), shopId));
203 break; 252 break;
  253 + case 'largeSlideImg':
  254 + Object.assign(dest, largeSlideImg(JSON.parse(value.resource_data)));
  255 + break;
204 case 'oneRowTwoColImages': 256 case 'oneRowTwoColImages':
205 Object.assign(dest, oneRowTwoColImages(JSON.parse(value.resource_data), shopId)); 257 Object.assign(dest, oneRowTwoColImages(JSON.parse(value.resource_data), shopId));
206 break; 258 break;
  259 + case 'recommend':
  260 + Object.assign(dest, recommend(JSON.parse(value.resource_data), shopId));
  261 + break;
207 default: 262 default:
208 break; 263 break;
209 } 264 }