Authored by 毕凯

Merge branch 'feature/ctx' into 'feature/contextMod'

Feature/ctx



See merge request !878
... ... @@ -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', {});
});
... ...
... ... @@ -22,10 +22,15 @@ class IndexModel extends global.yoho.BaseModel {
* @return {[object]}
*/
getAuthor(id) {
return serviceAPI.get('guang/service/v1/author/getAuthor', {
author_id: id
}, {
cache: true
return this.get({
api: serviceAPI,
url: 'guang/service/v1/author/getAuthor',
data: {
author_id: id
},
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return result;
... ... @@ -50,19 +55,22 @@ class IndexModel extends global.yoho.BaseModel {
* @return {[array]}
*/
getArticleList(gender, sortId, uid, udid, page, tag, authorId, limit, useCache) {
let param = {
page: page || 1,
uid: uid || 0,
udid: udid || '',
gender: gender || '',
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: 4
};
return serviceAPI.get('guang/api/v2/article/getList', param, {
cache: useCache
return this.get({
api: serviceAPI,
url: 'guang/api/v2/article/getList',
data: {
page: page || 1,
uid: uid || 0,
udid: udid || '',
gender: gender || '',
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: 4
},
param: {
cache: useCache
}
}).then((result) => {
if (result && result.code === 200) {
return result;
... ... @@ -305,7 +313,11 @@ class IndexModel extends global.yoho.BaseModel {
});
}
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params);
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getSimpleArticleList',
data: params
});
}
/**
... ... @@ -315,10 +327,14 @@ class IndexModel extends global.yoho.BaseModel {
*/
getDynamicDataById(id, uid, udid) {
return serviceAPI.get('guang/api/v6/article/getArticlePraiseAndFavor', {
id: id,
uid: uid,
udid: udid
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getArticlePraiseAndFavor',
data: {
id: id,
uid: uid,
udid: udid
}
});
}
... ... @@ -327,8 +343,12 @@ class IndexModel extends global.yoho.BaseModel {
* @param {*} params
*/
_getTopArticles(params) {
return serviceAPI.get('guang/api/v6/article/getTopList', {
gender: params.gender
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getTopList',
data: {
gender: params.gender
}
});
}
... ... @@ -336,11 +356,13 @@ class IndexModel extends global.yoho.BaseModel {
* 逛分类
*/
_category() {
return serviceAPI.get('/guang/api/v1/category/get', {
}, {
cache: true,
code: 200
return this.get({
api: serviceAPI,
url: '/guang/api/v1/category/get',
param: {
cache: true,
code: 200
}
});
}
... ... @@ -348,24 +370,23 @@ class IndexModel extends global.yoho.BaseModel {
* 逛内容列表
*/
_article(param) {
return serviceAPI.get('/guang/api/v2/article/getList', {
gender: param.gender,
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type || 0,
tag: param.tag ? param.tag : null,
limit: 4
// author_id: param.authorId ? param.authorId : null,
// limit: param.limit ? param.limit : null
}, {
cache: true,
code: 200
return this.get({
api: serviceAPI,
url: '/guang/api/v2/article/getList',
data: {
gender: param.gender,
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type || 0,
tag: param.tag ? param.tag : null,
limit: 4
}, param: {
cache: true,
code: 200
}
}).then(result => {
return result;
});
}
}
... ...
... ... @@ -24,7 +24,7 @@ const domains = {
module.exports = {
app: 'h5',
appVersion: '6.0.1', // 调用api的版本
appVersion: '6.0.2', // 调用api的版本
port: 6001,
siteUrl: '//m.yohobuy.com',
assetUrl: '//127.0.0.1:5001',
... ...