...
|
...
|
@@ -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');
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -19,14 +20,18 @@ const _ = require('lodash'); |
|
|
* @param domain
|
|
|
* @returns {*[]}
|
|
|
*/
|
|
|
function shopMenu(domain) {
|
|
|
function shopMenu(domain, customMenu) {
|
|
|
let menus = [
|
|
|
{id: 'index', name: '店铺首页', href: `/product/shop/${domain}`},
|
|
|
{id: 'all', name: '全部商品', href: `/product/shop/${domain}/list`, icon: ''},
|
|
|
{id: 'hot', name: '人气单品', href: `/product/shop/${domain}/list?order=s_n_desc`},
|
|
|
{id: 'new', name: '新品上架', href: `/product/shop/${domain}/list?order=s_t_desc`}
|
|
|
{id: 'index', name: '店铺首页', url: `/product/shop/${domain}`},
|
|
|
{id: 'all', name: '全部商品', url: `/product/shop/${domain}/list`, icon: ''},
|
|
|
{id: 'hot', name: '人气单品', url: `/product/shop/${domain}/list?order=s_n_desc`},
|
|
|
{id: 'new', name: '新品上架', url: `/product/shop/${domain}/list?order=s_t_desc`}
|
|
|
];
|
|
|
|
|
|
if (customMenu && customMenu.length > 0) {
|
|
|
menus = _.concat(menus, customMenu);
|
|
|
}
|
|
|
|
|
|
return menus;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -86,19 +91,27 @@ const ShopService = { |
|
|
* 获取店铺二级分类
|
|
|
* @param shopId
|
|
|
*/
|
|
|
getShopSecondSorts(shopId) {
|
|
|
getShopSecondSorts(brandId, shopId) {
|
|
|
return co(function*() {
|
|
|
let data = yield ShopApi.getShopSorts(shopId);
|
|
|
|
|
|
if (data && data.code === 200) {
|
|
|
let sorts = camelCase(data.data);
|
|
|
let data = yield Search.queryAllSort({
|
|
|
brand: brandId,
|
|
|
shop: shopId,
|
|
|
small_sort: 0
|
|
|
});
|
|
|
let sortArray = [];
|
|
|
|
|
|
if (data && data.data) {
|
|
|
let sorts = camelCase(data.data.sort);
|
|
|
|
|
|
sorts.forEach(s => {
|
|
|
sortArray = sortArray.concat(s.sub);
|
|
|
});
|
|
|
|
|
|
return sorts.sort((a, b) => {
|
|
|
return a.sub.length >= b.sub.length;
|
|
|
sortArray = sortArray.sort((s1, s2) => {
|
|
|
return s2.count - s1.count;
|
|
|
});
|
|
|
} else {
|
|
|
return [];
|
|
|
}
|
|
|
return sortArray;
|
|
|
})();
|
|
|
},
|
|
|
|
...
|
...
|
@@ -126,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);
|
...
|
...
|
@@ -134,10 +147,10 @@ const ShopService = { |
|
|
info.sorts = sorts;
|
|
|
|
|
|
if (resources.shopTopBanner) { // eslint-disable-line
|
|
|
info.banner = resources.shopTopBanner.detailSrc; // eslint-disable-line
|
|
|
info.banner = resources.shopTopBanner.shopSrc; // eslint-disable-line
|
|
|
}
|
|
|
info.resources = resources;
|
|
|
info.menus = shopMenu(domain);
|
|
|
info.menus = shopMenu(domain, resources.navigationBar);
|
|
|
} else {
|
|
|
let brandId = domainInfo.id;
|
|
|
let brandInfo = yield BrandService.getBrandInfo(brandId, uid);
|
...
|
...
|
|