...
|
...
|
@@ -5,6 +5,15 @@ const _ = require('lodash'); |
|
|
const logger = global.yoho.logger;
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const htmlProcess = require(`${global.utils}/html-process`);
|
|
|
|
|
|
const privateKeyList = {
|
|
|
android: 'fd4ad5fcfa0de589ef238c0e7331b585',
|
|
|
iphone: 'a85bb0674e08986c6b115d5e3a4884fa',
|
|
|
ipad: 'ad9fcda2e679cf9229e37feae2cdcf80',
|
|
|
web: '0ed29744ed318fd28d2c07985d3ba633',
|
|
|
h5: 'fd4ad5fcfa0de589ef238c0e7331b585'
|
|
|
};
|
|
|
|
|
|
const formaData = (data, gender) => {
|
|
|
let build = [];
|
...
|
...
|
@@ -61,7 +70,7 @@ const getContentData = (gender, type, channel, isRecommend) => { |
|
|
if (result && result.code === 200) {
|
|
|
return formaData(result.data.data.list[0].data, gender);
|
|
|
} else {
|
|
|
logger.error('列表 list data return code is not 200');
|
|
|
logger.error('list data return code is not 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -69,19 +78,45 @@ const getContentData = (gender, type, channel, isRecommend) => { |
|
|
|
|
|
const getListData = (gender, recom, all) => {
|
|
|
return Promise.all([getContentData(gender, recom), getContentData(gender, all)]).then((result) => {
|
|
|
return {
|
|
|
star: result[0],
|
|
|
plus: result[1]
|
|
|
};
|
|
|
let ps = [];
|
|
|
|
|
|
if (result[0]) {
|
|
|
ps.push({
|
|
|
focus: true,
|
|
|
name: '设计师',
|
|
|
list: result[0]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (result[1]) {
|
|
|
ps.push({
|
|
|
name: '经典潮牌',
|
|
|
list: result[1]
|
|
|
});
|
|
|
}
|
|
|
return ps;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) => {
|
|
|
return Promise.all([getContentData(gender, starBrand, isRecommend, channel), getContentData(gender, originalBrand, isRecommend, channel)]).then((result) => {
|
|
|
return {
|
|
|
star: result[0],
|
|
|
plus: result[1]
|
|
|
};
|
|
|
let ps = [];
|
|
|
|
|
|
if (result[1]) {
|
|
|
ps.push({
|
|
|
focus: true,
|
|
|
name: '原创潮牌',
|
|
|
list: result[1]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (result[0]) {
|
|
|
ps.push({
|
|
|
name: '明星潮品',
|
|
|
list: result[0]
|
|
|
});
|
|
|
}
|
|
|
return ps;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -153,7 +188,7 @@ const getNewProduct = (brandId, gender, url) => { |
|
|
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 + '_' +
|
|
|
url: '//m.yohobuy.com/product/pro_' + list.product_id + '_' +
|
|
|
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html',
|
|
|
tags: tag
|
|
|
});
|
...
|
...
|
@@ -179,14 +214,15 @@ const getNewProduct = (brandId, gender, url) => { |
|
|
};
|
|
|
|
|
|
// 相关资讯
|
|
|
const getRelatedEditorial = (brandId, uid, udid, clientType) => {
|
|
|
const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
|
|
|
|
|
|
return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
|
|
|
brand_id: brandId,
|
|
|
uid: uid,
|
|
|
udid: udid,
|
|
|
client_type: clientType,
|
|
|
limit: 3
|
|
|
limit: 3,
|
|
|
private_key: privateKeyList[clientType]
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result && result.code === 200) {
|
...
|
...
|
@@ -194,9 +230,13 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => { |
|
|
let list = [];
|
|
|
|
|
|
_.forEach(result.data, function(data) {
|
|
|
if (isApp) {
|
|
|
data.url = data.url + '';
|
|
|
}
|
|
|
|
|
|
list.push({
|
|
|
id: data.id,
|
|
|
url: data.url,
|
|
|
url: isApp ? `${helpers.https(data.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : data.url,
|
|
|
title: data.title,
|
|
|
text: data.intro,
|
|
|
img: helpers.image(data.src, 640, 640),
|
...
|
...
|
@@ -206,6 +246,8 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => { |
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
} else {
|
|
|
logger.error('editorial data return code is not 200');
|
...
|
...
|
@@ -219,7 +261,8 @@ const isCollection = (uid, brandId, clientType) => { |
|
|
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', {
|
|
|
uid: uid,
|
|
|
brandId: brandId,
|
|
|
client_type: clientType
|
|
|
client_type: clientType,
|
|
|
private_key: privateKeyList[clientType]
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result && result.code === 200) {
|
...
|
...
|
@@ -245,6 +288,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { |
|
|
if (result && result.code === 200) {
|
|
|
|
|
|
let list = result.data || [];
|
|
|
let jumpToApp;
|
|
|
|
|
|
list = camelCase(list);
|
|
|
let url;
|
...
|
...
|
@@ -259,12 +303,22 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { |
|
|
url = '//' + brandDomain + '.m.yohobuy.com';
|
|
|
}
|
|
|
|
|
|
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType), getNewProduct(brandId, gender, url)]).then((result) => {
|
|
|
if (isApp & !uid) {
|
|
|
jumpToApp = 1;
|
|
|
}
|
|
|
|
|
|
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url)]).then((resultData) => {
|
|
|
|
|
|
list = _.assign(list, {
|
|
|
isLike: result[0],
|
|
|
infos: result[1],
|
|
|
newArrival: result[2]
|
|
|
|
|
|
isLike: resultData[0],
|
|
|
infos: resultData[1],
|
|
|
newArrival: resultData[2],
|
|
|
jumpToApp: jumpToApp,
|
|
|
shareLink: '//guang.m.yohobuy.com/plustar/brandinfo?id=' + id,
|
|
|
shareTitle: list.brandName,
|
|
|
shareImg: list.brandIco,
|
|
|
shareDesc: htmlProcess.removeHtml(list.brandIntro)
|
|
|
});
|
|
|
|
|
|
return list;
|
...
|
...
|
|