...
|
...
|
@@ -5,6 +5,7 @@ const _ = require('lodash'); |
|
|
const productProcess = require('../../../utils/product-process');
|
|
|
const logger = global.yoho.logger;
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const formaData = (data, gender) => {
|
|
|
let build = [];
|
...
|
...
|
@@ -76,9 +77,126 @@ const getListData = (gender, recom, all) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
//新品到着
|
|
|
const getNewProduct = (brandId, gender, url) => {
|
|
|
|
|
|
return api.get('', {
|
|
|
method: 'app.search.li',
|
|
|
brand: brandId,
|
|
|
gender: gender,
|
|
|
limit: 6,
|
|
|
order: 's_t_desc',
|
|
|
page: 1
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
//console.log(result.data.product_list)
|
|
|
// let naList = [];
|
|
|
let newArrival = {
|
|
|
naList: []
|
|
|
}
|
|
|
|
|
|
if(result.data.product_list) {
|
|
|
_.forEach(result.data.product_list, function(list, index) {
|
|
|
// console.log(list)
|
|
|
if(index <= 5) {
|
|
|
let tag = [];
|
|
|
|
|
|
if (!list.product_skn) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (list.market_price === list.sales_price) {
|
|
|
list.market_price = false;
|
|
|
}
|
|
|
tag.push({
|
|
|
is_new: list.is_new === 'Y',
|
|
|
is_discount: list.is_discount === 'Y',
|
|
|
is_limited: list.is_limited === 'Y',
|
|
|
is_yohood: list.is_yohood === 'Y',
|
|
|
is_advance: list.is_advance === 'Y'
|
|
|
});
|
|
|
|
|
|
_.forEach(tag, function(data) {
|
|
|
|
|
|
if (data.is_discount === true && list.is_soon_soldOut === true) {
|
|
|
data.is_new = true;
|
|
|
data.is_discount = false;
|
|
|
} else if (data.is_discount === true && (data.is_new === true || data.is_limited === true || data.is_yohood === true || data.is_advance === true)) {
|
|
|
data.is_discount = false;
|
|
|
} else if (data.is_yohood === true && data.is_new === true) {
|
|
|
data.is_new = false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (list.market_price && list.market_price !== false) {
|
|
|
newArrival.naList.push({
|
|
|
price: list.market_price + '.00'
|
|
|
})
|
|
|
}
|
|
|
|
|
|
newArrival.moreUrl = url;
|
|
|
|
|
|
newArrival.naList.push({
|
|
|
id: list.product_skn,
|
|
|
product_id: list.product_id,
|
|
|
thumb: helpers.image(list.default_images, 235, 314),
|
|
|
name: list.product_name,
|
|
|
salePrice: list.sales_price + '.00',
|
|
|
studentPrice: list.sales_price * 0.9,
|
|
|
is_soon_sold_out: list.is_soon_sold_out === 'Y',
|
|
|
isShowSaleTagDis: list.sales_price * 2 < list.market_price,
|
|
|
url: '/product/pro_' + list.product_id + '_' +
|
|
|
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html',
|
|
|
tags: tag
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//console.log(newArrival)
|
|
|
return newArrival;
|
|
|
} else {
|
|
|
logger.error('new data return code is not 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 相关资讯
|
|
|
const getRelatedEditorial = () => {
|
|
|
const getRelatedEditorial = (brandId, uid, udid, clientType) => {
|
|
|
|
|
|
return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
|
|
|
brand_id: brandId,
|
|
|
uid: uid,
|
|
|
udid: udid,
|
|
|
client_type: clientType,
|
|
|
limit: 3
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
|
|
|
let list = [];
|
|
|
|
|
|
_.forEach(result.data, function(data) {
|
|
|
list.push({
|
|
|
id: data.id,
|
|
|
url: data.url,
|
|
|
title: data.title,
|
|
|
text: data.intro,
|
|
|
img: helpers.image(data.src, 640, 640),
|
|
|
publishTime: data.publish_time,
|
|
|
like: data.like,
|
|
|
pageView: data.views_num
|
|
|
})
|
|
|
})
|
|
|
|
|
|
return list;
|
|
|
} else {
|
|
|
logger.error('editorial data return code is not 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 是否收藏
|
...
|
...
|
@@ -88,9 +206,9 @@ const isCollection = (uid, brandId, clientType) => { |
|
|
brandId: brandId,
|
|
|
client_type: clientType
|
|
|
}).then((result) => {
|
|
|
// console.log(result)
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
// console.log(result.data)
|
|
|
|
|
|
let isLike = true;
|
|
|
return isLike;
|
|
|
} else {
|
...
|
...
|
@@ -101,27 +219,39 @@ const isCollection = (uid, brandId, clientType) => { |
|
|
};
|
|
|
|
|
|
// 品牌详情
|
|
|
const getBrandData = (id, clientType, uid) => {
|
|
|
const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
|
|
|
|
|
|
return serviceAPI.get('guang/api/v1/plustar/getbrandinfo', {
|
|
|
id: id,
|
|
|
client_type: clientType
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
// console.log(result.data)
|
|
|
|
|
|
let list = result.data || [];
|
|
|
list = camelCase(list);
|
|
|
let url;
|
|
|
|
|
|
let brandId = result.data.brand_id;
|
|
|
let brandId = list.brandId;
|
|
|
let brandDomain = list.brandDomain;
|
|
|
let isDifferent = list.isDifferent
|
|
|
|
|
|
if (isApp) {
|
|
|
url = '?openby:yohobuy={"action":"go.brand","params":{"brand_id":"' + brandId + '","is_different":"' + isDifferent + '"}}';
|
|
|
} else {
|
|
|
url = '//' + brandDomain + '.m.yohobuy.com';
|
|
|
}
|
|
|
|
|
|
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType), getNewProduct(brandId, gender, url)]).then((result) => {
|
|
|
|
|
|
return isCollection(uid, brandId, clientType).then((result) => {
|
|
|
// console.log(result)
|
|
|
list = _.assign(list, {
|
|
|
isLike: result
|
|
|
isLike: result[0],
|
|
|
infos: result[1],
|
|
|
newArrival: result[2]
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
logger.error('detail data return code is not 200');
|
|
|
return {};
|
...
|
...
|
@@ -129,18 +259,6 @@ const getBrandData = (id, clientType, uid) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
|
|
|
return Promise.all([getBrandData(id, clientType, uid), getRelatedEditorial(gender)]).then((result) => {
|
|
|
// console.log(result[0].brandDomain)
|
|
|
return {
|
|
|
brandInfo: result[0],
|
|
|
newArrival: result[1]
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
getListData,
|
|
|
getContentData,
|
...
|
...
|
|