...
|
...
|
@@ -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
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
|