Authored by zhangxiaoru

资讯首页

/**
* 资讯
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/7/4
*/
'use strict';
const index = (req, res) => {
var pageNum = req.query.page || 1;
res.render('index', {
module: 'editorial',
page: 'index',
title: '资讯',
editorial: {
nav: [
{
link: '//guang.yohobuy.com/index/index?type=0',
pathTitle: '首页',
name: 'MEN首页'
},
{
link: '/',
pathTitle: '资讯',
name: '咨询'
},
{
link: '/',
pathTitle: '资讯',
name: '咨询'
}
],
msgTypes: [
{
typeId: '0',
isActive: true,
type: '最新'
},
{
typeId: '1',
isActive: false,
type: '话题'
},
{
typeId: '2',
isActive: false,
type: '搭配'
},
{
typeId: '3',
isActive: false,
type: '潮人'
},
{
typeId: '4',
isActive: false,
type: '潮品'
}
],
mags: [
{
msgLeft: '潮品',
msgTitle: '很到位和范围的恢复文件和服务加热凤凰网二姐夫好无聊非互联网让发货文件符合我',
img: '',
msgContent: '鞋款定价回复即可老地方了服务可访问接待完了就服务来讲课费忘了空间访问量可放假',
time: '2016/05/25 19:36',
likeNum: '8'
},
{
msgLeft: '潮品',
msgTitle: '很到位和范围的恢复文件和服务加热凤凰网二姐夫好无聊非互联网让发货文件符合我',
img: '',
msgContent: '鞋款定价回复即可老地方了服务可访问接待完了就服务来讲课费忘了空间访问量可放假',
time: '2016/05/25 19:36',
likeNum: '8'
},
{
msgLeft: '潮品',
msgTitle: '很到位和范围的恢复文件和服务加热凤凰网二姐夫好无聊非互联网让发货文件符合我',
img: '',
msgContent: '鞋款定价回复即可老地方了服务可访问接待完了就服务来讲课费忘了空间访问量可放假',
time: '2016/05/25 19:36',
likeNum: '8'
}
]
},
helpers: {
// import component, path depends on your project
pagination: require('../../../doraemon/components/pagination/pagination').createPagination
}
});
};
module.exports = {
index // 组件demo页
};
... ...
/**
* sub app partial
* @author: zhangxiaoru<xiaoru.zhang@yoho.cn>
* @date: 2016/07/4
*/
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: 'helpers'
}));
// router
app.use(require('./router'));
module.exports = app;
... ...
/**
* router of sub app channel
* @author: zhangxiaoru<xiaoru.zhang@yoho.cn>
* @date: 2016/07/04
*/
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const editorial = require(cRoot + '/editorial');
router.get('/', editorial.index); // 咨询首页
// router.get('/list', editorial.list); // 咨询列表页
module.exports = router;
... ...
<div class="editorial-index-page">
{{# editorial}}
{{# nav}}
{{> path-nav}}
{{/ nav}}
<div class="index-content">
<ul class="msg-nav">
{{# msgTypes}}
<li data-type="{{typeId}}" {{#if isActive}}class="active"{{/if}}>
<a class="pjax-link" href="{{navUrl}}">{{type}}</a>
</li>
{{/ msgTypes}}
</ul>
<div id="msg-list" class="msg-list">
{{# msgs}}
{{> msg}}
{{/ msgs}}
</div>
</div>
{{/ editorial}}
</div>
\ No newline at end of file
... ...
<div class="content-msg clearfix" data-id="{{id}}">
<div class="msg-left">{{msgLeft}}</div>
<div class="msg-right">
<a class="msg-title">{{msgTitle}}</a>
<img class="lazy" data-original="{{img}}">
<div class="content">{{msgContent}}</div>
<div class="msg-app">
<span class="time">
<i class="iconfont">&#xe61b;</i>
<b class="time-word">{{time}}</b>
</span>
<span class="like-comment">
<i class="iconfont">&#xe60e;</i>
<b class="like-num">{{likeNum}}</b>
</span>
</div>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -11,4 +11,7 @@ module.exports = app => {
// 业务模块
//app.use('/passport', require('./apps/passport'));
//资讯
app.use('/editorial', require('./apps/editorial'));
};
... ...
{{#if nav}}
<p class="path-nav">
{{#each pathNav}}
{{#if href}}
<a {{#if @last}}class="last"{{/if}} href="{{href}}" title="{{pathTitle}}">{{{name}}}</a>
{{#each nav}}
{{#if link}}
<a {{#if @last}}class="last"{{/if}} href="{{link}}" title="{{pathTitle}}">{{{name}}}</a>
{{^}}
<span {{#if @last}}class="last"{{/if}} title="{{pathTitle}}">{{{name}}}</span>
{{/if}}
... ...
.editorial-index-page {
.index-content {
width: 1150px;
margin: 0 auto;
}
.msg-nav {
height: 35px;
border-bottom: 1px solid #eee;
padding-left: 300px;
padding-bottom: 5px;
li {
float: left;
height: 30px;
width: 120px;
line-height: 35px;
text-align: center;
font-size: 14px;
display: list-item;
list-style-type:none;
color: #999;
a {
display: block;
height: 100%;
width: 100%;
text-decoration: none;
color: #999;
}
&.active {
a {
color: #000;
}
}
}
}
}
@import "msg";
\ No newline at end of file
... ...
.content-msg {
margin-top: 40px;
margin-left: 110px;
}
.msg-left{
position: relative;
float: left;
width: 200px;
height: 30px;
margin-right: 80px;
line-height: 30px;
text-align:center;
border-bottom: 1px solid #bbb;
}
.msg-right {
float: left;
width: 643px;
border-bottom: 1px solid #eeeeee;
margin-top: 2px;
padding-bottom: 5px;
}
.msg-title {
font-size: 20px;
color: #333;
line-height: 30px;
max-height: 64px;
word-wrap: break-word;
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.lazy {
width: 640px;
height: 430px;
margin-top: 15px;
}
.content {
display: block;
font-size: 14px;
line-height: 24px;
word-wrap: break-word;
margin-top: 10px;
margin-bottom: 10px;
overflow : hidden;
word-wrap: break-word;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.msg-app {
height: 30px;
line-height: 30px;
font-size: 14px;
}
.time {
color: #a6a6a6;
margin-left: 3px;
}
.iconfont {
font-size: 14px;
margin-top: 0;
}
.time-word {
font-weight: normal;
}
.like-comment {
margin-left: 40px;
color: #a6a6a6;
cursor: pointer;
font-size: 14px;
}
.like-num {
font-weight: normal;
}
\ No newline at end of file
... ...
... ... @@ -7,3 +7,6 @@
/* 模块 */
@import "base";
@import "components/index";
/* 资讯 */
@import "editorial/index";
\ No newline at end of file
... ...