Authored by yyq

店铺首页

@@ -80,16 +80,17 @@ exports.brand = (req, res, next) => { @@ -80,16 +80,17 @@ exports.brand = (req, res, next) => {
80 80
81 // req.shopId存在,直接走店铺 81 // req.shopId存在,直接走店铺
82 if (req.shopId) { 82 if (req.shopId) {
83 - shop(req.shopId, req, res, next); 83 + return shop(req.shopId, req, res, next);
84 } 84 }
  85 + let brandDomain = 'colormad';
85 86
86 - let brandDomain = req.brandDomain || 'colormad'; 87 + // let brandDomain = req.brandDomain || 'shop$15';
87 88
88 // 获取品牌信息 89 // 获取品牌信息
89 list.getBrandInfo({domain: brandDomain}).then(brandInfo => { 90 list.getBrandInfo({domain: brandDomain}).then(brandInfo => {
90 91
91 // brandInfo.type = 2; 92 // brandInfo.type = 2;
92 - // brandInfo.shopId = 746; 93 + // brandInfo.shopId = 15;
93 switch (parseInt(brandInfo.type, 10)) { 94 switch (parseInt(brandInfo.type, 10)) {
94 case 1: 95 case 1:
95 // 搜索 96 // 搜索
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 5
6 'use strict'; 6 'use strict';
7 const utils = '../../../utils'; 7 const utils = '../../../utils';
8 -const api = global.yoho.API;  
9 const searchApi = require('./search-api'); 8 const searchApi = require('./search-api');
10 const headerModel = require('../../../doraemon/models/header'); 9 const headerModel = require('../../../doraemon/models/header');
11 const productProcess = require(`${utils}/product-process`); 10 const productProcess = require(`${utils}/product-process`);
@@ -46,7 +45,7 @@ exports.getListData = (params) => { @@ -46,7 +45,7 @@ exports.getListData = (params) => {
46 apiMethod.push(searchApi.getSortAds(Object.assign(IntroParams, {position_id: sortAdsId}))); 45 apiMethod.push(searchApi.getSortAds(Object.assign(IntroParams, {position_id: sortAdsId})));
47 } 46 }
48 47
49 - return api.all(apiMethod).then(result => { 48 + return Promise.all(apiMethod).then(result => {
50 let finalResult = { 49 let finalResult = {
51 headerData: Object.assign(result[0].headerData, { 50 headerData: Object.assign(result[0].headerData, {
52 header: true 51 header: true
@@ -102,7 +101,7 @@ exports.getListNewData = (params) => { @@ -102,7 +101,7 @@ exports.getListNewData = (params) => {
102 searchApi.getWeekNew(params) 101 searchApi.getWeekNew(params)
103 ]; 102 ];
104 103
105 - return api.all(apiMethod).then(result => { 104 + return Promise.all(apiMethod).then(result => {
106 let finalResult = { 105 let finalResult = {
107 headerData: Object.assign(result[0].headerData, { 106 headerData: Object.assign(result[0].headerData, {
108 header: true 107 header: true
@@ -185,7 +184,7 @@ exports.getBrandData = (params, extra) => { @@ -185,7 +184,7 @@ exports.getBrandData = (params, extra) => {
185 184
186 ]; 185 ];
187 186
188 - return api.all(apiMethod).then(result => { 187 + return Promise.all(apiMethod).then(result => {
189 let finalResult = { 188 let finalResult = {
190 headerData: Object.assign(result[0].headerData, { 189 headerData: Object.assign(result[0].headerData, {
191 header: true 190 header: true
@@ -241,7 +240,7 @@ exports.getNodeContentData = (params) => { @@ -241,7 +240,7 @@ exports.getNodeContentData = (params) => {
241 */ 240 */
242 exports.getAdnav = (params) => { 241 exports.getAdnav = (params) => {
243 242
244 - return api.all([searchApi.getBrandFolder(params), searchApi.getBrandSeries(params)]).then(result => { 243 + return Promise.all([searchApi.getBrandFolder(params), searchApi.getBrandSeries(params)]).then(result => {
245 244
246 let dest = { 245 let dest = {
247 picTitle: '', 246 picTitle: '',
@@ -296,6 +295,8 @@ exports.getShopInfo = (shopId, uid) => { @@ -296,6 +295,8 @@ exports.getShopInfo = (shopId, uid) => {
296 * @param shopInfo 店铺介绍 295 * @param shopInfo 店铺介绍
297 */ 296 */
298 exports.getShopData = (shopId, uid, params, shopInfo) => { 297 exports.getShopData = (shopId, uid, params, shopInfo) => {
  298 + params = params || {};
  299 + params.shopId = shopId;
299 300
300 // 店铺所有品牌 301 // 店铺所有品牌
301 return searchApi.getShopBrands(shopId).then(shopBrands => { 302 return searchApi.getShopBrands(shopId).then(shopBrands => {
@@ -336,16 +337,16 @@ exports.getShopData = (shopId, uid, params, shopInfo) => { @@ -336,16 +337,16 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
336 }); 337 });
337 338
338 // 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类) 339 // 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
339 - // apiMethod.push(  
340 - // // 店铺分类  
341 - // searchApi.getSortList({brand: shopBrandIds})  
342 - // ); 340 + apiMethod.push(
  341 +
  342 + // 店铺分类
  343 + searchApi.getSortList({brand: shopBrandIds})
  344 + );
343 345
344 // apiMethod 添加调用相关文章的接口 346 // apiMethod 添加调用相关文章的接口
345 apiMethod = _.concat(apiMethod, articleApiMethod); 347 apiMethod = _.concat(apiMethod, articleApiMethod);
346 348
347 - return api.all(apiMethod).then(result => {  
348 - 349 + return Promise.all(apiMethod).then(result => {
349 let finalResult = { 350 let finalResult = {
350 headerData: Object.assign(result[0].headerData, {header: true}), 351 headerData: Object.assign(result[0].headerData, {header: true}),
351 pathNav: searchHandler.handlePathNavData(shopInfo, params, 'shop') 352 pathNav: searchHandler.handlePathNavData(shopInfo, params, 'shop')
@@ -363,6 +364,8 @@ exports.getShopData = (shopId, uid, params, shopInfo) => { @@ -363,6 +364,8 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
363 return Promise.reject('No ShopDecorator data'); 364 return Promise.reject('No ShopDecorator data');
364 } 365 }
365 366
  367 +
  368 +
366 // // 获取左侧类目数据 369 // // 获取左侧类目数据
367 // if (result[1].code === 200) { 370 // if (result[1].code === 200) {
368 // Object.assign(finalResult.shop, { 371 // Object.assign(finalResult.shop, {
@@ -377,16 +380,28 @@ exports.getShopData = (shopId, uid, params, shopInfo) => { @@ -377,16 +380,28 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
377 // } 380 // }
378 381
379 // 获取商品数据和顶部筛选条件 382 // 获取商品数据和顶部筛选条件
380 - // if (result[2].code === 200) {  
381 - // Object.assign(finalResult.shop, {  
382 - // filters: searchHandler.handleFilterData(result[2].data.filter, params),  
383 - // opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),  
384 - // totalCount: result[2].data.total,  
385 - // footPager: searchHandler.handlePagerData(result[2].data.total, params),  
386 - // goods: productProcess.processProductList(result[2].data.product_list,  
387 - // Object.assign({showDiscount: false}, params))  
388 - // });  
389 - // } 383 + if (result[2].code === 200) {
  384 + let allGoods = {
  385 + name: '全部商品 ALL',
  386 + sort: searchHandler.handleOptsData(params, _.get(result[2], 'data.total', 0)),
  387 + list: productProcess.processProductList(_.get(result[2], 'data.product_list', []))
  388 + };
  389 +
  390 + _.set(allGoods, 'sort.newPage', true); // 启用新的分页导航
  391 +
  392 + finalResult.allGoods = allGoods;
  393 + }
  394 +
  395 + if (result[3].code === 200) {
  396 + let groupSort = _.get(result[3], 'data.filter.group_sort', []);
  397 +
  398 + finalResult.leftContent = searchHandler.handleSortData(groupSort, params);
  399 +
  400 + if (finalResult.allGoods) {
  401 + Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, params));
  402 + }
  403 + }
  404 +
390 return finalResult; 405 return finalResult;
391 }); 406 });
392 407
@@ -45,9 +45,12 @@ const getProductList = (params) => { @@ -45,9 +45,12 @@ const getProductList = (params) => {
45 */ 45 */
46 const getSortList = (params) => { 46 const getSortList = (params) => {
47 let finalParams = { 47 let finalParams = {
48 - method: 'web.regular.groupsort' 48 + method: 'app.search.li',
49 49
50 - // method: 'app.search.li' 50 + // method: 'web.regular.groupsort',
  51 + sales: 'Y', // 在销售商品分类
  52 + status: 1, // 上架商品分类
  53 + stocknumber: 1 // 过滤掉已售罄
51 }; 54 };
52 55
53 Object.assign(finalParams, params); 56 Object.assign(finalParams, params);
@@ -176,7 +176,7 @@ exports.handleOptsData = (params, total, extra) => { @@ -176,7 +176,7 @@ exports.handleOptsData = (params, total, extra) => {
176 176
177 switch (i) { 177 switch (i) {
178 case 0: 178 case 0:
179 - opt.href = handleFilterUrl(params, {order: 's_t_desc'}); 179 + opt.href = handleFilterUrl(params, {order: ''});
180 if (extra === 'discont') { // 如果是折扣专场 180 if (extra === 'discont') { // 如果是折扣专场
181 opt.name = '全部'; 181 opt.name = '全部';
182 if (_.isEmpty(params.order) || params.order === 's_t_desc') { 182 if (_.isEmpty(params.order) || params.order === 's_t_desc') {
@@ -186,13 +186,11 @@ exports.handleOptsData = (params, total, extra) => { @@ -186,13 +186,11 @@ exports.handleOptsData = (params, total, extra) => {
186 } 186 }
187 } else { 187 } else {
188 opt.name = '默认'; 188 opt.name = '默认';
189 - opt.hasSortOrient = true;  
190 if (_.isEmpty(params.order) || params.order === 's_n_desc') { 189 if (_.isEmpty(params.order) || params.order === 's_n_desc') {
191 opt.active = true; 190 opt.active = true;
192 } else { 191 } else {
193 opt.active = false; 192 opt.active = false;
194 } 193 }
195 - opt.desc = true;  
196 } 194 }
197 break; 195 break;
198 case 1: 196 case 1:
@@ -306,6 +304,7 @@ exports.handleOptsData = (params, total, extra) => { @@ -306,6 +304,7 @@ exports.handleOptsData = (params, total, extra) => {
306 total : parseInt(dest.start, 10) + paramsLimit - 1; 304 total : parseInt(dest.start, 10) + paramsLimit - 1;
307 } 305 }
308 306
  307 + if (extra) {
309 // 新品 308 // 新品
310 if (extra.new === 'Y') { 309 if (extra.new === 'Y') {
311 dest.checks.push(hadleChecks('new', params)); 310 dest.checks.push(hadleChecks('new', params));
@@ -320,6 +319,7 @@ exports.handleOptsData = (params, total, extra) => { @@ -320,6 +319,7 @@ exports.handleOptsData = (params, total, extra) => {
320 if (extra.limited === 'Y') { 319 if (extra.limited === 'Y') {
321 dest.checks.push(hadleChecks('limited', params)); 320 dest.checks.push(hadleChecks('limited', params));
322 } 321 }
  322 + }
323 return dest; 323 return dest;
324 }; 324 };
325 325
@@ -342,7 +342,7 @@ exports.handleSortData = (origin, params) => { @@ -342,7 +342,7 @@ exports.handleSortData = (origin, params) => {
342 num: value.count, 342 num: value.count,
343 childList: [ 343 childList: [
344 { 344 {
345 - name: '全部' + value.sort_name, 345 + name: `全部${value.sort_name}`,
346 num: value.count, 346 num: value.count,
347 href: handleFilterUrl(params, {msort: value.sort_id}), 347 href: handleFilterUrl(params, {msort: value.sort_id}),
348 childActive: params.misort === value.sort_id 348 childActive: params.misort === value.sort_id
@@ -372,6 +372,35 @@ exports.handleSortData = (origin, params) => { @@ -372,6 +372,35 @@ exports.handleSortData = (origin, params) => {
372 }; 372 };
373 373
374 /** 374 /**
  375 + * 店铺品类聚合
  376 + * @param data 分类数据
  377 + * @returns {{}}
  378 + */
  379 +exports.setShopSort = (data, params) => {
  380 + let resData = {};
  381 +
  382 + if (!_.isEmpty(data)) {
  383 + let list = [];
  384 +
  385 + _.forEach(data, value => {
  386 + _.forEach(value.sub, subValue => {
  387 + list.push({
  388 + name: subValue.sort_name,
  389 + href: handleFilterUrl(params, {msort: value.sort_id, misort: subValue.sort_id}),
  390 + curMenu: params.misort === subValue.sort_id
  391 + });
  392 + });
  393 + });
  394 +
  395 + if (list.length) {
  396 + _.set(resData, 'goodsMenu.menuList', list);
  397 + }
  398 + }
  399 +
  400 + return resData;
  401 +};
  402 +
  403 +/**
375 * 处理一般筛选数据 404 * 处理一般筛选数据
376 * @param origin 要处理的筛选数据 filter 405 * @param origin 要处理的筛选数据 filter
377 * @param params 当前 URL 中已有的参数,处理选中状态使用 406 * @param params 当前 URL 中已有的参数,处理选中状态使用
@@ -19,11 +19,13 @@ const shopListUrl = '/shoplist'; @@ -19,11 +19,13 @@ const shopListUrl = '/shoplist';
19 * 新品上架 19 * 新品上架
20 */ 20 */
21 const newProducts = (data) => { 21 const newProducts = (data) => {
22 - let dest = { 22 + let dest = {};
  23 +
  24 + if (!_.isEmpty(data)) {
  25 + Object.assign(dest, {
23 name: newProductsName, 26 name: newProductsName,
24 list: [] 27 list: []
25 - };  
26 - 28 + });
27 _.forEach(data, (value) => { 29 _.forEach(data, (value) => {
28 30
29 dest.list.push({ 31 dest.list.push({
@@ -36,6 +38,8 @@ const newProducts = (data) => { @@ -36,6 +38,8 @@ const newProducts = (data) => {
36 // url: helpers.getProductUrl(value.productId, value.productSkn, value.productName) 38 // url: helpers.getProductUrl(value.productId, value.productSkn, value.productName)
37 }); 39 });
38 }); 40 });
  41 + }
  42 +
39 return dest; 43 return dest;
40 }; 44 };
41 45
@@ -153,7 +157,6 @@ const navigationBar = (data, shopId) => { @@ -153,7 +157,6 @@ const navigationBar = (data, shopId) => {
153 const largeSlideImg = (data) => { 157 const largeSlideImg = (data) => {
154 let dest = []; 158 let dest = [];
155 159
156 - console.log(data);  
157 _.forEach(data, (value) => { 160 _.forEach(data, (value) => {
158 dest.push({ 161 dest.push({
159 img: value.data[0].src, 162 img: value.data[0].src,
@@ -221,7 +224,7 @@ const brandBrowse = (data, params) => { @@ -221,7 +224,7 @@ const brandBrowse = (data, params) => {
221 224
222 _.forEach(data, value => { 225 _.forEach(data, value => {
223 list.push({ 226 list.push({
224 - url: helpers.urlFormat('/shoplist', { 227 + url: helpers.urlFormat(shopListUrl, {
225 shopId: _.get(params, 'shopId', ''), 228 shopId: _.get(params, 'shopId', ''),
226 brand: value.id, 229 brand: value.id,
227 navBar: 1 230 navBar: 1
@@ -288,10 +291,10 @@ exports.getShopDecorator = (data, params, shopId) => { @@ -288,10 +291,10 @@ exports.getShopDecorator = (data, params, shopId) => {
288 case 'signboard': 291 case 'signboard':
289 break; 292 break;
290 case 'newProducts': 293 case 'newProducts':
291 - dest.newArrivel = newProducts(info); 294 + Object.assign(dest.newArrivel, newProducts(info));
292 break; 295 break;
293 case 'hotProducts': 296 case 'hotProducts':
294 - dest.hotSingle = hotProducts(info); 297 + Object.assign(dest.hotSingle, hotProducts(info));
295 break; 298 break;
296 case 'goodsTabBar': 299 case 'goodsTabBar':
297 tabBar = goodsTabBar(info); 300 tabBar = goodsTabBar(info);
@@ -324,7 +327,5 @@ exports.getShopDecorator = (data, params, shopId) => { @@ -324,7 +327,5 @@ exports.getShopDecorator = (data, params, shopId) => {
324 } 327 }
325 }); 328 });
326 329
327 - // console.log(dest);  
328 return dest; 330 return dest;
329 }; 331 };
330 -  
1 -  
2 <div class="shop-index-page product-list-page product-page yoho-page center-content home-page"> 1 <div class="shop-index-page product-list-page product-page yoho-page center-content home-page">
3 <div class="center-content clearfix"> 2 <div class="center-content clearfix">
4 {{> common/path-nav}} 3 {{> common/path-nav}}
@@ -54,7 +53,7 @@ @@ -54,7 +53,7 @@
54 {{> index/floor-header}} 53 {{> index/floor-header}}
55 54
56 <div class="goods-wrap"> 55 <div class="goods-wrap">
57 - {{> product/goods-list}} 56 + {{> list/shop-list}}
58 </div> 57 </div>
59 58
60 <div class="loading"> 59 <div class="loading">
  1 +<div class="fixed-area">
  2 +{{# goodsMenu}}
  3 + <div class="all-goods-menu">
  4 + <span class="menu-tag">所有商品</span>
  5 + <ul class="menu-list">
  6 + {{#each menuList}}
  7 + <li class="{{#if curMenu}} on{{/if}}"><a class="pjax" href="{{href}}">{{name}}</a></li>
  8 + {{/each}}
  9 + </ul>
  10 + <a href="{{url}}" class="more">MORE</a>
  11 + </div>
  12 +{{/ goodsMenu}}
  13 +
  14 +{{> common/sort-pager}}
  15 +</div>
  16 +
  17 +<div class="goods-container clearfix">
  18 + {{# list}}
  19 + {{> product/good}}
  20 + {{/list}}
  21 + <div class="good-item-wrapper">
  22 + <div class="good-info-main"></div>
  23 + <div class="good-select-color"></div>
  24 + </div>
  25 +</div>
@@ -372,6 +372,7 @@ @@ -372,6 +372,7 @@
372 li { 372 li {
373 display: inline-block; 373 display: inline-block;
374 padding: 0 15px; 374 padding: 0 15px;
  375 + vertical-align: middle;
375 } 376 }
376 377
377 .on { 378 .on {
@@ -391,10 +392,6 @@ @@ -391,10 +392,6 @@
391 } 392 }
392 } 393 }
393 394
394 - .sort-pager .sort-type:first-child .iconfont {  
395 - display: inline-block;  
396 - }  
397 -  
398 .loading { 395 .loading {
399 position: relative; 396 position: relative;
400 width: 100%; 397 width: 100%;