...
|
...
|
@@ -12,6 +12,7 @@ const co = Promise.coroutine; |
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const BrandService = require('./brand-service');
|
|
|
const ShopApi = require('./shop-api');
|
|
|
const Search = require('../models/search');
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -90,19 +91,27 @@ const ShopService = { |
|
|
* 获取店铺二级分类
|
|
|
* @param shopId
|
|
|
*/
|
|
|
getShopSecondSorts(shopId) {
|
|
|
getShopSecondSorts(brandId, shopId) {
|
|
|
return co(function*() {
|
|
|
let data = yield ShopApi.getShopSorts(shopId);
|
|
|
let data = yield Search.queryAllSort({
|
|
|
brand: brandId,
|
|
|
shop: shopId,
|
|
|
small_sort: 0
|
|
|
});
|
|
|
let sortArray = [];
|
|
|
|
|
|
if (data && data.code === 200) {
|
|
|
let sorts = camelCase(data.data);
|
|
|
if (data && data.data) {
|
|
|
let sorts = camelCase(data.data.sort);
|
|
|
|
|
|
return sorts.sort((a, b) => {
|
|
|
return a.sub.length >= b.sub.length;
|
|
|
sorts.forEach(s => {
|
|
|
sortArray = sortArray.concat(s.sub);
|
|
|
});
|
|
|
|
|
|
sortArray = sortArray.sort((s1, s2) => {
|
|
|
return s2.count - s1.count;
|
|
|
});
|
|
|
} else {
|
|
|
return [];
|
|
|
}
|
|
|
return sortArray;
|
|
|
})();
|
|
|
},
|
|
|
|
...
|
...
|
@@ -130,7 +139,7 @@ const ShopService = { |
|
|
info.isFavorite = shopIntro.isFavorite === 'Y';
|
|
|
|
|
|
let shopData = yield Promise.all([ShopService.getShopDecorator(shopId),
|
|
|
ShopService.getShopSecondSorts(shopId)]);
|
|
|
ShopService.getShopSecondSorts(domainInfo.id, shopId)]);
|
|
|
let shopList = shopData[0];
|
|
|
let sorts = shopData[1];
|
|
|
let resources = resourceDataHandle(shopList.list);
|
...
|
...
|
|