...
|
...
|
@@ -5,7 +5,6 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
const serviceAPI = global.yoho.ServiceAPI;
|
|
|
const api = global.yoho.API;
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
...
|
...
|
@@ -74,9 +73,12 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
|
|
|
_getLeftNav(choosed) {
|
|
|
choosed = choosed || 'all';
|
|
|
|
|
|
return serviceAPI.get('operations/api/v6/category/getCategory', {}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'operations/api/v6/category/getCategory',
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
}).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
|
...
|
...
|
@@ -86,8 +88,12 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
_getShareData(id) {
|
|
|
return serviceAPI.get('guang/api/v6/share/guang', {
|
|
|
id: id
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v6/share/guang',
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
}).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
|
...
|
...
|
@@ -101,10 +107,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getArticle(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_ARTICLE}getArticle`,
|
|
|
data: {
|
|
|
article_id: articleId
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -113,10 +124,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} authorId
|
|
|
*/
|
|
|
_getAuthor(authorId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, {
|
|
|
author_id: authorId
|
|
|
}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_AUTHOR}getAuthor`,
|
|
|
data: {
|
|
|
author_id: authorId
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -125,10 +141,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getArticleContent(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
|
|
|
data: {
|
|
|
article_id: articleId
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -137,10 +158,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} articleId
|
|
|
*/
|
|
|
_getBrand(articleId) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, {
|
|
|
article_id: articleId
|
|
|
}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_ARTICLE}getBrand`,
|
|
|
data: {
|
|
|
article_id: articleId
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -150,13 +176,18 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} tag
|
|
|
*/
|
|
|
_getOtherArticle(articleId, tag) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, {
|
|
|
article_id: articleId,
|
|
|
tags: tag,
|
|
|
offset: 0,
|
|
|
limit: 3
|
|
|
}, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_ARTICLE}getOtherArticle`,
|
|
|
data: {
|
|
|
article_id: articleId,
|
|
|
tags: tag,
|
|
|
offset: 0,
|
|
|
limit: 3
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -164,10 +195,12 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* APP 获取微信模块
|
|
|
*/
|
|
|
_getSingleTemplateWechat() {
|
|
|
return api.get('', {
|
|
|
method: 'app.resources.getSingleTemplate',
|
|
|
module: 'wechat',
|
|
|
key: 'guang_detail_wechat'
|
|
|
return this.get({
|
|
|
data: {
|
|
|
method: 'app.resources.getSingleTemplate',
|
|
|
module: 'wechat',
|
|
|
key: 'guang_detail_wechat'
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -320,13 +353,16 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @return {[object]}
|
|
|
*/
|
|
|
intro(id) {
|
|
|
let param = {
|
|
|
article_id: id,
|
|
|
client_type: 'h5'
|
|
|
};
|
|
|
|
|
|
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
|
|
|
data: {
|
|
|
article_id: id,
|
|
|
client_type: 'h5'
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -338,16 +374,16 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
productInfoBySkns(sknString) {
|
|
|
let limit = sknString && sknString.split(',').length;
|
|
|
|
|
|
// 调用搜索接口
|
|
|
let param = {
|
|
|
method: 'app.search.recomandLi',
|
|
|
query: sknString,
|
|
|
order: 's_t_desc',
|
|
|
limit: limit || 1
|
|
|
};
|
|
|
|
|
|
return api.get('', param, {
|
|
|
cache: true
|
|
|
return this.get({
|
|
|
data: {
|
|
|
method: 'app.search.recomandLi',
|
|
|
query: sknString,
|
|
|
order: 's_t_desc',
|
|
|
limit: limit || 1
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
}).then(result => {
|
|
|
return _.get(result, 'data.product_list', []);
|
|
|
});
|
...
|
...
|
@@ -357,11 +393,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* 获取文章评论列表
|
|
|
*/
|
|
|
comments(params) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, {
|
|
|
article_id: params.article_id,
|
|
|
page: params.page,
|
|
|
limit: params.limit || 20,
|
|
|
udid: params.udid
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_COMMENTS}getList`,
|
|
|
data: {
|
|
|
article_id: params.article_id,
|
|
|
page: params.page,
|
|
|
limit: params.limit || 20,
|
|
|
udid: params.udid
|
|
|
}
|
|
|
}).then(result => {
|
|
|
return _.get(result, 'data.list', []);
|
|
|
});
|
...
|
...
|
@@ -372,11 +412,15 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} params
|
|
|
*/
|
|
|
commentsTotal(params) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, {
|
|
|
article_id: params.article_id,
|
|
|
page: 1,
|
|
|
limit: 1,
|
|
|
udid: params.udid
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_COMMENTS}getList`,
|
|
|
data: {
|
|
|
article_id: params.article_id,
|
|
|
page: 1,
|
|
|
limit: 1,
|
|
|
udid: params.udid
|
|
|
}
|
|
|
}).then(result => {
|
|
|
return _.get(result, 'data.total', 0);
|
|
|
});
|
...
|
...
|
@@ -387,10 +431,14 @@ class DetailModel extends global.yoho.BaseModel { |
|
|
* @param {*} params
|
|
|
*/
|
|
|
getArticlePraiseAndFavor(params) {
|
|
|
return serviceAPI.get(`${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`, {
|
|
|
uid: params.uid,
|
|
|
id: params.id,
|
|
|
udid: params.udid
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: `${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`,
|
|
|
data: {
|
|
|
uid: params.uid,
|
|
|
id: params.id,
|
|
|
udid: params.udid
|
|
|
}
|
|
|
}).then(result => {
|
|
|
return _.get(result, 'data', {});
|
|
|
});
|
...
|
...
|
|