Authored by zhangxiaoru

editorial

... ... @@ -13,7 +13,7 @@ const brand = require('../models/brand');
* @param res
*/
const index = (req, res, next) => {
let channel = req.cookies._Channel || 'men';
let channel = req.yoho.channel || 'men';
let contentCode = '';
let name = '';
... ...
... ... @@ -19,11 +19,22 @@ const index = (req, res, next) => {
let pageNum = req.query.page || 1;
let limit = req.query.limit || 20;
let appType = 1;
let udid = md5(req.ip);
let channel = req.cookies._Channel || 'men';
let gender = '';
if(channel === 'men') {
gender = '1,3';
} else if (channel === 'women') {
gender = '2,3';
} else {
gender = '3,3';
}
console.log(gender)
// let gender = req.query.brand || 1;
editorialModel.getIndexData(pageNum, limit, appType, udid, gender).then((result) => {
editorialModel.getIndexData(pageNum, limit, appType).then((result) => {
// console.log(result.msg)
res.display('index', {
module: 'editorial',
page: 'index',
... ... @@ -67,8 +78,9 @@ const list = (req, res) => {
let limit = req.query.limit || 20;
let tag = req.query.query;
let authorId = req.query.authorId;
let udid = md5(req.ip);
editorialModel.getListData(pageNum, limit, tag, authorId).then((result) => {
editorialModel.getListData(pageNum, limit, tag, authorId, udid).then((result) => {
res.display('list', {
module: 'editorial',
... ... @@ -116,10 +128,10 @@ const list = (req, res) => {
*/
const detail = (req, res, next) => {
let id = req.params.id;
let appType = 1;
// let clientType = 'pc';
editorialModel.getDetailData(id).then((result) => {
editorialModel.getDetailData(id, appType).then((result) => {
res.display('detail', {
module: 'editorial',
page: 'detail',
... ...
... ... @@ -35,8 +35,6 @@ const _processListData = (list) => {
total: list.total
});
// console.log(list)
_.forEach(list.list.artList, (data) => {
if (data.author) {
... ... @@ -47,12 +45,13 @@ const _processListData = (list) => {
data.publishTime = data.publishTime.replace(/年|月/g, '/');
data.publishTime = data.publishTime.replace(/日/g, '');
console.log(data)
data.isPraise = data.isPraise === 'Y';
});
listData.tabs = list.list.artList;
//console.log(listData)
return listData;
};
... ... @@ -65,13 +64,16 @@ const _processListData = (list) => {
* @param limit
* @returns {*}
*/
const getIndexData = (pageNum, limit, appType) => {
const getIndexData = (pageNum, limit, appType, udid, gender) => {
return serviceAPI.get('guang/api/*/article/getList', {
page: pageNum,
limit: limit,
app_type: appType
app_type: appType,
udid: udid,
gender: gender
}).then((result) => {
if (result && result.code === 200) {
// console.log(result)
return _processListData(result.data);
} else {
logger.error('Information page list data return code is not 200');
... ... @@ -88,10 +90,11 @@ const getIndexData = (pageNum, limit, appType) => {
* @param authorId
* @returns {*}
*/
const getListData = (pageNum, limit, tag, authorId) => {
const getListData = (pageNum, limit, tag, authorId, udid) => {
let param = {
page: pageNum,
limit: limit
limit: limit,
udid: udid
};
if (tag) {
... ... @@ -188,8 +191,8 @@ const _processHeadData = (list) => {
}
});
newData.headData.time = newData.headData.time.replace(/-/g, '/');
newData.headData.time = newData.headData.time.replace(':00', '', 2);
// newData.headData.time = newData.headData.time.replace(/-/g, '/');
// newData.headData.time = newData.headData.time.replace(':00', '', 2);
let id = newData.headData.authorId;
... ... @@ -341,9 +344,10 @@ const _processContentData = (list) => {
* @param id
* @returns {*}
*/
const _getHeadData = (id) => {
const _getHeadData = (id, appType) => {
return serviceAPI.get('/guang/api/*/article/getArticleBaseInfo', {
id: id
id: id,
app_type: appType
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -400,6 +404,10 @@ const _getCommentsData = (id) => {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
_.forEach(result.data.list, function(data) {
data.create_time = data.create_time.replace(/月/g, '/');
data.create_time = data.create_time.replace(/日/g, '');
});
return camelCase(result.data);
} else {
logger.error('Review data return code is not 200');
... ... @@ -433,12 +441,15 @@ const _getRelateBrand = (id) => {
});
};
const _getArticlePre = (id) => {
const _getArticlePre = (id, appType) => {
return serviceAPI.get('guang/api/*/article/getArticlePre', {
id: id
id: id,
app_type: appType
}).then((result) => {
if (result && result.code === 200) {
// console.log(result);
// console.log(1)
// let id = result.data.articleIdPre;
// _getHeadData(id, appType);
return result;
} else {
logger.error('上一篇不是200');
... ... @@ -554,13 +565,13 @@ const shareData = () => {
* @param id
* @returns {*}
*/
const getDetailData = (id) => {
const getDetailData = (id, appType) => {
return co(function *() {
let result = yield Promise.all([_getHeadData(id),
let result = yield Promise.all([_getHeadData(id, appType),
_getArticleData(id),
_getContentData(id),
_getCommentsData(id),
_getArticlePre(id),
_getArticlePre(id, appType),
_getRelateBrand(id)]);
let res = yield _processHeadData([result[0], result[1], result[3]]);
... ...
... ... @@ -8,7 +8,7 @@
<div class="content">{{intro}}</div>
<div class="msg-app">
<span class="like-comment">
<i class="iconfont like-icon{{#if isPraise}}liked{{/if}}">&#xe60e;</i>
<i class="iconfont like-icon {{#if isPraise}}liked{{/if}}">&#xe60e;</i>
<b class="like-num">{{praiseNum}}</b>
</span>
</div>
... ...
... ... @@ -414,9 +414,9 @@
display: inline-block;
height: 48px;
line-height: 48px;
font-size: 12px;
color: #c8c8c8;
float: right;
.exceed-count {
color: #f00;
... ... @@ -425,7 +425,7 @@
.publish-btn {
margin-top: 10px;
float: right;
float: left;
width: 100px;
height: 30px;
line-height: 33px;
... ...