Authored by biao

Merge branch 'develop' of http://git.yoho.cn/fe/yoho-blk into develop

/**
* 资讯
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/7/4
*/
'use strict';
const index = (req, res) => {
var pageNum = req.query.page || 1;
res.display('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: '潮品'
}
],
msg: [
{
msgLeft: '潮品',
msgTitle: '很到位和范围的恢复文件和的减肥了晚餐费',
img: '',
msgContent: '鞋款定价回复即可老地方了服务',
time: '2016/05/25 19:36',
liked: true,
like: '8'
},
{
msgLeft: '潮品',
msgTitle: '很到位和范围的恢复文件和的减肥了晚餐费',
img: '',
msgContent: '鞋款定价回复即可老地方了服务',
time: '2016/05/25 19:36',
liked: true,
like: '8'
}
],
paginationOpts: {
page: pageNum, // current page: http://host/?page=2
limit: 10, // per_page records' number
totalRows: 100 // total page number
}
},
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
// var partials = path.join(__dirname, './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}}
{{> path-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">
{{# msg}}
{{> msg}}
{{/ msg}}
</div>
<div class="paging">
{{{ pagination paginationOpts }}}
</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 like-icon{{#if liked}} liked{{/if}}">&#xe60e;</i>
<b class="like-num">{{like}}</b>
</span>
</div>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -6,6 +6,8 @@
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
/**
* 订单
*/
... ... @@ -15,51 +17,8 @@ const index = (req, res) => {
page: 'order',
isMe: true,
content: {
nav: [
{
link: '//www.yohoblk.com',
name: 'YOHO!BLK首页'
},
{
link: '//www.yohoblk.com/me',
name: '个人中心'
},
{
link: '//www.yohoblk.com/me',
name: '我的订单'
}
],
navigation: [
{
focus: true,
link: '/me/order',
name: '我的订单'
},
{
link: '/me/return',
name: '我的退/换货'
},
{
link: '/me/collection',
name: '我的收藏'
},
{
link: '/me/message',
name: '我的消息'
},
{
link: '/me/currency',
name: '我的YOHO币'
},
{
link: '/me/setting',
name: '个人设置'
},
{
link: '/me/address',
name: '收货地址'
}
],
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('我的订单'),
banner: 'http://placehold.it/150x120'
}
});
... ...
/**
* 个人中心布局(顶部面包屑和左侧导航)
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/7/5
*/
'use strict';
const _ = require('lodash');
const blk = global.yoho;
const url = blk.helpers.urlFormat;
// 左侧菜单
const navigation = [
{
link: url('/me/order'),
name: '我的订单'
},
{
link: url('/me/return'),
name: '我的退/换货'
},
{
link: url('/me/collection'),
name: '我的收藏'
},
{
link: url('/me/message'),
name: '我的消息'
},
{
link: url('/me/currency'),
name: '我的YOHO币'
},
{
link: url('/me/setting'),
name: '个人设置'
},
{
link: url('/me/address'),
name: '收货地址'
}
];
// 头部导航面包屑
const getMeCrumb = name => {
return [
{
link: blk.config.sitUrl,
name: 'YOHO!BLK首页'
},
{
link: url('/me'),
name: '个人中心'
},
{
name: name ? name : '我的订单'
}
];
};
// 侧栏菜单
const getSideMenu = focus => {
let copiedNav = _.cloneDeep(navigation);
if (focus && _.some(copiedNav, {name: focus})) {
Object.assign(_.find(copiedNav, {name: focus}), {
focus: true
});
} else {
// 若没有传focus || focus不在navigation中,则默认focus第1个菜单
copiedNav[0].focus = true;
}
return copiedNav;
};
module.exports = {
getMeCrumb,
getSideMenu
};
... ...
<div class="me-page blk-page clearfix">
<div class="center-content">
<div class="me-page blk-page">
<div class="center-content clearfix">
{{# content}}
{{!-- 头部面包屑 --}}
{{> path-nav}}
... ... @@ -65,7 +65,7 @@
<span class="iconfont">&#xe61c;</span>
<span class="hover-text hide">在线<br>客服</span>
</a>
<div class="return-top">
<div class="return-top hide">
<span class="iconfont bold">&#xe617;</span>
<span class="hover-text hide">返回<br>顶部</span>
</div>
... ...
... ... @@ -80,7 +80,17 @@
</div>
<p class="title">9. 分页组件</p>
<div style="border: 1px solid #000; height: 40px; padding: 5px;">
<div style="border: 1px solid #000; height: 200px; padding: 5px;">
<pre>
全局安装json-server
npm i -g json-server
启动
json-server --watch mock/address.json
</pre>
{{{ pagination paginationOpts }}}
</div>
... ...
... ... @@ -14,4 +14,7 @@ module.exports = app => {
app.use('/', require('./apps/channel')); // 频道页
app.use('/me', require('./apps/me')); // 个人中心
// 资讯
app.use('/editorial', require('./apps/editorial'));
};
... ...
<div class="yoho-footer">
<div class="blk-footer">
<div class="center-content">
<ul class="about-us clearfix">
<li><a href="#">BLK首页</a></li>
... ...
... ... @@ -9,7 +9,7 @@ var $ = require('yoho-jquery');
var $returnTop = $('.return-top');
function showOrNot() {
if ($(window).height() > $(document).height()) {
if ($(window).height() >= $(document).height()) {
$returnTop.addClass('hide');
}
}
... ... @@ -28,4 +28,9 @@ $(window).scroll(function() {
}
});
// 页面图片加载完成后根据页面高度决定是否显示
if ($returnTop.hasClass('hide')) {
$('img').load(showOrNot);
}
exports.returnTopShowOrNot = showOrNot;
... ...
/**
* 资讯首页
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/07/05
*/
// var $ = require('yoho-jquery'),
// lazyLoad = require('yoho-jquery-lazyload');
// lazyLoad($('#msg-list img.lazy'));
... ...
... ... @@ -6,6 +6,19 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var $st = $('.service-top');
function reposServiceTop() {
if ($(window).width() < 1380) {
$st.addClass('for-min');
} else {
$st.removeClass('for-min');
}
}
$('.blk-footer .return-top').remove(); // 移除通用的返回顶部组件
require('../common/return-top'); // return-top
// 左侧banner图片lazyload
lazyLoad($('.banner-img'));
... ... @@ -16,3 +29,8 @@ $('.service, .return-top').hover(function() {
}, function() {
$(this).find('.iconfont').removeClass('hide').end().find('.hover-text').addClass('hide');
});
// repos service-return when window resize
$(window).resize(reposServiceTop);
reposServiceTop();
... ...
... ... @@ -196,6 +196,11 @@ a {
-moz-osx-font-smoothing: grayscale;
}
/* 单一布局 */
.blk-page {
min-width: 1150px;
}
.body-mask {
position: absolute;
z-index: 100;
... ... @@ -219,7 +224,7 @@ a {
}
.hide {
display: none;
display: none !important;
}
.vhide {
... ...
.yoho-footer {
.blk-footer {
background: #fff;
.center-content {
... ...
.editorial-index-page {
width: 1150px;
margin: 0 auto;
.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;
}
}
}
}
.paging {
margin: 20px auto;
width: 300px;
height: 40px;
}
}
@import "msg";
... ...
.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 #eee;
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;
overflow: hidden;
word-wrap: break-word;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.msg-app {
height: 45px;
line-height: 45px;
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-icon {
cursor: pointer;
&.liked {
color: #000;
}
}
}
.like-num {
font-weight: normal;
}
... ...
... ... @@ -8,4 +8,9 @@
/* 模块 */
@import "me/index";
@import "channel/index";
@import "base";
@import "components/index";
/* 资讯 */
@import "editorial/index";
... ...
... ... @@ -3,7 +3,7 @@
background: #f5f5f5;
/* 个人中心布局下重置默认的底部样式 */
+ .yoho-footer .center-content {
+ .blk-footer .center-content {
border-top: none;
}
... ... @@ -64,6 +64,12 @@
z-index: 2;
margin-left: 625px;
&.for-min {
right: 20px;
left: initial;
margin-left: auto;
}
.service,
.return-top {
display: block;
... ...