Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/hotfix/shopSort'

@@ -526,6 +526,7 @@ const getBaseShopData = (params, shopInfo) => { @@ -526,6 +526,7 @@ const getBaseShopData = (params, shopInfo) => {
526 const getShopData = (req, shopId, uid, isApp) => { 526 const getShopData = (req, shopId, uid, isApp) => {
527 let shopData = {}; 527 let shopData = {};
528 let channel = req.yoho.channel; 528 let channel = req.yoho.channel;
  529 + let brandData = [];
529 530
530 return _getShopInfo(shopId, uid).then(shopInfoResult => { 531 return _getShopInfo(shopId, uid).then(shopInfoResult => {
531 532
@@ -536,56 +537,73 @@ const getShopData = (req, shopId, uid, isApp) => { @@ -536,56 +537,73 @@ const getShopData = (req, shopId, uid, isApp) => {
536 }; 537 };
537 } 538 }
538 539
539 - return Promise.all([  
540 - _getShopDecorator(shopId),  
541 - searchModel.getFilterSearchData({  
542 - shop_id: shopId,  
543 - channel: channel  
544 - }),  
545 - _shopCouponsList(shopId, uid)  
546 - ]).then((result) => {  
547 - shopData = {  
548 - decorator: result[0], // 店铺装修资源数据  
549 - shopInfo: shopInfoResult // 店铺信息  
550 - }; 540 + return _getShopDecorator(shopId).then(shopDeco => {
  541 + return shopDeco;
  542 + }).then(shopDeco => {
  543 + let brandBrowseData;
  544 +
  545 + // 取店铺下的brand, id
  546 + _.forEach(shopDeco.list, floor => {
  547 + if (floor.resource_name === 'brandBrowse') {
  548 + brandBrowseData = JSON.parse(floor.resource_data);
  549 + _.forEach(brandBrowseData, brandBrowse => {
  550 + brandData.push(brandBrowse.id);
  551 + });
  552 + }
  553 + });
551 554
552 - /* 获取一次分类和商品数据 */  
553 - let shopFilterSearchData = {  
554 - filter: [],  
555 - goods: []  
556 - }; 555 + return Promise.all([
  556 + searchModel.getFilterSearchData({
  557 + shop_id: shopId,
  558 + brand: brandData.join(','),
  559 + order: '0',
  560 + channel: channel
  561 + }),
  562 + _shopCouponsList(shopId, uid)
  563 + ]).then((result) => {
  564 + shopData = {
  565 + decorator: shopDeco, // 店铺装修资源数据
  566 + shopInfo: shopInfoResult // 店铺信息
  567 + };
557 568
558 - if (result[1]) {  
559 - shopFilterSearchData.filter = productProcess.processFilter(result[1].filter || []);  
560 - shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || [], {isApp: isApp});  
561 - } 569 + /* 获取一次分类和商品数据 */
  570 + let shopFilterSearchData = {
  571 + filter: [],
  572 + goods: []
  573 + };
562 574
563 - /* 店鋪優惠券 */  
564 - let shopCoupons = result[2] || [];  
565 -  
566 - // 店铺分类  
567 - return _getShopCategory(shopId, channel).then(shopCategory => {  
568 -  
569 - shopData = _.assign({  
570 - shopCategory: shopCategory  
571 - }, shopData);  
572 -  
573 - // noinspection JSCheckFunctionSignatures  
574 - return Object.assign(  
575 - _formShopData(shopData, shopId, isApp),  
576 - shopFilterSearchData,  
577 - {  
578 - shopId: shopId,  
579 - uid: uid ? crypto.encryption('', uid + '') : '',  
580 - coverChannel: channel,  
581 - shopCoupons: shopCoupons,  
582 - shopCouponsOne: shopCoupons.length === 1  
583 - }  
584 - ); 575 + if (result[0]) {
  576 + shopFilterSearchData.filter = productProcess.processFilter(result[0].filter || []);
  577 + shopFilterSearchData.goods = productProcess.processProductList(result[0].product_list || [], {isApp: isApp});
  578 + }
  579 +
  580 + /* 店铺优惠券 */
  581 + let shopCoupons = result[1] || [];
  582 +
  583 + // 店铺分类
  584 + return _getShopCategory(shopId, channel).then(shopCategory => {
  585 +
  586 + shopData = _.assign({
  587 + shopCategory: shopCategory
  588 + }, shopData);
  589 +
  590 + // noinspection JSCheckFunctionSignatures
  591 + return Object.assign(
  592 + _formShopData(shopData, shopId, isApp),
  593 + shopFilterSearchData,
  594 + {
  595 + shopId: shopId,
  596 + uid: uid ? crypto.encryption('', uid + '') : '',
  597 + coverChannel: channel,
  598 + shopCoupons: shopCoupons,
  599 + shopCouponsOne: shopCoupons.length === 1
  600 + }
  601 + );
  602 + });
585 }); 603 });
586 }); 604 });
587 -  
588 }); 605 });
  606 +
589 }; 607 };
590 608
591 /** 609 /**
@@ -101,7 +101,7 @@ var $listNav = $('#list-nav'), @@ -101,7 +101,7 @@ var $listNav = $('#list-nav'),
101 end: false 101 end: false
102 }, 102 },
103 newest: { 103 newest: {
104 - order: 1, 104 + order: 0,
105 reload: true, 105 reload: true,
106 page: 0, 106 page: 0,
107 end: false 107 end: false