Authored by 郝肖肖

'newsale-ctx'

... ... @@ -11,7 +11,6 @@ const helpers = global.yoho.helpers;
const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
class DetailModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
... ...
... ... @@ -44,8 +44,7 @@ const index = (req, res, next) => {
// 唤起 APP 的路径
res.locals.appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.top100","params":{"page":"0"}}';
newsaleModel.getHotRank(codeKey).then((result) => {
req.ctx(newsaleModel).getHotRank(codeKey).then((result) => {
res.render('newsale/hotrank', {
module: 'product',
page: 'hot-rank',
... ... @@ -68,8 +67,7 @@ const selectHotrank = (req, res, next) => {
let yhChannel = (req.query.gender && yhchannels[req.query.gender]) ||
(req.cookies._Channel && channels[req.cookies._Channel]) || 1;
newsaleModel.selectHotrank(yhChannel, sort, tab_id, limit, page, notab).then((result) => {
req.ctx(newsaleModel).selectHotrank(yhChannel, sort, tab_id, limit, page, notab).then((result) => {
res.render('newsale/hotlist', {
layout: false,
tabs: result.tabs,
... ...
... ... @@ -2,16 +2,25 @@
const utils = '../../../utils';
const productNameProcess = require(`${utils}/product-name-process`);
const api = global.yoho.API;
const _ = require('lodash');
const serviceAPI = global.yoho.ServiceAPI;
const logger = global.yoho.logger;
const getHotRank = (codeKey) => {
return serviceAPI.get('operations/api/v5/resource/get', {
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getHotRank(codeKey) {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: codeKey
}, {
},
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -38,9 +47,9 @@ const getHotRank = (codeKey) => {
return {};
}
});
};
}
const selectHotrank = (yhChannel, sort, tabId, limit, page, notab) => {
selectHotrank(yhChannel, sort, tabId, limit, page, notab) {
let param = {
method: 'app.search.top',
yh_channel: yhChannel,
... ... @@ -56,8 +65,11 @@ const selectHotrank = (yhChannel, sort, tabId, limit, page, notab) => {
param.tab_id = tabId;
}
return api.get('', param, {
return this.get({
data: param,
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200 && result.data.product_list) {
... ... @@ -127,9 +139,5 @@ const selectHotrank = (yhChannel, sort, tabId, limit, page, notab) => {
}
});
};
module.exports = {
getHotRank,
selectHotrank
}
};
... ...