...
|
...
|
@@ -9,66 +9,49 @@ const _ = require('lodash'); |
|
|
const moment = require('moment');
|
|
|
const ghelper = require('./guang-helper');
|
|
|
|
|
|
// const dataMap = require('../../../config/data-map');
|
|
|
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const serviceApi = global.yoho.ServiceAPI;
|
|
|
const yohoApi = global.yoho.API;
|
|
|
const cache = global.yoho.cache;
|
|
|
|
|
|
const KEY_WEB_GUANG_BANNER_DATA = 'key_web_guang_banner_data';// 逛的首页banner
|
|
|
const KEY_WEB_GUANG_ADS_DATA = 'key_web_guang_ads_data';// 逛的首页ads
|
|
|
// const KEY_WEB_GUANG_BANNER_DATA = 'key_web_guang_banner_data';// 逛的首页banner
|
|
|
// const KEY_WEB_GUANG_ADS_DATA = 'key_web_guang_ads_data';// 逛的首页ads
|
|
|
const URL_OPERATIONS_RESOURCE_GET = 'operations/api/v5/resource/get';
|
|
|
|
|
|
// const headerModel = require('../../../doraemon/models/header');
|
|
|
|
|
|
// guang banner code
|
|
|
const BANNER_CODE = {
|
|
|
'boys': '15a288635c2ed9f6c807417be90f5d2d',
|
|
|
'girls': 'e14e12e35af8626650979f7af8a0de2b',
|
|
|
'lifestyle': '1d398e899f759c6d88971be680521a6f',
|
|
|
'kids': 'ad14ee01ad048ce308aa3ca416133d2a'
|
|
|
boys: '15a288635c2ed9f6c807417be90f5d2d',
|
|
|
girls: 'e14e12e35af8626650979f7af8a0de2b',
|
|
|
lifestyle: '1d398e899f759c6d88971be680521a6f',
|
|
|
kids: 'ad14ee01ad048ce308aa3ca416133d2a'
|
|
|
};
|
|
|
|
|
|
// 逛 ads code
|
|
|
const ADS_CODE = {
|
|
|
'boys': '41777aa7ac86347692c5aa0d394b2f59',
|
|
|
'girls': '722253573823ebb994e313e71b0a4fb9',
|
|
|
'lifestyle': '02568b6042510e4be739cc688dc7d6ae',
|
|
|
'kids': '1ffdd6ea22c58af52ee6408cd353c2d5'
|
|
|
boys: '41777aa7ac86347692c5aa0d394b2f59',
|
|
|
girls: '722253573823ebb994e313e71b0a4fb9',
|
|
|
lifestyle: '02568b6042510e4be739cc688dc7d6ae',
|
|
|
kids: '1ffdd6ea22c58af52ee6408cd353c2d5'
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取首页频道nav
|
|
|
*/
|
|
|
const getHomeChannelNav = (channel) => {
|
|
|
let home = null;
|
|
|
let home;
|
|
|
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
|
|
{
|
|
|
home = helpers.urlFormat('', '', 'default');
|
|
|
break;
|
|
|
}
|
|
|
case 'girls':
|
|
|
{
|
|
|
home = helpers.urlFormat('/woman', '', 'new');
|
|
|
break;
|
|
|
}
|
|
|
home = helpers.urlFormat('/woman', '', 'new');
|
|
|
break;
|
|
|
case 'lifestyle':
|
|
|
{
|
|
|
home = helpers.urlFormat('/lifestyle', '', 'new');
|
|
|
break;
|
|
|
}
|
|
|
home = helpers.urlFormat('/lifestyle', '', 'new');
|
|
|
break;
|
|
|
case 'kids':
|
|
|
{
|
|
|
home = helpers.urlFormat('/kids', '', 'new');
|
|
|
break;
|
|
|
}
|
|
|
home = helpers.urlFormat('/kids', '', 'new');
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
home = helpers.urlFormat('', '', 'default');
|
|
|
}
|
|
|
home = helpers.urlFormat('', '', 'default');
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -93,11 +76,13 @@ const getPathNav = (channelType, query) => { |
|
|
return query ? _.concat(path, [{ name: query, pathTitle: query}]) : path;
|
|
|
};
|
|
|
|
|
|
const _formatTag = (tagData, isApp, uid) => {
|
|
|
const _formatTag = (tagData) => {
|
|
|
let name = tagData.name;
|
|
|
|
|
|
return {
|
|
|
tag: tagData['name'],
|
|
|
name: tagData['name'],
|
|
|
url: helpers.urlFormat('/tags/index', { query: tagData['name']}, 'guang')
|
|
|
tag: name,
|
|
|
name: name,
|
|
|
url: helpers.urlFormat('/tags/index', {query: name}, 'guang')
|
|
|
};
|
|
|
};
|
|
|
|
...
|
...
|
@@ -106,30 +91,21 @@ const _formatTag = (tagData, isApp, uid) => { |
|
|
*
|
|
|
* @param array $articleData 需要格式化的资讯数据
|
|
|
* @param bool $showTag 是否显示左上角标签
|
|
|
* @param mixed $isApp 是否显示分享,在APP客户端里嵌入需要传url链接
|
|
|
* @param bool $showAuthor 控制是否显示作者信息
|
|
|
* @param int $uid 当前登录的用户ID
|
|
|
* @return array | false
|
|
|
*/
|
|
|
const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
|
|
|
|
|
|
if (showTag !== false) {
|
|
|
showTag = true;
|
|
|
}
|
|
|
|
|
|
if (showAuthor !== false) {
|
|
|
showAuthor = true;
|
|
|
}
|
|
|
const _formatArticle = (articleData, showTag, showAuthor) => {
|
|
|
|
|
|
// 资讯ID不存在,则不显示
|
|
|
if (!articleData || !articleData.id) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
let width, height, isSquareImage = true, tags = [];
|
|
|
width = height = 360;
|
|
|
let width = 360,
|
|
|
height = 360,
|
|
|
isSquareImage = true;
|
|
|
|
|
|
if (articleData['conver_image_type'] === 2) {
|
|
|
if (articleData.conver_image_type === 2) {
|
|
|
width = 360;
|
|
|
height = 240;
|
|
|
isSquareImage = false;
|
...
|
...
|
@@ -143,85 +119,83 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => { |
|
|
img: helpers.image(articleData.src, width, height, 1),
|
|
|
isSquareImg: isSquareImage,
|
|
|
title: articleData.title,
|
|
|
pTime: articleData['publish_time'],
|
|
|
pView: articleData['views_num'],
|
|
|
content: articleData['intro'],
|
|
|
pTime: articleData.publish_time,
|
|
|
pView: articleData.views_num,
|
|
|
content: articleData.intro,
|
|
|
showTags: showTag,
|
|
|
comment: articleData['comment_num']
|
|
|
comment: articleData.comment_num
|
|
|
};
|
|
|
|
|
|
if (!articleData['author']) {
|
|
|
articleData['author'] = {
|
|
|
if (!articleData.author) {
|
|
|
articleData.author = {
|
|
|
name: '',
|
|
|
avatar: ''
|
|
|
};
|
|
|
}
|
|
|
result['author'] = articleData.author.name;
|
|
|
if (articleData['author']['author_id']) {
|
|
|
let author_id = articleData['author']['author_id'];
|
|
|
result['editorUrl'] = helpers.urlFormat('/Index/editor', {'author_id': author_id}, 'guang');
|
|
|
|
|
|
// result.author = articleData.author.name;
|
|
|
|
|
|
let authorId = articleData.author.author_id;
|
|
|
|
|
|
if (authorId) {
|
|
|
result.editorUrl = helpers.urlFormat('/Index/editor', {author_id: authorId}, 'guang');
|
|
|
}
|
|
|
|
|
|
if (articleData['tags']) {
|
|
|
for (let tag of articleData['tags']) {
|
|
|
tags.push(_formatTag(tag, isApp));
|
|
|
let tags = [];
|
|
|
|
|
|
if (articleData.tags) {
|
|
|
let aTags = articleData.tags;
|
|
|
|
|
|
for (let i = 0; i < aTags.length; i++) {
|
|
|
tags.push(_formatTag(aTags[i]));
|
|
|
}
|
|
|
}
|
|
|
result['tags'] = tags;
|
|
|
|
|
|
// 收藏
|
|
|
if (isApp) {
|
|
|
result['collect'] = {
|
|
|
isCollected: articleData['isFavor'] && articleData['isFavor'] === 'Y',
|
|
|
url: uid ? 'javascript:;' : articleData['url'].replace('"islogin":"N"', '"islogin":"Y"')
|
|
|
};
|
|
|
} else { // 点赞
|
|
|
result['like'] = articleData['praise_num'];
|
|
|
result['liked'] = articleData['isPraise'] && articleData['isPraise'] === 'Y';
|
|
|
}
|
|
|
result.tags = tags;
|
|
|
|
|
|
// 分享链接
|
|
|
result['share'] = isApp && articleData['share']['url'] ? articleData['share']['url'] : false;
|
|
|
_.assign(result, {
|
|
|
tags: tags,
|
|
|
like: articleData.praise_num,
|
|
|
liked: articleData.isPraise === 'Y'
|
|
|
});
|
|
|
|
|
|
// 判断是否显示作者信息
|
|
|
if (showAuthor && articleData['author']) {
|
|
|
if (!isApp) {
|
|
|
articleData['author']['url'] = articleData['author']['url'];
|
|
|
}
|
|
|
result['author'] = articleData['author'];
|
|
|
if (showAuthor && articleData.author) {
|
|
|
result.author = _.cloneDeep(articleData.author);
|
|
|
}
|
|
|
|
|
|
// 模板中需要的标签标识
|
|
|
if (showTag && articleData['category_id']) {
|
|
|
let categoryId = '' + articleData['category_id'];
|
|
|
if (showTag && articleData.category_id) {
|
|
|
let categoryId = '' + articleData.category_id;
|
|
|
|
|
|
switch (categoryId) {
|
|
|
case '1': // 话题
|
|
|
result['isTopic'] = true;
|
|
|
result.isTopic = true;
|
|
|
break;
|
|
|
case '2': // 搭配
|
|
|
result['isCollocation'] = true;
|
|
|
result.isCollocation = true;
|
|
|
break;
|
|
|
case '3': // 潮人
|
|
|
result['isFashionMan'] = true;
|
|
|
result.isFashionMan = true;
|
|
|
break;
|
|
|
case '4': // 潮品
|
|
|
result['isFashionGood'] = true;
|
|
|
result.isFashionGood = true;
|
|
|
break;
|
|
|
case '5': // 小贴士
|
|
|
result['isTip'] = true;
|
|
|
result.isTip = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
const _formatAd = (adData, isApp, uid) => {
|
|
|
const _formatAd = (adData) => {
|
|
|
|
|
|
return {
|
|
|
img: helpers.image(adData['src'], 640, 640),
|
|
|
url: isApp ? adData['url'] : helpers.urlFormat('/info/index', { 'id': adData['id'] }, 'guang'),
|
|
|
title: adData['title'],
|
|
|
bgColor: adData['bgColor']
|
|
|
img: helpers.image(adData.src, 640, 640),
|
|
|
url: helpers.urlFormat('/info/index', {id: adData.id}, 'guang'),
|
|
|
title: adData.title,
|
|
|
bgColor: adData.bgColor
|
|
|
};
|
|
|
};
|
|
|
|
...
|
...
|
@@ -261,10 +235,8 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
param.limit = limit;
|
|
|
}
|
|
|
|
|
|
let cache = useCache ? 300 : false;
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/article/getList', param, {
|
|
|
cache: cache
|
|
|
cache: useCache ? 300 : false
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res && res.data) {
|
...
|
...
|
@@ -279,12 +251,13 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
|
|
|
if (res.data.list) {
|
|
|
let list = res.data.list;
|
|
|
|
|
|
if (list.artList) {
|
|
|
artList = _.map(list.artList, it => _formatArticle(it, true, false, false, uid));
|
|
|
artList = _.map(list.artList, it => _formatArticle(it, true, false, uid));
|
|
|
}
|
|
|
|
|
|
if (list.adlist) {
|
|
|
adsList = _.map(list.artList, it => _formatAd(it, true, false, false, uid));
|
|
|
adsList = _.map(list.artList, it => _formatAd(it, uid));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -311,10 +284,8 @@ const getHotTags = (page, limit) => { |
|
|
};
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/article/getTagTop', data, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
cache: true
|
|
|
}).then(res => {
|
|
|
|
|
|
return _.map((res && res.data) || [], it => {
|
|
|
return {
|
|
|
tagName: it.tag_name,
|
...
|
...
|
@@ -332,15 +303,14 @@ const getHotTags = (page, limit) => { |
|
|
const getAds = channelType => {
|
|
|
|
|
|
let contentCode = ADS_CODE[channelType] || ADS_CODE.boys;
|
|
|
let ckey = KEY_WEB_GUANG_ADS_DATA + '_' + contentCode;
|
|
|
|
|
|
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
|
|
|
content_code: contentCode
|
|
|
}).then(res => {
|
|
|
|
|
|
}, {cache: true}).then(res => {
|
|
|
let list = [];
|
|
|
if (res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
|
|
|
list = _.map(res['data'][0]['data'], (it) => {
|
|
|
|
|
|
if (res && res.code === 200 && res.data && res.data[0] && res.data[0].data) {
|
|
|
list = _.map(res.data[0].data, (it) => {
|
|
|
return {
|
|
|
img: helpers.image(it.src, 640, 640, 1),
|
|
|
url: it.url
|
...
|
...
|
@@ -360,16 +330,16 @@ const getAds = channelType => { |
|
|
const getBanner = channelType => {
|
|
|
|
|
|
let contentCode = BANNER_CODE[channelType] || BANNER_CODE.boys;
|
|
|
let ckey = KEY_WEB_GUANG_BANNER_DATA + '_' + contentCode;
|
|
|
|
|
|
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
|
|
|
content_code: contentCode
|
|
|
}).then(res => {
|
|
|
|
|
|
let list = [];
|
|
|
if (res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
|
|
|
|
|
|
list = _.map(res['data'][0]['data'], (it) => {
|
|
|
if (res && res.code === 200 && res.data && res.data[0] && res.data[0].data) {
|
|
|
|
|
|
list = _.map(res.data[0].data, it => {
|
|
|
return {
|
|
|
img: helpers.image(it.src, 830, 327, 1),
|
|
|
url: it.url
|
...
|
...
|
@@ -391,8 +361,8 @@ const getCategory = currentSortId => { |
|
|
list.push({
|
|
|
typeId: cat.id,
|
|
|
type: cat.name,
|
|
|
isActive: cat.id == currentSortId,
|
|
|
navUrl: helpers.urlFormat('/index/index', { type: cat.id }, 'guang')
|
|
|
isActive: cat.id === currentSortId,
|
|
|
navUrl: helpers.urlFormat('/index/index', {type: cat.id}, 'guang')
|
|
|
});
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -402,9 +372,9 @@ const getCategory = currentSortId => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 得到推荐文章
|
|
|
* 推荐文章
|
|
|
*/
|
|
|
const getTjArticles = (gender, page, limit) => {
|
|
|
const getRecoArticles = (gender, page, limit) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/article/getArticleByViewsNum', {
|
|
|
gender: gender,
|
...
|
...
|
@@ -414,16 +384,17 @@ const getTjArticles = (gender, page, limit) => { |
|
|
|
|
|
let list = [];
|
|
|
|
|
|
if (res && res['data']) {
|
|
|
for (let it of res['data']) {
|
|
|
if (res && res.data) {
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
let it = res.data[i];
|
|
|
|
|
|
let reco = {
|
|
|
url: ghelper.getArticleUrl(it.url, it.id),
|
|
|
title: it['title']
|
|
|
title: it.title
|
|
|
};
|
|
|
|
|
|
if (it['src']) {
|
|
|
reco['img'] = helpers.image(it.src, 90, 60, 1);
|
|
|
if (it.src) {
|
|
|
reco.img = helpers.image(it.src, 90, 60, 1);
|
|
|
}
|
|
|
|
|
|
list.push(reco);
|
...
|
...
|
@@ -444,15 +415,15 @@ const getAuthor = authorId => { |
|
|
}, {
|
|
|
cache: 3600
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res && res.data) {
|
|
|
let d = res.data;
|
|
|
|
|
|
return {
|
|
|
authorId: authorId,
|
|
|
avatar: d.avatar,
|
|
|
name: d.name,
|
|
|
intro: d.author_desc,
|
|
|
authorUrl: d.name ? helpers.urlFormat('/Index/editor', { 'author_id': authorId }, 'guang') : ''
|
|
|
authorUrl: d.name ? helpers.urlFormat('/Index/editor', {author_id: authorId }, 'guang') : ''
|
|
|
};
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -462,19 +433,17 @@ const getAuthor = authorId => { |
|
|
* 获取文章基本信息,文章标题(不含内容)
|
|
|
*/
|
|
|
const getArticleInfo = aid => {
|
|
|
|
|
|
return serviceApi.get('guang/service/v2/article/getArticle', {
|
|
|
article_id: aid
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
let d = res.data;
|
|
|
|
|
|
let tags = [];
|
|
|
if (d.tags) {
|
|
|
|
|
|
for (let t of d.tags) {
|
|
|
tags.push(_formatTag(t));
|
|
|
if (d.tags) {
|
|
|
for (let i = 0; i < d.tags.length; i++) {
|
|
|
tags.push(_formatTag(d.tags[i]));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -494,17 +463,14 @@ const getArticleInfo = aid => { |
|
|
};
|
|
|
|
|
|
const _formatProduct = (products, arr) => {
|
|
|
|
|
|
let result = [];
|
|
|
|
|
|
|
|
|
_.forEach(products, (val, key) => {
|
|
|
|
|
|
_.forEach(products, val => {
|
|
|
let goods = {
|
|
|
thumb: helpers.image(val.default_images, 235, 314),
|
|
|
name: val.product_name,
|
|
|
salePrice: val.sales_price,
|
|
|
url: helpers.getUrlBySkc(val.product_id, val.goods_list[0]['goods_id'], val.cn_alphabet)
|
|
|
url: helpers.getUrlBySkc(val.product_id, val.goods_list[0].goods_id, val.cn_alphabet)
|
|
|
};
|
|
|
|
|
|
if (val.market_price !== val.sales_price) {
|
...
|
...
|
@@ -512,9 +478,8 @@ const _formatProduct = (products, arr) => { |
|
|
}
|
|
|
|
|
|
_.forEach(arr, (v, k) => {
|
|
|
if (k == val.product_skn) {
|
|
|
if (k === val.product_skn) {
|
|
|
goods.thumb = helpers.image(v, 235, 314);
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -529,12 +494,11 @@ const _formatProduct = (products, arr) => { |
|
|
*/
|
|
|
const getProductList = (params, arr) => {
|
|
|
|
|
|
return yohoApi.get('', Object.assign({
|
|
|
return yohoApi.get('', _.assign({
|
|
|
method: 'web.search.search',
|
|
|
order: 's_n_desc',
|
|
|
limit: 60
|
|
|
}, params)).then(ret => {
|
|
|
|
|
|
if (ret && ret.code === 200 && ret.data && ret.data.product_list) {
|
|
|
return _formatProduct(ret.data.product_list, arr);
|
|
|
}
|
...
|
...
|
@@ -547,7 +511,7 @@ const _articleContentFormat = { |
|
|
let productSkn = [],
|
|
|
arr = {};
|
|
|
|
|
|
_.forEach(goods, (val, key) => {
|
|
|
_.forEach(goods, val => {
|
|
|
productSkn.push(val.id);
|
|
|
arr[val.id] = val.src;
|
|
|
});
|
...
|
...
|
@@ -564,29 +528,28 @@ const _articleContentFormat = { |
|
|
},
|
|
|
goodsGroup: goodsGroup => {
|
|
|
|
|
|
let result = [], groupSkn = {};
|
|
|
let result = [];
|
|
|
|
|
|
_.forEach(goodsGroup, (val, key) => {
|
|
|
_.forEach(goodsGroup, val => {
|
|
|
if (val && val.list) {
|
|
|
|
|
|
let productSkn = [];
|
|
|
let arr = {};
|
|
|
|
|
|
for (let it of val.list) {
|
|
|
productSkn.push(it.id);
|
|
|
arr[it.id] = it.src;
|
|
|
}
|
|
|
|
|
|
if (productSkn.length) {
|
|
|
|
|
|
// 包含多个对象,每对象里list都取数据,最终每个list只取前4个
|
|
|
let pms = getProductList({
|
|
|
result.push(getProductList({
|
|
|
query: productSkn.join(',')
|
|
|
}, arr).then(products => {
|
|
|
let p = products.slice(0, 4);
|
|
|
|
|
|
return p;
|
|
|
});
|
|
|
result.push(pms);
|
|
|
}));
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -597,16 +560,18 @@ const _articleContentFormat = { |
|
|
return data;
|
|
|
},
|
|
|
singleImage: data => {
|
|
|
if (data && data[0] && data[0]['src']) {
|
|
|
if (data && data[0] && data[0].src) {
|
|
|
return {
|
|
|
pic: helpers.image(data[0]['src'], 640, 640)
|
|
|
pic: helpers.image(data[0].src, 640, 640)
|
|
|
};
|
|
|
}
|
|
|
return null;
|
|
|
},
|
|
|
smallPic: data => {
|
|
|
let result = {
|
|
|
smallPic: []
|
|
|
};
|
|
|
|
|
|
let result = { smallPic: [] };
|
|
|
_.forEach(data, (it, key) => {
|
|
|
if (key < 2) {
|
|
|
result.smallPic.push(helpers.image(it.src, 600, 600));
|
...
|
...
|
@@ -614,9 +579,7 @@ const _articleContentFormat = { |
|
|
});
|
|
|
return result;
|
|
|
},
|
|
|
link: data => {
|
|
|
return {};
|
|
|
}
|
|
|
link: () => ({})
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -643,7 +606,10 @@ const getArticleContent = aid => { |
|
|
// 可能包含多个list,则有多个promise
|
|
|
ggpromises = ggpromises.concat(_articleContentFormat.goodsGroup(val.data));
|
|
|
} else {
|
|
|
content.push(_.isFunction(_articleContentFormat[key]) ? _articleContentFormat[key](val.data) : '');
|
|
|
let other = _.isFunction(_articleContentFormat[key]) ?
|
|
|
_articleContentFormat[key](val.data) : '';
|
|
|
|
|
|
content.push(other);
|
|
|
}
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -704,13 +670,11 @@ const getArticleBaseInfo = (aid, uid, udid) => { |
|
|
id: aid,
|
|
|
uid: uid,
|
|
|
udid: udid
|
|
|
}).then(res => {
|
|
|
return {
|
|
|
isLike: res && res.isPraise === 'Y',
|
|
|
likeNum: res.praise_num || 0,
|
|
|
isCollected: res && res.isFavor === 'Y'
|
|
|
};
|
|
|
});
|
|
|
}).then(res => ({
|
|
|
isLike: res && res.isPraise === 'Y',
|
|
|
likeNum: res.praise_num || 0,
|
|
|
isCollected: res && res.isFavor === 'Y'
|
|
|
}));
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -726,7 +690,6 @@ const getArticleRelateBrand = aid => { |
|
|
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
return _.map(res.data, it => {
|
|
|
|
|
|
it.thumb = it.thumb;
|
|
|
it.url = it.url;
|
|
|
return it;
|
...
|
...
|
@@ -754,7 +717,6 @@ const getRelateArticleList = (aid, tag, size) => { |
|
|
}).then(res => {
|
|
|
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);
|
|
|
return it;
|
...
|
...
|
@@ -767,7 +729,6 @@ const getRelateArticleList = (aid, tag, size) => { |
|
|
* 获取文章评论数据
|
|
|
*/
|
|
|
const getArticleComments = (aid, page, pageSize) => {
|
|
|
|
|
|
page = page || 1;
|
|
|
pageSize = pageSize || 20;
|
|
|
|
...
|
...
|
@@ -776,15 +737,17 @@ const getArticleComments = (aid, page, pageSize) => { |
|
|
page: page,
|
|
|
pageSize: pageSize
|
|
|
}).then(res => {
|
|
|
let result = {};
|
|
|
|
|
|
if (res && res.code === 200) {
|
|
|
let num = (res.data && res.data.total) || 0;
|
|
|
|
|
|
let list = [];
|
|
|
|
|
|
if (num > 0 && res.data.list) {
|
|
|
for (let it of res.data.list) {
|
|
|
let iList = res.data.list;
|
|
|
|
|
|
for (let i = 0; i < iList.length; i++) {
|
|
|
let it = iList[i];
|
|
|
|
|
|
list.push({
|
|
|
avatar: helpers.image(it.avator, 100, 100),
|
|
|
name: it.username,
|
...
|
...
|
@@ -799,7 +762,6 @@ const getArticleComments = (aid, page, pageSize) => { |
|
|
list: list
|
|
|
};
|
|
|
}
|
|
|
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -809,20 +771,17 @@ const getArticleComments = (aid, page, pageSize) => { |
|
|
* @param $uid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const addComment = (aid, uid, content) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v1/comments/add', {
|
|
|
article_id: aid,
|
|
|
uid: uid,
|
|
|
content: content
|
|
|
}).then(res => {
|
|
|
if (res && res.code === 200) {
|
|
|
return res.data;
|
|
|
} else {
|
|
|
return Promise.reject('评论失败');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
const addComment = (aid, uid, content) => serviceApi.get('guang/api/v1/comments/add', {
|
|
|
article_id: aid,
|
|
|
uid: uid,
|
|
|
content: content
|
|
|
}).then(res => {
|
|
|
if (res && res.code === 200) {
|
|
|
return res.data;
|
|
|
} else {
|
|
|
return Promise.reject('评论失败');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 文章点赞
|
...
|
...
|
@@ -830,13 +789,10 @@ const addComment = (aid, uid, content) => { |
|
|
* @param $uid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const praise = (aid, udid) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/praise/setPraise', {
|
|
|
article_id: aid,
|
|
|
udid: udid
|
|
|
});
|
|
|
};
|
|
|
const praise = (aid, udid) => serviceApi.get('guang/api/v2/praise/setPraise', {
|
|
|
article_id: aid,
|
|
|
udid: udid
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 文章点赞
|
...
|
...
|
@@ -844,13 +800,10 @@ const praise = (aid, udid) => { |
|
|
* @param $uid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const cancelPraise = (aid, udid) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v2/praise/cancel', {
|
|
|
article_id: aid,
|
|
|
udid: udid
|
|
|
});
|
|
|
};
|
|
|
const cancelPraise = (aid, udid) => serviceApi.get('guang/api/v2/praise/cancel', {
|
|
|
article_id: aid,
|
|
|
udid: udid
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 收藏文章
|
...
|
...
|
@@ -858,19 +811,10 @@ const cancelPraise = (aid, udid) => { |
|
|
* @param $uid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const collect = (aid, uid) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v1/favorite/setFavorite', {
|
|
|
article_id: aid,
|
|
|
uid: uid
|
|
|
});/* .then(res => {
|
|
|
if (res && res.code === 200) {
|
|
|
return res.data;
|
|
|
} else {
|
|
|
return Promise.reject('收藏失败');
|
|
|
}
|
|
|
});*/
|
|
|
};
|
|
|
const collect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/setFavorite', {
|
|
|
article_id: aid,
|
|
|
uid: uid
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 取消收藏文章
|
...
|
...
|
@@ -878,13 +822,10 @@ const collect = (aid, uid) => { |
|
|
* @param $uid
|
|
|
* @return mixed
|
|
|
*/
|
|
|
const cancelCollect = (aid, uid) => {
|
|
|
|
|
|
return serviceApi.get('guang/api/v1/favorite/cancelFavorite', {
|
|
|
article_id: aid,
|
|
|
uid: uid
|
|
|
});
|
|
|
};
|
|
|
const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancelFavorite', {
|
|
|
article_id: aid,
|
|
|
uid: uid
|
|
|
});
|
|
|
|
|
|
module.exports = {
|
|
|
getArticleList,
|
...
|
...
|
@@ -892,7 +833,7 @@ module.exports = { |
|
|
getAds,
|
|
|
getBanner,
|
|
|
getCategory,
|
|
|
getTjArticles,
|
|
|
getRecoArticles,
|
|
|
getPathNav,
|
|
|
getAuthor,
|
|
|
|
...
|
...
|
|