...
|
...
|
@@ -48,13 +48,13 @@ var $listNav = $('#list-nav'), |
|
|
new: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
page: 1,
|
|
|
end: false
|
|
|
},
|
|
|
hot: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
page: 1,
|
|
|
end: false
|
|
|
},
|
|
|
newest: {
|
...
|
...
|
@@ -80,7 +80,7 @@ var $listNav = $('#list-nav'), |
|
|
searching;
|
|
|
|
|
|
var viewType = 1; // 1-首页,2-上新,3-人气
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
//焦点效果
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
bannerSwiper = new Swiper('.banner-swiper', {
|
...
|
...
|
@@ -133,20 +133,18 @@ function newData(callback) { |
|
|
req.data = {
|
|
|
type: 'newest',
|
|
|
order: '1',
|
|
|
page: '1',
|
|
|
page: navInfo.new.page,
|
|
|
shop_id: $shopId
|
|
|
|
|
|
};
|
|
|
req.callBack = function(data) {
|
|
|
$('#new-arrival').append(data);
|
|
|
navInfo.new.page++;
|
|
|
myScroll.refresh();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$("#scroller").trigger('scroll');
|
|
|
lazyLoad($('#new-arrival .lazy'));
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
searching = false;
|
|
|
callback && $.isFunction(callback) && callback();
|
|
|
}
|
|
|
};
|
|
|
getPageGoods(req);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -157,19 +155,18 @@ function hotData(callback) { |
|
|
req.data = {
|
|
|
type: 'sales',
|
|
|
order: '1',
|
|
|
page: '1',
|
|
|
page: navInfo.hot.page,
|
|
|
shop_id: $shopId
|
|
|
};
|
|
|
req.callBack = function(data) {
|
|
|
$('#popularity').append(data);
|
|
|
navInfo.hot.page++;
|
|
|
myScroll.refresh();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$("#scroller").trigger('scroll');
|
|
|
lazyLoad($('#popularity .lazy'));
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
searching = false;
|
|
|
callback && $.isFunction(callback) && callback();
|
|
|
}
|
|
|
};
|
|
|
getPageGoods(req);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -192,71 +189,64 @@ $.jqtab = function(nav, posNav, main) { |
|
|
activeTab = $(this).attr('tab');
|
|
|
|
|
|
$nav1.removeClass('fixed-top');
|
|
|
|
|
|
tabChange($(nav + ' li'), index);
|
|
|
tabChange($(posNav + ' li'), index);
|
|
|
|
|
|
$(main).hide();
|
|
|
$('#' + activeTab).fadeIn();
|
|
|
|
|
|
if(activeTab === 'new-arrival'){
|
|
|
if (activeTab === 'new-arrival') {
|
|
|
newData();
|
|
|
viewType = 2;
|
|
|
} else if(activeTab === 'popularity'){
|
|
|
} else if (activeTab === 'popularity') {
|
|
|
hotData();
|
|
|
viewType = 2;
|
|
|
viewType = 3;
|
|
|
} else if (activeTab === 'home-page') {
|
|
|
|
|
|
myScroll && myScroll.refresh();
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
$nav1.removeClass('fixed-top');
|
|
|
$nav1.removeClass('absolute');
|
|
|
|
|
|
$nav2.removeClass('fixed-top');
|
|
|
$nav2.removeClass('absolute');
|
|
|
}
|
|
|
|
|
|
myScroll.scrollTo(0,0);
|
|
|
myScroll.scrollTo(0, 0);
|
|
|
$nav1.addClass('hide');
|
|
|
|
|
|
return false;
|
|
|
});
|
|
|
};
|
|
|
$.jqtab('#nav','#pos-nav','.main');
|
|
|
|
|
|
$.jqtab('#nav', '#pos-nav', '.main');
|
|
|
$('#wrapper').addClass('scroll-wrapper');
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
// lazyLoad($('img.lazy'));
|
|
|
|
|
|
myScroll = new IScroll('#wrapper', {
|
|
|
probeType: 3,
|
|
|
mouseWheel: true,
|
|
|
click: true
|
|
|
});
|
|
|
|
|
|
myScroll.on('scroll', function() {
|
|
|
var scrollCall,
|
|
|
sTop = -this.y;
|
|
|
|
|
|
if (sTop + winH * 2 > scH) {
|
|
|
switch(viewType) {
|
|
|
switch (viewType) {
|
|
|
case 2:
|
|
|
var scrollCall = function() {
|
|
|
scrollCall = function() {
|
|
|
$nav1.css({
|
|
|
transform: 'translate(0, ' + (- scH) + 'px)'
|
|
|
transform: 'translate(0, ' + (-scH) + 'px)'
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
newData(scrollCall);
|
|
|
break;
|
|
|
case 3:
|
|
|
var scrollCall = function() {
|
|
|
scrollCall = function() {
|
|
|
$nav1.css({
|
|
|
transform: 'translate(0, ' + (- scH) + 'px)'
|
|
|
transform: 'translate(0, ' + (-scH) + 'px)'
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
hotData(scrollCall);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (sTop < imgH) {
|
|
|
if (!$nav1.hasClass('hide')) {
|
|
|
$nav1.addClass('hide');
|
...
|
...
|
@@ -277,14 +267,13 @@ myScroll.on('scroll', function() { |
|
|
$nav1.addClass('fixed-top')
|
|
|
.removeClass('absolute')
|
|
|
.css({
|
|
|
transform: 'translate(0, ' + (- scH) + 'px)'
|
|
|
transform: 'translate(0, ' + (-scH) + 'px)'
|
|
|
});
|
|
|
}
|
|
|
} else if (sTop < imgH + nav1H + main1H) {
|
|
|
if ($('#home-page').is(':hidden')) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!$nav1.hasClass('absolute')) {
|
|
|
$nav1.addClass('absolute')
|
|
|
.removeClass('fixed-top');
|
...
|
...
|
@@ -310,12 +299,12 @@ myScroll.on('scroll', function() { |
|
|
$nav2.addClass('fixed-top')
|
|
|
.removeClass('absolute')
|
|
|
.css({
|
|
|
transform: 'translate(0, ' + (- scH) + 'px)'
|
|
|
transform: 'translate(0, ' + (-scH) + 'px)'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$("#scroller").trigger('scroll');
|
|
|
$('#scroller').trigger('scroll');
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
@@ -338,9 +327,9 @@ $(window).load(function() { |
|
|
main1oH = $('#nav-main').outerHeight();
|
|
|
nav2H = $('#list-nav').outerHeight();
|
|
|
main2oH = $('#goods-container').outerHeight();
|
|
|
setTimeout(function(){
|
|
|
setTimeout(function() {
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
},1000);
|
|
|
}, 1000);
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
@@ -430,7 +419,7 @@ function search(opt) { |
|
|
//不需要重新加载并且数据请求结束
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
console.log(page)
|
|
|
$.extend(setting, defaultOpt, {
|
|
|
type: navType,
|
|
|
order: nav.order,
|
...
|
...
|
@@ -487,12 +476,10 @@ function search(opt) { |
|
|
|
|
|
window.rePosFooter();
|
|
|
|
|
|
setTimeout(function () {
|
|
|
setTimeout(function() {
|
|
|
myScroll.refresh();
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
...
|
...
|
@@ -509,13 +496,11 @@ $.ajax({ |
|
|
success: function(data) {
|
|
|
$goodsContainer.append(data);
|
|
|
|
|
|
setTimeout(function () {
|
|
|
setTimeout(function() {
|
|
|
myScroll.refresh();
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
//初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: search,
|
...
|
...
|
@@ -647,8 +632,7 @@ function scrollHandler() { |
|
|
|
|
|
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
|
|
|
myScroll && myScroll.refresh();
|
|
|
|
|
|
if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50){
|
|
|
if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50) {
|
|
|
if ($pre !== undefined) {
|
|
|
search({
|
|
|
type: 'shop_id',
|
...
|
...
|
@@ -669,57 +653,48 @@ search({ |
|
|
type: 'shop_id',
|
|
|
id: $shopId,
|
|
|
url: '/index/search/search'
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
|
|
|
$listNav.on('touchstart', 'li', function(e) {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$listNav.find('li').removeClass('bytouch');
|
|
|
myScroll.refresh();
|
|
|
|
|
|
if (sTop > imgH + nav1H + main1oH) {
|
|
|
myScroll.scrollTo(0,-(imgH + nav1H + main1oH + 10));
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$posList.on('touchstart', 'li', function(e) {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$posList.find('li').removeClass('bytouch');
|
|
|
myScroll.refresh();
|
|
|
|
|
|
if (sTop > imgH + nav1H + main1oH) {
|
|
|
myScroll.scrollTo(0,-(imgH + nav1H + main1oH + 10));
|
|
|
}
|
|
|
myScroll.scrollTo(0, -(imgH + nav1H + main1oH + 5));
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//底部导航点击
|
|
|
function fotterClick(group) {
|
|
|
$(group + ' li').on('touchstart', function() {
|
|
|
$('.sub-group').addClass('hide');
|
|
|
if ($(this).find('.sub-group').length > 0){
|
|
|
if ($(this).find('.sub-group').length > 0) {
|
|
|
$(this).find('.sub-group').removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
fotterClick('.shop-foot-wrapper');
|
|
|
|
|
|
function stopPropagation(e) {
|
|
|
if (e.stopPropagation){
|
|
|
if (e.stopPropagation) {
|
|
|
e.stopPropagation();
|
|
|
}else {
|
|
|
e.cancelBubble = true; }
|
|
|
} else {
|
|
|
e.cancelBubble = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(document).bind('touchstart', function(){
|
|
|
$(document).bind('touchstart', function() {
|
|
|
$('.sub-group').addClass('hide');
|
|
|
});
|
|
|
|
|
|
$('.shop-foot-wrapper').bind('touchstart',function(e){
|
|
|
$('.shop-foot-wrapper').bind('touchstart', function(e) {
|
|
|
stopPropagation(e);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -739,10 +714,10 @@ function postCollect(info) { |
|
|
|
|
|
success: function(data) {
|
|
|
|
|
|
if (data.code === 200){
|
|
|
if (data.code === 200) {
|
|
|
if ($('#collect').hasClass('alreadyCollect')) {
|
|
|
$('#collect').attr('class', 'notCollect');
|
|
|
}else{
|
|
|
} else {
|
|
|
$('#collect').attr('class', 'alreadyCollect');
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -754,11 +729,10 @@ function postCollect(info) { |
|
|
$('.jump-login').click();
|
|
|
}
|
|
|
|
|
|
setTimeout(function () {
|
|
|
setTimeout(function() {
|
|
|
myScroll.refresh();
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
}, 1000);
|
|
|
|
|
|
searching = false;
|
|
|
},
|
|
|
error: function() {
|
...
|
...
|
@@ -793,9 +767,9 @@ function cancelShop() { |
|
|
$('#collect').bind('touchstart', function() {
|
|
|
if ($('#collect').hasClass('alreadyCollect')) {
|
|
|
cancelShop();
|
|
|
}else{
|
|
|
} else {
|
|
|
collectShop();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|