...
|
...
|
@@ -6,7 +6,6 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
const logger = global.yoho.logger;
|
|
|
const api = global.yoho.API;
|
|
|
const shopApi = require('./shop-api');
|
|
|
const processProductList = require(`${global.utils}/beautify/product`);
|
|
|
const camelCase = global.yoho.camelCase;
|
...
|
...
|
@@ -21,50 +20,44 @@ const prettyFilter = require(`${global.utils}/beautify/filters`); |
|
|
const getShopData = params => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
return api.all([
|
|
|
shopApi.getBrandInfoByDomain({domain: params.domain})
|
|
|
]).then(result => {
|
|
|
return shopApi.getBrandInfoByDomain({domain: params.domain}).then(result => {
|
|
|
|
|
|
if (result[0].code === 200) {
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
/* 品牌名称 */
|
|
|
Object.assign(finalResult, {
|
|
|
brandName: result[0].data.brand_name
|
|
|
brandName: result.data.brand_name
|
|
|
});
|
|
|
|
|
|
/* 品牌是否有店铺 */
|
|
|
if (result[0].data.shop_id) {
|
|
|
if (result.data.shop_id) {
|
|
|
|
|
|
/* 是 BLK 的店铺 */
|
|
|
Object.assign(finalResult, {
|
|
|
isBlkShop: true,
|
|
|
shopId: result[0].data.shop_id
|
|
|
shopId: result.data.shop_id
|
|
|
});
|
|
|
|
|
|
return api.all([
|
|
|
shopApi.getShopInfoData({
|
|
|
shopId: result[0].data.shop_id,
|
|
|
uid: params.uid
|
|
|
return shopApi.getShopInfoData({
|
|
|
shopId: result.data.shop_id,
|
|
|
uid: params.uid
|
|
|
|
|
|
// uid: '8050882'
|
|
|
})
|
|
|
]).then(subResult => {
|
|
|
if (subResult[0].code === 200) {
|
|
|
// uid: '8050882'
|
|
|
}).then(subResult => {
|
|
|
if (subResult.code === 200) {
|
|
|
|
|
|
/* 取店铺的基本信息 */
|
|
|
Object.assign(finalResult, {
|
|
|
shopLogo: subResult[0].data.shop_logo,
|
|
|
shopName: subResult[0].data.shop_name,
|
|
|
shopIntro: subResult[0].data.shop_intro,
|
|
|
isFav: subResult[0].data.is_favorite === 'Y'
|
|
|
shopLogo: subResult.data.shop_logo,
|
|
|
shopName: subResult.data.shop_name,
|
|
|
shopIntro: subResult.data.shop_intro,
|
|
|
isFav: subResult.data.is_favorite === 'Y'
|
|
|
});
|
|
|
|
|
|
/* 取资源位店铺背景图 */
|
|
|
return api.all([
|
|
|
shopApi.getShopsDecoratorList({shopId: result[0].data.shop_id})
|
|
|
]).then(thResult => {
|
|
|
if (thResult[0].code === 200) {
|
|
|
_.forEach(thResult[0].data.list, value => {
|
|
|
return shopApi.getShopsDecoratorList({shopId: result.data.shop_id}).then(thResult => {
|
|
|
if (thResult.code === 200) {
|
|
|
_.forEach(thResult.data.list, value => {
|
|
|
|
|
|
if (value.resource_name === 'shopTopBanner_app') {
|
|
|
Object.assign(finalResult, {
|
...
|
...
|
@@ -110,24 +103,20 @@ const getShopData = params => { |
|
|
const getBrandShopGoodsData = params => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
return api.all([
|
|
|
shopApi.getBrandInfoByDomain({ domain: params.domain })
|
|
|
]).then(result => {
|
|
|
if (result[0].code === 200) {
|
|
|
return api.all([
|
|
|
shopApi.getBrandShopGoodsOriginData(Object.assign(params, {
|
|
|
brand: result[0].data.id,
|
|
|
shopId: result[0].data.shop_id
|
|
|
}))
|
|
|
]).then(subResult => {
|
|
|
if (subResult[0].code === 200 && subResult[0].data) {
|
|
|
prettyFilter(subResult[0].data.filter);
|
|
|
return shopApi.getBrandInfoByDomain({ domain: params.domain }).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
return shopApi.getBrandShopGoodsOriginData(Object.assign(params, {
|
|
|
brand: result.data.id,
|
|
|
shopId: result.data.shop_id
|
|
|
})).then(subResult => {
|
|
|
if (subResult.code === 200 && subResult.data) {
|
|
|
prettyFilter(subResult.data.filter);
|
|
|
finalResult = {
|
|
|
data: {
|
|
|
productList: processProductList(subResult[0].data.product_list),
|
|
|
filter: subResult[0].data.filter,
|
|
|
page: subResult[0].data.page,
|
|
|
pageTotal: subResult[0].data.page_total
|
|
|
productList: processProductList(subResult.data.product_list),
|
|
|
filter: subResult.data.filter,
|
|
|
page: subResult.data.page,
|
|
|
pageTotal: subResult.data.page_total
|
|
|
},
|
|
|
code: 200
|
|
|
};
|
...
|
...
|
@@ -151,8 +140,8 @@ const getBrandShopGoodsData = params => { |
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const collectShopData = params => {
|
|
|
return api.all([shopApi.collectShopOriginData(params)]).then(result => {
|
|
|
return result[0];
|
|
|
return shopApi.collectShopOriginData(params).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|