Authored by 郝肖肖

'news-接口'

... ... @@ -12,11 +12,8 @@ const newsService = require('../models/news-service');
*/
exports.index = (req, res, next) => {
let channel = req.yoho.channel;
let page = req.query.page || 1;
let pageSize = req.query.pageSize || 20;
let type = req.query.type || 0;
req.ctx(newsService).getIndexList(channel, req).then(result => {
req.ctx(newsService).getIndexList(channel, req.body).then(result => {
return res.render('news-index', Object.assign({
title: '新闻 | ' + (res.locals.title || ''),
module: 'news',
... ... @@ -25,11 +22,17 @@ exports.index = (req, res, next) => {
}).catch(next);
};
/**
* 文章详情
*/
exports.detail = (req, res, next) => {
let channel = req.yoho.channel;
req.ctx(newsService).detail(channel, req.body).then(result => {
return res.render('news-detail', Object.assign({
title: '新闻详情页 | ' + (res.locals.title || ''),
module: 'news',
page: 'detail'
}, result));
}).catch(next);
};
... ...
'use strict';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getPolymerizationList(params) {
return this.get({
url: 'yohonow/api/page/getPolymerizationList',
data: params,
param: {
cache: true
},
api: global.yoho.YohoNowApi
});
}
getContentDetail(params) {
return this.get({
url: 'yohoboyins/v5/channel/getContentDetail',
data: {parameters: JSON.stringify(params)},
param: {
cache: true
},
api: global.yoho.YohoNowApi
});
}
};
... ...
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
const pager = require(`${global.utils}/pager`).setPager;
const headerModel = require('../../../doraemon/models/header');
const NewsAPi = require('./news-api');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getIndexList(channel) {
getIndexList(channel, param) {
let params = {
type: 'wechat',
limit: 20,
page: param.page || 1
};
let apiMethod = [
headerModel.requestHeaderData(channel),
new NewsAPi(this.ctx).getPolymerizationList(params)
];
return Promise.all(apiMethod).then(result => {
let responseData = {};
// 头部数据
Object.assign(responseData, result[0]);
return responseData;
});
}
detail(channel, param) {
let params = {
id: param.id || 20735,
cid: param.cid || 11893
};
let apiMethod = [
headerModel.requestHeaderData(channel),
new NewsAPi(this.ctx).getContentDetail(params)
];
return Promise.all(apiMethod).then(result => {
... ...
... ... @@ -12,6 +12,7 @@ const cRoot = './controllers';
const newsController = require(`${cRoot}/index`);
router.get(['/', '/index/index'], newsController.index);
router.get(['/detail'], newsController.detail);
// ajax
... ...
<div class="news-page yoho-page clearfix">
999
{{> common/path-nav}}
</div>
... ...
... ... @@ -23,6 +23,7 @@ module.exports = {
serviceNotify: 'http://api-test3.yohops.com:9999/',
global: 'http://global-test-soa.yohops.com:9999/',
platformApi: 'http://192.168.102.48:8088/',
yohoNowApi: 'http://yohonow-test.yohops.com:9999/',
// test2
// singleApi: 'http://api-test2.yohops.com:9999/',
... ... @@ -194,7 +195,8 @@ if (isProduction) {
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
platformApi: 'http://api.platform.yohoops.org',
unionApi: 'http://union.yoho.cn/'
unionApi: 'http://union.yoho.cn/',
yohoNowApi: 'http://new.yohoboys.com/',
},
memcache: {
master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
... ... @@ -249,7 +251,8 @@ if (isProduction) {
search: process.env.TEST_SEARCH || 'http://192.168.102.216:8080/yohosearch/',
serviceNotify: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api'
imCs: 'http://im.yohobuy.com/api',
yohoNowApi: process.env.YOHO_NOW_API || 'http://yohonow-test.yohops.com:9999/',
},
useOneapm: true,
useCache: true,
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common');
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common');
... ...