...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2017-03-24 13:43:55
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-03-24 16:54:26
|
|
|
* @Last Modified time: 2017-03-24 17:57:30
|
|
|
*/
|
|
|
|
|
|
/** *****************************
|
...
|
...
|
@@ -26,37 +26,28 @@ const shopId = $('#shopId').val(); |
|
|
let navInfo = {
|
|
|
price: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
discount: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
default: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false,
|
|
|
type: 'default'
|
|
|
},
|
|
|
new: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
sale: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let beforeScroll = document.body.scrollTop; // 滚动前位置记录
|
|
|
let navType = 'default'; // 目前激活的导航页面
|
|
|
let defaultOpt = Object.assign({}, navInfo.default, {shop_id: shopId}); // 默认参数
|
|
|
let onSearching = false; // 是否正在搜索
|
...
|
...
|
@@ -82,7 +73,7 @@ const handleChoseFilter = function() { |
|
|
const getGoodsList = function() {
|
|
|
handleChoseFilter();
|
|
|
|
|
|
if (isScrollLoad && !onSearching) {
|
|
|
if (!onSearching) {
|
|
|
Object.assign(defaultOpt, {
|
|
|
page: page++
|
|
|
});
|
...
|
...
|
@@ -197,6 +188,8 @@ $listNav.bind('contextmenu', function() { |
|
|
});
|
|
|
|
|
|
$listNav.on('touchend touchcancel', function(e) {
|
|
|
page = 0;
|
|
|
beforeScroll = $(window).scrollTop();
|
|
|
isScrollLoad = false;
|
|
|
|
|
|
let $this = $(e.target).closest('li'); // 被点击的 Tab
|
...
|
...
|
@@ -248,7 +241,6 @@ $listNav.on('touchend touchcancel', function(e) { |
|
|
// 价格或折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
$pre = $this; // 更新 pre 为当前项
|
|
|
nav.reload = true; // 排序改变,标记需要重新获取数据
|
|
|
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -270,15 +262,24 @@ $listNav.on('touchend touchcancel', function(e) { |
|
|
defaultOpt.type = navType;
|
|
|
Object.assign(defaultOpt, nav);
|
|
|
|
|
|
if (nav.reload) {
|
|
|
getGoodsList();
|
|
|
}
|
|
|
getGoodsList();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// srcoll to load more
|
|
|
/**
|
|
|
* 滚动加载
|
|
|
*/
|
|
|
$(window).scroll(function() {
|
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
setTimeout(function() {
|
|
|
let afterScroll = document.body.scrollTop;
|
|
|
|
|
|
if (afterScroll - beforeScroll > 0) {
|
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
beforeScroll = afterScroll;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}, 5);
|
|
|
});
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|