...
|
...
|
@@ -4,6 +4,15 @@ const serviceAPI = global.yoho.ServiceAPI; |
|
|
const _ = require('lodash');
|
|
|
const logger = global.yoho.logger;
|
|
|
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 = [];
|
...
|
...
|
@@ -60,7 +69,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 {};
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -85,7 +94,7 @@ const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) = |
|
|
};
|
|
|
|
|
|
// 新品到着
|
|
|
const getNewProduct = (brandId, gender, url) => {
|
|
|
const getNewProduct = (brandId, gender, url, isApp) => {
|
|
|
|
|
|
return api.get('', {
|
|
|
method: 'app.search.li',
|
...
|
...
|
@@ -143,6 +152,14 @@ const getNewProduct = (brandId, gender, url) => { |
|
|
|
|
|
newArrival.moreUrl = url;
|
|
|
|
|
|
let productUrl = '//m.yohobuy.com/product/pro_' + list.product_id + '_' +
|
|
|
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html';
|
|
|
|
|
|
if (isApp) {
|
|
|
console.log(productUrl);
|
|
|
productUrl += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${list.product_skn}"}}`;
|
|
|
}
|
|
|
|
|
|
obj = _.assign(obj, {
|
|
|
id: list.product_skn,
|
|
|
product_id: list.product_id,
|
...
|
...
|
@@ -152,8 +169,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 + '_' +
|
|
|
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html',
|
|
|
url: productUrl,
|
|
|
tags: tag
|
|
|
});
|
|
|
|
...
|
...
|
@@ -167,6 +183,8 @@ const getNewProduct = (brandId, gender, url) => { |
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return newArrival;
|
...
|
...
|
@@ -178,14 +196,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) {
|
...
|
...
|
@@ -193,9 +212,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),
|
...
|
...
|
@@ -205,6 +228,8 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => { |
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
} else {
|
|
|
logger.error('editorial data return code is not 200');
|
...
|
...
|
@@ -218,7 +243,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) {
|
...
|
...
|
@@ -243,6 +269,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { |
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
let list = result.data || [];
|
|
|
let jumpToApp;
|
|
|
|
|
|
let url;
|
|
|
|
...
|
...
|
@@ -256,12 +283,34 @@ 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) => { //pagecache重构
|
|
|
return getNewProduct(brandId, gender, url).then((result) => {
|
|
|
if (isApp & !uid) {
|
|
|
jumpToApp = 1;
|
|
|
}
|
|
|
|
|
|
let likeUrl = helpers.urlFormat('/plustar/brandinfo', {
|
|
|
id: brandId
|
|
|
}, 'guang');
|
|
|
|
|
|
if (isApp) {
|
|
|
let $url = likeUrl;
|
|
|
$url += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
|
|
|
+ brandId + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + brandId + '"}},"priority":"Y"}}';
|
|
|
} else {
|
|
|
let $url = helpers.urlFormat('/signin.html', {refer: likeUrl});
|
|
|
}
|
|
|
|
|
|
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
|
|
|
|
|
|
list = _.assign(list, {
|
|
|
// isLike: result[0], //pagecache重构
|
|
|
// infos: result[1], //pagecache重构
|
|
|
newArrival: result
|
|
|
|
|
|
isLike: result[0],
|
|
|
infos: result[1],
|
|
|
newArrival: result[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;
|
...
|
...
|
|