...
|
...
|
@@ -96,6 +96,81 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取文章接口调用
|
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getArticle(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取作者接口调用
|
|
|
* @param {*} authorId
|
|
|
*/
|
|
|
_getAuthor(authorId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, {
|
|
|
author_id: authorId
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取文章详情接口调用
|
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getArticleContent(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取文章相关品牌接口调用
|
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getBrand(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取资讯相关的其它资讯接口调用
|
|
|
* @param {*} articleId
|
|
|
* @param {*} tag
|
|
|
*/
|
|
|
_getOtherArticle(articleId, tag) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, {
|
|
|
article_id: articleId,
|
|
|
tags: tag,
|
|
|
offset: 0,
|
|
|
limit: 3
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* APP 获取微信模块
|
|
|
*/
|
|
|
_getSingleTemplateWechat() {
|
|
|
return api.get('', {
|
|
|
method: 'app.resources.getSingleTemplate',
|
|
|
module: 'wechat',
|
|
|
key: 'guang_detail_wechat'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [逛资讯详情页数据封装]
|
|
|
* @param {[int]} id [内容ID]
|
|
|
* @param {Boolean} isApp [标识是否是APP访问]
|
...
|
...
|
@@ -111,110 +186,51 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
};
|
|
|
|
|
|
// 获取资讯
|
|
|
let param = {
|
|
|
article_id: id
|
|
|
|
|
|
// private_key: sign.privateKey[clientType]
|
|
|
};
|
|
|
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, param, {
|
|
|
cache: true
|
|
|
}).then(data => {
|
|
|
// 接口要判断一下返回状态是否成功
|
|
|
return this._getArticle(id).then(data => {
|
|
|
// 调用接口失败
|
|
|
if (!data || data.code !== 200) {
|
|
|
result.code = 400;
|
|
|
return result;
|
|
|
}
|
|
|
let article = data.data || {};
|
|
|
|
|
|
result.getArticle = article;
|
|
|
|
|
|
let promises = [];
|
|
|
|
|
|
// 获取作者信息
|
|
|
param = {
|
|
|
author_id: article.author_id
|
|
|
};
|
|
|
|
|
|
// param.client_secret = sign.apiSign(param);
|
|
|
promises.push(serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, param, {
|
|
|
cache: true
|
|
|
}));
|
|
|
|
|
|
// 获取资讯内容
|
|
|
param = {
|
|
|
article_id: id
|
|
|
|
|
|
// private_key: sign.privateKey[clientType]
|
|
|
};
|
|
|
|
|
|
// param.client_secret = sign.apiSign(param);
|
|
|
promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, {
|
|
|
cache: true
|
|
|
}));
|
|
|
|
|
|
// 获取资讯相关的品牌
|
|
|
param = {
|
|
|
article_id: id
|
|
|
|
|
|
// private_key: sign.privateKey[clientType]
|
|
|
};
|
|
|
|
|
|
// param.client_secret = sign.apiSign(param);
|
|
|
promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, param, {
|
|
|
cache: true
|
|
|
}));
|
|
|
let article = result.getArticle = data && data.data || {};
|
|
|
let promises = [
|
|
|
this._getAuthor(article.author_id),
|
|
|
this._getArticleContent(id),
|
|
|
this._getBrand(id)
|
|
|
];
|
|
|
|
|
|
// 获取资讯相关的其它资讯
|
|
|
if (typeof article.tag !== 'undefined') {
|
|
|
param = {
|
|
|
article_id: id,
|
|
|
tags: article.tag,
|
|
|
offset: 0,
|
|
|
limit: 3
|
|
|
|
|
|
// private_key: sign.privateKey[clientType]
|
|
|
};
|
|
|
|
|
|
// param.client_secret = sign.apiSign(param);
|
|
|
promises.push(serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, param, {
|
|
|
cache: true
|
|
|
}));
|
|
|
promises.push(this._getOtherArticle(id, article.tag));
|
|
|
}
|
|
|
|
|
|
// APP 获取微信模块
|
|
|
if (isApp) {
|
|
|
promises.push(api.get('', {
|
|
|
method: 'app.resources.getSingleTemplate',
|
|
|
module: 'wechat',
|
|
|
key: 'guang_detail_wechat'
|
|
|
}));
|
|
|
promises.push(this._getSingleTemplateWechat);
|
|
|
}
|
|
|
|
|
|
if (isShare) {
|
|
|
let navGender = _.cloneDeep(channel);
|
|
|
|
|
|
promises.push(this._getLeftNav(navGender));
|
|
|
}
|
|
|
|
|
|
if (isShare) {
|
|
|
promises.push(this._getShareData(id));
|
|
|
promises.push(
|
|
|
this._getLeftNav(navGender),
|
|
|
this._getShareData(id)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
return Promise.all(promises).then(datas => {
|
|
|
|
|
|
let getArticleContent = [];
|
|
|
|
|
|
if (datas) {
|
|
|
if (datas[1]) {
|
|
|
|
|
|
getArticleContent = datas[1].data;
|
|
|
|
|
|
result.getArticleContent = getArticleContent;
|
|
|
if (!datas) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if (datas[1]) {
|
|
|
result.getArticleContent = getArticleContent = datas[1].data;
|
|
|
}
|
|
|
|
|
|
if (isApp && datas[4] && datas[4].data) {
|
|
|
|
|
|
let preCount = 0;
|
|
|
let i;
|
|
|
|
...
|
...
|
@@ -235,7 +251,6 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
if (isShare && datas[5]) {
|
|
|
|
|
|
if (datas[5].wechatShareImgUrl) {
|
|
|
datas[5].wechatShareImgUrl =
|
|
|
datas[5].wechatShareImgUrl.substring(datas[5].wechatShareImgUrl.indexOf('//'));
|
...
|
...
|
@@ -273,7 +288,6 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
getArticleContent.splice(preCount, 0, {
|
|
|
shareCode: datas[5]
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (datas[0]) {
|
...
|
...
|
@@ -294,7 +308,6 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
result.getOtherArticle = datas[3].data;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
});
|
...
|
...
|
|