Authored by xuqi

split guang home from list

... ... @@ -257,7 +257,6 @@
### 逛首页
{
isHomePage: true,
swiper: [
{
url: '',
... ... @@ -269,13 +268,15 @@
{
typeId: 1,
type: '最新',
url: '',
focus: true
},
...
],
infos: [
{...}, //标签
[
{...}, //资讯
...
],
...
]
}
... ... @@ -283,10 +284,17 @@
### 逛列表页
{
infos: [
infos:
[
{
show: true,
info: [
{...}, //标签
...
]
},
...
]
}
### 编辑页
... ...
/**
* 逛首页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
var $ = require('yoho.zepto'),
Swiper = require('yoho.iswiper');
var info = require('./info'),
setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,
loadMore = info.loadMore;
var winH = $(window).height(),
loadMoreH = $('#load-more').height();
var $infoList = $('#info-list'),
$infos = $infoList.children('.info-list'),
$nav = $('#guang-nav'),
$curNav = $nav.children('.focus'),
curIndex = $curNav.index();
var state = {};
var mySwiper;
mySwiper = new Swiper('.swiper-container', {
lazyLoading: true,
pagination: '.swiper-pagination'
});
info.initInfosEvt($infoList);
//初始化各Nav下资讯加载的状态
(function() {
$nav.children('.guang-nav-item').each(function() {
var type = $(this).data('type');
state[type] = {
page: 1,
end: false,
type: type
};
});
}());
$nav.delegate('.guang-nav-item', 'touchstart', function() {
var $this = $(this),
$content,
index;
if ($this.hasClass('focus')) {
return;
}
index = $this.index();
$this.addClass('focus');
$curNav.removeClass('focus');
$infos.not('.hide').addClass('hide');
$content = $infos.eq(index);
$content.removeClass('hide');
//lazyload & mellipsis
setLazyLoadAndMellipsis($content.children('.guang-info'));
$curNav = $this;
curIndex = index;
});
$(document).scroll(function() {
if (state[curIndex].end) {
return;
}
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, state[curIndex]);
}
});
\ No newline at end of file
... ...
... ... @@ -15,6 +15,21 @@ var loading = false;
ellipsis.init();
/**
* 设置指定资讯项的Lazyload和文字截取
* @params $infos 资讯项
*/
function setLazyLoadAndMellipsis($infos) {
lazyLoad($infos.find('img.lazy'));
$infos.each(function() {
var $this = $(this);
$this.find('.info-title')[0].mlellipsis(2);
$this.find('.info-text')[0].mlellipsis(2);
});
}
/**
* 初始化资讯列表事件绑定
* @params $container 逛资讯列表容器
*/
... ... @@ -42,22 +57,7 @@ function initInfosEvt($container) {
});
});
_setLazyLoadAndMellipsis($container.find('.guang-info'));
}
/**
* 设置指定资讯项的Lazyload和文字截取
* @params $infos 资讯项
*/
function _setLazyLoadAndMellipsis($infos) {
lazyLoad($infos.find('img.lazy'));
$infos.each(function() {
var $this = $(this);
$this.find('.info-title')[0].mlellipsis(2);
$this.find('.info-text')[0].mlellipsis(2);
});
setLazyLoadAndMellipsis($container.find('.guang-info'));
}
/**
... ... @@ -88,7 +88,7 @@ function loadMore($container, opt) {
$container.append(res.infos);
$newInfos = $container.find('.guang-info:gt(' + (infosNum - 1) + ')');
_setLazyLoadAndMellipsis($newInfos);
setLazyLoadAndMellipsis($newInfos);
opt.page++;
}
... ... @@ -98,4 +98,5 @@ function loadMore($container, opt) {
}
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
\ No newline at end of file
... ...
/**
* 逛首页,列表页,编辑页
* 列表页,编辑页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
var $ = require('yoho.zepto'),
Swiper = require('yoho.iswiper');
var $ = require('yoho.zepto');
var info = require('./info'),
loadMore = info.loadMore;
... ... @@ -18,22 +17,16 @@ var setting = {
end: false
};
var $infos = $('#info-list'),
mySwiper;
var $infos = $('#info-list');
info.initInfosEvt($infos);
mySwiper = new Swiper('.swiper-container', {
lazyLoading: true,
pagination: '.swiper-pagination'
});
$(document).scroll(function() {
if (setting.end) {
return;
}
if ($(window).scrollTop() + $(window).height() >= $(document).height() - loadMoreH) {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, setting);
}
});
\ No newline at end of file
... ...
... ... @@ -66,13 +66,13 @@
padding: 0 22rem / $pxConvertRem;
line-height: 80rem / $pxConvertRem;
&.focus a {
&.focus {
color: #000;
}
a {
color: #ccc;
}
.info-list.hide {
display: none;
}
.load-more-info {
... ...
{{> layout/header}}
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{#if isHomePage}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# swiper}}
... ... @@ -15,7 +14,6 @@
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
{{# author}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
... ... @@ -29,19 +27,21 @@
</div>
{{/ author}}
{{#if isHomePage}}
<ul id="guang-nav" class="guang-nav clearfix">
{{# navs}}
<li class="guang-nav-item {{#focus}}focus{{/focus}}" data-type={{typeId}}>
<a class="pjax-link" href="{{url}}">{{type}}</a>
{{type}}
</li>
{{/ navs}}
</ul>
{{/if}}
<div id="info-list" class="info-list">
<div id="info-list">
{{# infos}}
<div class="info-list {{^show}}hide{{/show}}">
{{# info}}
{{> guang/info}}
{{/ info}}
</div>
{{/ infos}}
</div>
... ...
{{> layout/header}}
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{# author}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
<div class="avatar">
<img src="{{avatar}}">
</div>
<div class="text">
<p class="name">{{name}}</p>
<p class="info">{{info}}</p>
</div>
</div>
{{/ author}}
<div id="info-list" class="info-list">
{{# infos}}
{{> guang/info}}
{{/ infos}}
</div>
<div id="load-more-info" class="load-more-info">
<div class="loading status">
正在加载...
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
{{/ guang}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -6,14 +6,12 @@ use Action\AbstractAction;
*/
class ListController extends AbstractAction
{
/**
* 首页
*/
public function indexAction()
{
$data = array(
'isHomePage' => true,
'swiper' => array(
array(
'url' => '',
... ... @@ -27,38 +25,34 @@ class ListController extends AbstractAction
'navs' => array(
array(
'typeId' => 1,
'type' => '最新',
'url' => '/guang/index'
'type' => '最新'
),
array(
'typeId' => 2,
'type' => '话题',
'focus' => true,
'url' => '/guang/index'
'focus' => true
),
array(
'typeId' => 3,
'type' => '搭配',
'url' => '/guang/index'
'type' => '搭配'
),
array(
'typeId' => 4,
'type' => '潮人',
'url' => '/guang/index'
'type' => '潮人'
),
array(
'typeId' => 5,
'type' => '潮物',
'url' => '/guang/index'
'type' => '潮物'
),
array(
'typeId' => 6,
'type' => '小贴士',
'url' => '/guang/index'
'type' => '小贴士'
)
),
'infos' => array(
array(
'info' => array(
array(
'id' => 1,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '1.副线不知为何总是好看点',
... ... @@ -93,8 +87,155 @@ class ListController extends AbstractAction
'url' => '',
'likeUrl' => '',
'isTip' => true
)
)
),
array(
'show' => true,
'info' => array(
array(
'id' => 2,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '2.副线不知为何总是好看点测试长度是否会被截取塞真的很恶心啊',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => false,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 100,
'isLiked' => false
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isFashionGood' => true
)
)
),
array(
'info' => array(
array(
'id' => 2,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '2.副线不知为何总是好看点测试长度是否会被截取塞真的很恶心啊',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => false,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 100,
'isLiked' => false
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isFashionGood' => true
),
array(
'id' => 1,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '1.副线不知为何总是好看点',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => true,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 459,
'isLiked' => true
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isTip' => true
)
)
),
array(
'info' => array(
array(
'id' => 2,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '2.副线不知为何总是好看点测试长度是否会被截取塞真的很恶心啊',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => false,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 100,
'isLiked' => false
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isFashionGood' => true
),
array(
'id' => 1,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '1.副线不知为何总是好看点',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => true,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 459,
'isLiked' => true
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isTip' => true
)
)
),
array(
'info' => array(
array(
'id' => 2,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '2.副线不知为何总是好看点测试长度是否会被截取塞真的很恶心啊',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => false,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 100,
'isLiked' => false
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isFashionGood' => true
),
array(
'id' => 1,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '1.副线不知为何总是好看点',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => true,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 459,
'isLiked' => true
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isTip' => true
)
)
),
array(
'info' => array(
array(
'id' => 2,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '2.副线不知为何总是好看点测试长度是否会被截取塞真的很恶心啊',
... ... @@ -111,11 +252,31 @@ class ListController extends AbstractAction
'url' => '',
'likeUrl' => '',
'isFashionGood' => true
),
array(
'id' => 1,
'img' => 'http://7xidk0.com1.z0.glb.clouddn.com/bg.png',
'title' => '1.副线不知为何总是好看点',
'text' => '具有绅士气质的英伦风格是永走前沿的经典,在众多的Made ' .
'In England中Panul Smith缔造了一个传奇',
'showTags' => true,
'publishTime' => '2月13日 12:34',
'pageView' => 3445,
'like' => array(
'count' => 459,
'isLiked' => true
),
'share' => true,
'url' => '',
'likeUrl' => '',
'isTip' => true
)
)
)
)
);
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('index', array('modulePath' => 'guang/list', 'guang' => $data));
$this->_view->display('index', array('modulePath' => 'guang/home', 'guang' => $data));
}
/**
... ... @@ -182,7 +343,7 @@ class ListController extends AbstractAction
)
);
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('index', array('modulePath' => 'guang/list', 'guang' => $data));
$this->_view->display('list', array('modulePath' => 'guang/list', 'guang' => $data));
}
/**
... ... @@ -254,7 +415,6 @@ class ListController extends AbstractAction
)
);
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('index', array('modulePath' => 'guang/list', 'guang' => $data));
$this->_view->display('list', array('modulePath' => 'guang/list', 'guang' => $data));
}
}
\ No newline at end of file
... ...