Authored by xuqi

order rebuild

... ... @@ -943,7 +943,8 @@
{
name: '',
active: true,
typeId: 1
typeId: 1,
url: ''
},
...
]
... ...
/**
* 我的逛
* @author xuqi<qi.xu@yoho.cn>
* @date: 2015/11/17
*/
var $ = require('jquery');
var info = require('../guang/info');
info.initInfoEvt($('#info-list'));
\ No newline at end of file
... ...
... ... @@ -17,27 +17,32 @@ var winH = $(window).height();
var activeType = $navLi.filter('.active').data('type'); //当前active的项的index
var orderPage = {};
var order = {
page: 0,
end: false
};
var inAjax = false;
var loading = require('../plugin/loading');
var navHammer, orderHammer;
var orderHammer;
//加载订单
function getOrders() {
function getOrders(option) {
var opt = {
type: activeType,
page: orderPage[activeType] ? (orderPage[activeType] + 1) : 1
page: order.page + 1
};
var show = option && option.showLoadingMask;
if (inAjax) {
return;
}
inAjax = true;
loading.showLoadingMask();
show && loading.showLoadingMask();
$.ajax({
type: 'GET',
... ... @@ -46,23 +51,27 @@ function getOrders() {
success: function(data) {
var num;
if (data.code === 200) {
orderPage[opt.type] = opt.page;
if (data !== ' ') {
order.page = opt.page;
if (opt.page === 1) {
$curContainer.html(data.data);
$curContainer.html(data);
lazyLoad($curContainer.find('.lazy'));
} else {
num = $curContainer.children('.order').length;
$curContainer.append(data.data);
$curContainer.append(data);
//lazyload
lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ') .lazy'));
lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ')').find('.lazy'));
}
window.rePosFooter(); //重新计算底部位置
} else {
order.end = true;
}
inAjax = false;
loading.hideLoadingMask();
show && loading.hideLoadingMask();
}
});
}
... ... @@ -83,33 +92,6 @@ lazyLoad();
loading.init($('body')); //满屏loading
//导航切换
navHammer = new Hammer(document.getElementById('order-nav'));
navHammer.on('tap', function(e) {
var $cur = $(e.target).closest('li'),
index;
if ($cur.length === 0 || $cur.hasClass('active')) {
return;
}
index = $cur.index();
$navLi.filter('.active').removeClass('active');
$cur.addClass('active');
$curContainer.addClass('hide');
$curContainer = $orderContainer.children(':eq(' + index + ')').removeClass('hide');
activeType = $cur.data('type');
if (orderPage[activeType]) {
return;
} else {
getOrders();
}
});
//点击订单区域跳转订单详情页
orderHammer = new Hammer(document.getElementById('order-container'));
orderHammer.on('tap', function(e) {
... ... @@ -168,9 +150,13 @@ orderHammer.on('tap', function(e) {
});
$(window).scroll(function() {
if ($(window).scrollTop() + winH >
if (order.end === false && $(window).scrollTop() + winH >
$(document).height() - 0.25 * $orderContainer.height()) {
getOrders();
//下拉请求时不显示mask
getOrders({
noLoadingMask: true
});
}
});
... ...
... ... @@ -106,7 +106,14 @@
border-bottom: 1px solid #e0e0e0;
background: #fff;
> li{
a {
display: block;
height: 100%;
width: 100%;
color: #b0b0b0;
}
> li {
float: left;
height: 90rem / $pxConvertRem;
width: 25%;
... ... @@ -115,7 +122,7 @@
font-size: 26rem / $pxConvertRem;
text-align: center;
&.active {
&.active a {
color: #000;
}
}
... ...
... ... @@ -4,7 +4,7 @@
<ul id="order-nav" class="order-nav clearfix">
{{#each navs}}
<li {{#if active}}class="active"{{/if}} data-type="{{typeId}}">
{{name}}
<a href="{{url}}">{{name}}</a>
</li>
{{/each}}
</ul>
... ...
... ... @@ -463,19 +463,19 @@ class HomeController extends AbstractAction
$data = OrderModel::getNavs($type);
if (!empty($data)) {
$order['navs'] = $data;
$order['orderPage'] = true;
} else {
$this->error();
}
$this->_view->display('order', array(
'order' => $order,
'pageFooter' => true
'pageFooter' => true,
'orderPage' => true
));
}
//ajax请求订单页面
public function getOrderAction() {
public function getOrdersAction() {
//判断是不是ajax请求
if (!$this->isAjax()) {
$this->error();
... ...