...
|
...
|
@@ -75,13 +75,20 @@ const getPathNav = (channelType, query) => { |
|
|
return query ? _.concat(path, [{ name: query, pathTitle: query}]) : path;
|
|
|
};
|
|
|
|
|
|
const _formatTag = (tagData) => {
|
|
|
let name = tagData.name;
|
|
|
const _formatTag = (tagData, channel) => {
|
|
|
let name = tagData.name,
|
|
|
param = {
|
|
|
query: name
|
|
|
};
|
|
|
|
|
|
if (channel) {
|
|
|
param.channel = channel;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
tag: name,
|
|
|
name: name,
|
|
|
url: helpers.urlFormat('/tags/index', {query: name}, 'guang')
|
|
|
url: helpers.urlFormat('/tags/index', param, 'guang')
|
|
|
};
|
|
|
};
|
|
|
|
...
|
...
|
@@ -93,7 +100,7 @@ const _formatTag = (tagData) => { |
|
|
* @param bool $showAuthor 控制是否显示作者信息
|
|
|
* @return array | false
|
|
|
*/
|
|
|
const _formatArticle = (articleData, showTag, showAuthor) => {
|
|
|
const _formatArticle = (articleData, showTag, showAuthor, channel) => {
|
|
|
|
|
|
// 资讯ID不存在,则不显示
|
|
|
if (!articleData || !articleData.id) {
|
...
|
...
|
@@ -105,7 +112,7 @@ const _formatArticle = (articleData, showTag, showAuthor) => { |
|
|
isSquareImage = true;
|
|
|
|
|
|
|
|
|
if (articleData.conver_image_type === 2) {
|
|
|
if (Number(articleData.conver_image_type) === 2) {
|
|
|
width = 360;
|
|
|
height = 240;
|
|
|
isSquareImage = false;
|
...
|
...
|
@@ -115,7 +122,7 @@ const _formatArticle = (articleData, showTag, showAuthor) => { |
|
|
id: articleData.id,
|
|
|
classification: articleData.category_name,
|
|
|
isReco: articleData.is_recommended ? true : false,
|
|
|
url: ghelper.getArticleUrl(articleData.url, articleData.id),
|
|
|
url: ghelper.getArticleUrl(articleData.url, articleData.id, channel),
|
|
|
img: helpers.image(articleData.src, width, height, 1),
|
|
|
isSquareImg: isSquareImage,
|
|
|
title: articleData.title,
|
...
|
...
|
@@ -138,7 +145,15 @@ const _formatArticle = (articleData, showTag, showAuthor) => { |
|
|
let authorId = articleData.author.author_id;
|
|
|
|
|
|
if (authorId) {
|
|
|
result.editorUrl = helpers.urlFormat('/Index/editor', {author_id: authorId}, 'guang');
|
|
|
|
|
|
let aparam = {
|
|
|
author_id: authorId
|
|
|
};
|
|
|
|
|
|
if (channel) {
|
|
|
aparam.channel = channel;
|
|
|
}
|
|
|
result.editorUrl = helpers.urlFormat('/Index/editor', aparam, 'guang');
|
|
|
}
|
|
|
|
|
|
let tags = [];
|
...
|
...
|
@@ -147,7 +162,7 @@ const _formatArticle = (articleData, showTag, showAuthor) => { |
|
|
let aTags = articleData.tags;
|
|
|
|
|
|
for (let i = 0; i < aTags.length; i++) {
|
|
|
tags.push(_formatTag(aTags[i]));
|
|
|
tags.push(_formatTag(aTags[i], channel));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -191,11 +206,23 @@ const _formatArticle = (articleData, showTag, showAuthor) => { |
|
|
return result;
|
|
|
};
|
|
|
|
|
|
const _formatAd = (adData) => {
|
|
|
const _formatAd = (adData, channel) => {
|
|
|
|
|
|
if (!adData) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
let param = {
|
|
|
id: adData.id
|
|
|
};
|
|
|
|
|
|
if (channel) {
|
|
|
param.channel = channel;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
img: helpers.image(adData.src, 640, 640),
|
|
|
url: helpers.urlFormat('/info/index', {id: adData.id}, 'guang'),
|
|
|
url: helpers.urlFormat('/info/index', param, 'guang'),
|
|
|
title: adData.title,
|
|
|
bgColor: adData.bgColor
|
|
|
};
|
...
|
...
|
@@ -206,7 +233,7 @@ const _formatAd = (adData) => { |
|
|
* @param {String} channelType 传入频道页类型,值可以是: boys, girls, kids, lifestyle
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, useCache) => {
|
|
|
const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, channel, useCache) => {
|
|
|
|
|
|
uid = uid || 0;
|
|
|
udid = udid || '';
|
...
|
...
|
@@ -229,7 +256,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
param.tag = tag;
|
|
|
}
|
|
|
|
|
|
if (_.isNumber(authorId)) {
|
|
|
if (authorId && Number(authorId)) {
|
|
|
param.author_id = authorId;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -255,11 +282,11 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
let list = res.data.list;
|
|
|
|
|
|
if (list.artList) {
|
|
|
artList = _.map(list.artList, it => _formatArticle(it, true, false));
|
|
|
artList = _.map(list.artList, it => _formatArticle(it, true, false, channel));
|
|
|
}
|
|
|
|
|
|
if (list.adlist) {
|
|
|
adsList = _.map(list.artList, it => _formatAd(it));
|
|
|
adsList = _.map(list.artList, it => _formatAd(it, channel));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -269,6 +296,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
total: total
|
|
|
};
|
|
|
}
|
|
|
return null;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -277,7 +305,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
const getHotTags = (page, limit) => {
|
|
|
const getHotTags = (page, limit, channel) => {
|
|
|
|
|
|
let data = {
|
|
|
client_type: 'web',
|
...
|
...
|
@@ -286,12 +314,20 @@ const getHotTags = (page, limit) => { |
|
|
};
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/article/getTagTop', data, {
|
|
|
cache: false
|
|
|
cache: true
|
|
|
}).then(res => {
|
|
|
return _.map((res && res.data) || [], it => {
|
|
|
let param = {
|
|
|
query: it.tag_name
|
|
|
};
|
|
|
|
|
|
if (channel) {
|
|
|
param.channel = channel;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
tagName: it.tag_name,
|
|
|
url: helpers.urlFormat('/tags/index', { query: it.tag_name}, 'guang')
|
|
|
url: helpers.urlFormat('/tags/index', param, 'guang')
|
|
|
};
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -352,19 +388,29 @@ const getBanner = channelType => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getCategory = currentSortId => {
|
|
|
const getCategory = (currentSortId, channel) => {
|
|
|
|
|
|
currentSortId = currentSortId || 0;
|
|
|
return serviceApi.get('guang/api/v1/category/get', {}).then(res => {
|
|
|
return serviceApi.get('guang/api/v1/category/get', {}, {
|
|
|
cache: true
|
|
|
}).then(res => {
|
|
|
let list = [];
|
|
|
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
for (let cat of res.data) {
|
|
|
let param = {
|
|
|
type: cat.id
|
|
|
};
|
|
|
|
|
|
if (channel) {
|
|
|
param.channel = channel;
|
|
|
}
|
|
|
|
|
|
list.push({
|
|
|
typeId: cat.id,
|
|
|
type: cat.name,
|
|
|
isActive: ('' + cat.id) === ('' + currentSortId),
|
|
|
navUrl: helpers.urlFormat('/index/index', {type: cat.id}, 'guang')
|
|
|
isActive: String(cat.id) === String(currentSortId),
|
|
|
navUrl: helpers.urlFormat('/index/index', param, 'guang')
|
|
|
});
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -376,7 +422,7 @@ const getCategory = currentSortId => { |
|
|
/**
|
|
|
* 推荐文章
|
|
|
*/
|
|
|
const getRecoArticles = (gender, page, limit) => {
|
|
|
const getRecoArticles = (gender, page, limit, channel) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/article/getArticleByViewsNum', {
|
|
|
gender: gender,
|
...
|
...
|
@@ -391,7 +437,7 @@ const getRecoArticles = (gender, page, limit) => { |
|
|
let it = res.data[i];
|
|
|
|
|
|
let reco = {
|
|
|
url: ghelper.getArticleUrl(it.url, it.id),
|
|
|
url: ghelper.getArticleUrl(it.url, it.id, channel),
|
|
|
title: it.title
|
|
|
};
|
|
|
|
...
|
...
|
@@ -434,7 +480,7 @@ const getAuthor = authorId => { |
|
|
/**
|
|
|
* 获取文章基本信息,文章标题(不含内容)
|
|
|
*/
|
|
|
const getArticleInfo = aid => {
|
|
|
const getArticleInfo = (aid, channel) => {
|
|
|
return serviceApi.get('guang/service/v2/article/getArticle', {
|
|
|
article_id: aid
|
|
|
}, {cache: true}).then(res => {
|
...
|
...
|
@@ -444,7 +490,7 @@ const getArticleInfo = aid => { |
|
|
|
|
|
if (d.tags) {
|
|
|
for (let i = 0; i < d.tags.length; i++) {
|
|
|
tags.push(_formatTag(d.tags[i]));
|
|
|
tags.push(_formatTag(d.tags[i], channel));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -470,8 +516,8 @@ const _formatProduct = (products, arr) => { |
|
|
|
|
|
let goods = {
|
|
|
thumb: helpers.image(val.default_images, 235, 314),
|
|
|
name: val.product_name,
|
|
|
salesPrice: val.sales_price,
|
|
|
product_name: val.product_name,
|
|
|
sales_price: val.sales_price,
|
|
|
url: helpers.getUrlBySkc(val.product_id, val.goods_list[0].goods_id, val.cn_alphabet)
|
|
|
};
|
|
|
|
...
|
...
|
@@ -480,7 +526,7 @@ const _formatProduct = (products, arr) => { |
|
|
}
|
|
|
|
|
|
_.forEach(arr, (v, k) => {
|
|
|
if (k === val.product_skn) {
|
|
|
if (Number(k) === Number(val.product_skn)) {
|
|
|
goods.thumb = helpers.image(v, 235, 314);
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -500,7 +546,7 @@ const getProductList = (params, arr) => { |
|
|
method: 'web.search.search',
|
|
|
order: 's_n_desc',
|
|
|
limit: 60
|
|
|
}, params)).then(ret => {
|
|
|
}, params), { cache: true }).then(ret => {
|
|
|
if (ret && ret.code === 200 && ret.data && ret.data.product_list) {
|
|
|
return _formatProduct(ret.data.product_list, arr);
|
|
|
}
|
...
|
...
|
@@ -705,7 +751,7 @@ const getArticleRelateBrand = aid => { |
|
|
* @param bool $onlyUrl
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const getRelateArticleList = (aid, tag, size) => {
|
|
|
const getRelateArticleList = (aid, tag, size, channel) => {
|
|
|
size = size || 3;
|
|
|
|
|
|
return serviceApi.get('guang/service/v2/article/getOtherArticle', {
|
...
|
...
|
@@ -716,7 +762,7 @@ const getRelateArticleList = (aid, tag, size) => { |
|
|
if (res && res.code === 200 && res.data) {
|
|
|
return _.map(res.data, it => {
|
|
|
it.thumb = helpers.image(it.thumb, 264, 173, 1);
|
|
|
it.url = ghelper.getArticleUrl(it.url, it.id);
|
|
|
it.url = ghelper.getArticleUrl(it.url, it.id, channel);
|
|
|
return it;
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -835,7 +881,7 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel |
|
|
* @returns {Promise.<T>|*}
|
|
|
*/
|
|
|
const getDynamicDataById = (id, uid, udid) => {
|
|
|
return serviceApi.get('/gateway/guang/api/*/article/getArticlePraiseAndFavor', {
|
|
|
return serviceApi.get('guang/api/*/article/getArticlePraiseAndFavor', {
|
|
|
id: id,
|
|
|
uid: uid,
|
|
|
udid: udid
|
...
|
...
|
|