Authored by yyq

Merge branch 'release/4.4' of http://git.dev.yoho.cn/web/yohobuywap into release/4.4

... ... @@ -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', {
... ... @@ -96,7 +96,7 @@ if ($('.banner-swiper').find('li').size() > 1) {
}
if ($('.multi-browse').find('li').size() > 1) {
multiSwiper = new Swiper('.multi-browse', {
multiSwiper = new Swiper('.multi-browse', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
lazyLoadingOnTransitionStart: true,
... ... @@ -117,7 +117,7 @@ function getPageGoods(info) {
url: info.url,
data: info.data,
success: function(data) {
info.callBack(data);
info.callBack(data);
},
error: function() {
alert('网络断开连接了~');
... ... @@ -133,21 +133,19 @@ 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);
};
getPageGoods(req);
}
function hotData(callback) {
... ... @@ -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,
mouseWheel: true,
click: true
});
myScroll.on('scroll', function() {
sTop = -this.y;
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);
};
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,20 +267,19 @@ 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');
}
$nav1.css({
transform: 'translate(0, ' + (imgH + main1H - sTop - scH) + 'px)'
transform: 'translate(0, ' + (imgH + main1H - sTop - scH) + 'px)'
});
}
} else {
... ... @@ -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);
});
... ... @@ -365,7 +354,7 @@ function search(opt) {
}
switch (opt.type) {
case 'shop_id':
case 'shop_id':
ext = {
shop_id: opt.id
};
... ... @@ -430,7 +419,7 @@ function search(opt) {
//不需要重新加载并且数据请求结束
return;
}
console.log(page)
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
... ... @@ -487,13 +476,11 @@ function search(opt) {
window.rePosFooter();
setTimeout(function () {
setTimeout(function() {
myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
},
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
... ... @@ -509,12 +496,10 @@ $.ajax({
success: function(data) {
$goodsContainer.append(data);
setTimeout(function () {
myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
setTimeout(function() {
myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
//初始化filter&注册filter回调
filter.initFilter({
... ... @@ -644,17 +629,16 @@ $subNav.on('touchend touchcancel', function(e) {
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',
id: $shopId,
url: '/index/search/search'
});
});
}
}
}
... ... @@ -669,59 +653,50 @@ 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.refresh();
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){
$(this).find('.sub-group').removeClass('hide');
}
});
};
$(group + ' li').on('touchstart', function() {
$('.sub-group').addClass('hide');
if ($(this).find('.sub-group').length > 0) {
$(this).find('.sub-group').removeClass('hide');
}
});
}
fotterClick('.shop-foot-wrapper');
function stopPropagation(e) {
if (e.stopPropagation){
e.stopPropagation();
}else {
e.cancelBubble = true; }
}
function stopPropagation(e) {
if (e.stopPropagation) {
e.stopPropagation();
} else {
e.cancelBubble = true;
}
}
$(document).bind('touchstart', function(){
$('.sub-group').addClass('hide');
});
$(document).bind('touchstart', function() {
$('.sub-group').addClass('hide');
});
$('.shop-foot-wrapper').bind('touchstart',function(e){
stopPropagation(e);
});
$('.shop-foot-wrapper').bind('touchstart', function(e) {
stopPropagation(e);
});
//收藏
function postCollect(info) {
... ... @@ -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() {
... ... @@ -792,10 +766,10 @@ function cancelShop() {
$('#collect').bind('touchstart', function() {
if ($('#collect').hasClass('alreadyCollect')) {
cancelShop();
}else{
cancelShop();
} else {
collectShop();
}
});
});
... ...