Authored by 徐祁xuqi

filter for shop

... ... @@ -9702,7 +9702,7 @@ function newData(callback) {
getPageGoods(req);
}
function hotData(callback) {
function hotData(callBack) {
var req = {};
req.url = location.protocol + '//m.yohobuy.com/index/search/search';
... ... @@ -9730,13 +9730,17 @@ function hotData(callback) {
function tabChange(dom, index) {
var li = dom.eq(index);
dom.removeClass('active');
li.addClass('active');
dom.removeClass('color');
li.addClass('color');
dom.removeClass('active color');
li.addClass('active color');
}
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
//首页导航
(function(nav, posNav, main) {
... ... @@ -9745,6 +9749,10 @@ function tabChange(dom, index) {
var index = $(this).index(),
activeTab = $(this).attr('tab');
if (!$('filter-mask').hasClass('hide')) {
return;
}
$nav1.removeClass('fixed-top');
tabChange($(nav + ' li'), index);
tabChange($(posNav + ' li'), index);
... ... @@ -9760,30 +9768,65 @@ function tabChange(dom, index) {
myScroll && myScroll.refresh();
scH = $('#scroller').outerHeight();
$nav1.removeClass('fixed-top');
$nav1.removeClass('absolute');
$nav2.removeClass('fixed-top');
$nav2.removeClass('absolute');
$nav1.removeClass('fixed-top absolute');
$nav2.removeClass('fixed-top absolute');
}
if (!$nav1.hasClass('hide')) {
myScroll.scrollTo(0, 0 - imgH);
myScroll && myScroll.scrollTo(0, 0 - imgH);
}
$nav1.addClass('hide');
});
}('#nav', '#pos-nav', '.main'));
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
var theY;
/**
* 筛选后内容变化,导致nav1位置错掉,重新计算确保位置正确显示
*/
function reNav1Pos() {
var sTop = theY ? theY : 0;
if (sTop < imgH + main1oH + nav1H) {
if ($nav1.hasClass('hide')) {
$nav1.removeClass('hide');
}
if (sTop < imgH + main1H) {
tra = 'translate3d(0, ' + (-scH) + 'px, 0)';
$nav1.addClass('fixed-top')
.removeClass('absolute')
.css({
transform: tra,
'-moz-transform': tra,
'-ms-transform': tra,
'-webkit-transform': tra
});
} else if (sTop < imgH + main1H + nav1H) {
if ($('#home-page').is(':hidden')) {
return false;
}
$nav1.addClass('absolute')
.removeClass('fixed-top');
tra = 'translate3d(0, ' + (imgH + main1H - sTop - scH) + 'px, 0)';
$nav1.css({
transform: tra,
'-moz-transform': tra,
'-ms-transform': tra,
'-webkit-transform': tra
});
}
}
}
myScroll.on('scroll', function() {
var scrollCall,
sTop = -this.y;
var tra;
if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50) {
theY = sTop;
if (sTop + winH > scH - 0.25 * $goodsContainer.height() - 50) {
if ($pre !== undefined) {
search({
type: 'shop_id',
... ... @@ -9822,7 +9865,7 @@ myScroll.on('scroll', function() {
if (!$nav2.hasClass('hide')) {
$nav2.addClass('hide');
} //滑动距离不到导航1
} else if (sTop < imgH + main1oH) {
} else if (sTop < imgH + main1oH + nav1H) {
if ($nav1.hasClass('hide')) {
$nav1.removeClass('hide');
}
... ... @@ -9830,7 +9873,7 @@ myScroll.on('scroll', function() {
$nav2.addClass('hide');
}//滑动距离不到导航2
if (sTop < imgH + main1H - nav1H) {
if (sTop < imgH + main1H) {
if (!$nav1.hasClass('fixed-top')) {
tra = 'translate3d(0, ' + (-scH) + 'px, 0)';
$nav1.addClass('fixed-top')
... ... @@ -9842,7 +9885,7 @@ myScroll.on('scroll', function() {
'-webkit-transform': tra
});
}
} else if (sTop < imgH + main1H) {
} else if (sTop < imgH + main1H + nav1H) {
if ($('#home-page').is(':hidden')) {
return false;
}
... ... @@ -9850,7 +9893,7 @@ myScroll.on('scroll', function() {
$nav1.addClass('absolute')
.removeClass('fixed-top');
}
tra = 'translate3d(0, ' + (imgH + main1H - nav1H - sTop - scH) + 'px, 0)';
tra = 'translate3d(0, ' + (imgH + main1H - sTop - scH) + 'px, 0)';
$nav1.css({
transform: tra,
'-moz-transform': tra,
... ... @@ -9884,6 +9927,23 @@ myScroll.on('scroll', function() {
});
}
}
});
myScroll.on('scrollStart', function() {
// stop auto play when scroll
bannerSwiper && bannerSwiper.stopAutoplay();
multiSwiper && multiSwiper.stopAutoplay();
});
myScroll.on('scrollEnd', function() {
// start auto play when scroll end
bannerSwiper && bannerSwiper.startAutoplay();
multiSwiper && multiSwiper.startAutoplay();
$('#scroller').trigger('scroll');
});
... ... @@ -10065,6 +10125,8 @@ function search(opt) {
}
}
scH = $('#scroller').outerHeight();
nav.reload = false;
nav.page = page;
... ... @@ -10073,10 +10135,9 @@ function search(opt) {
window.rePosFooter();
setTimeout(function() {
myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
myScroll.refresh();
rePos();
bindGoodThumbClick();
},
error: function() {
... ... @@ -10116,6 +10177,8 @@ $subNav.on('touchend touchcancel', function(e) {
//点击筛选钱的active项回复active
$pre.addClass('active');
$this.removeClass('active');
myScroll.enable();
} else {
$pre = $this.siblings('.active');
... ... @@ -10123,6 +10186,14 @@ $subNav.on('touchend touchcancel', function(e) {
$this.addClass('active');
filter.showFilter();
if ($this.closest('.pos-list').length > 0) {
$('.filter-mask').addClass('call-by-fix').css('top', '');
} else {
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
}
myScroll.disable();
}
} else {
if ($this.hasClass('new')) {
... ... @@ -10218,12 +10289,17 @@ $subNav.on('touchend touchcancel', function(e) {
});
filter.initFilter({
fCbFn: search,
fCbFn: function(option) {
search(option);
myScroll.enable();
},
hCbFn: function() {
//切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
myScroll.enable();
},
missStatus: true
});
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -199,7 +199,7 @@ function newData(callback) {
getPageGoods(req);
}
function hotData(callback) {
function hotData(callBack) {
var req = {};
req.url = location.protocol + '//m.yohobuy.com/index/search/search';
... ... @@ -227,13 +227,17 @@ function hotData(callback) {
function tabChange(dom, index) {
var li = dom.eq(index);
dom.removeClass('active');
li.addClass('active');
dom.removeClass('color');
li.addClass('color');
dom.removeClass('active color');
li.addClass('active color');
}
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
//首页导航
(function(nav, posNav, main) {
... ... @@ -242,6 +246,10 @@ function tabChange(dom, index) {
var index = $(this).index(),
activeTab = $(this).attr('tab');
if (!$('filter-mask').hasClass('hide')) {
return;
}
$nav1.removeClass('fixed-top');
tabChange($(nav + ' li'), index);
tabChange($(posNav + ' li'), index);
... ... @@ -260,24 +268,61 @@ function tabChange(dom, index) {
$nav1.removeClass('fixed-top absolute');
$nav2.removeClass('fixed-top absolute');
}
if (!$nav1.hasClass('hide')) {
myScroll.scrollTo(0, 0 - imgH);
myScroll && myScroll.scrollTo(0, 0 - imgH);
}
$nav1.addClass('hide');
});
}('#nav', '#pos-nav', '.main'));
myScroll = new IScroll('#wrapper', {
probeType: 3,
mouseWheel: true,
click: true
});
var theY;
/**
* 筛选后内容变化,导致nav1位置错掉,重新计算确保位置正确显示
*/
function reNav1Pos() {
var sTop = theY ? theY : 0;
if (sTop < imgH + main1oH + nav1H) {
if ($nav1.hasClass('hide')) {
$nav1.removeClass('hide');
}
if (sTop < imgH + main1H) {
tra = 'translate3d(0, ' + (-scH) + 'px, 0)';
$nav1.addClass('fixed-top')
.removeClass('absolute')
.css({
transform: tra,
'-moz-transform': tra,
'-ms-transform': tra,
'-webkit-transform': tra
});
} else if (sTop < imgH + main1H + nav1H) {
if ($('#home-page').is(':hidden')) {
return false;
}
$nav1.addClass('absolute')
.removeClass('fixed-top');
tra = 'translate3d(0, ' + (imgH + main1H - sTop - scH) + 'px, 0)';
$nav1.css({
transform: tra,
'-moz-transform': tra,
'-ms-transform': tra,
'-webkit-transform': tra
});
}
}
}
myScroll.on('scroll', function() {
var scrollCall,
sTop = -this.y;
var tra;
theY = sTop;
if (sTop + winH > scH - 0.25 * $goodsContainer.height() - 50) {
if ($pre !== undefined) {
search({
... ... @@ -317,7 +362,7 @@ myScroll.on('scroll', function() {
if (!$nav2.hasClass('hide')) {
$nav2.addClass('hide');
} //滑动距离不到导航1
} else if (sTop < imgH + main1oH) {
} else if (sTop < imgH + main1oH + nav1H) {
if ($nav1.hasClass('hide')) {
$nav1.removeClass('hide');
}
... ... @@ -325,7 +370,7 @@ myScroll.on('scroll', function() {
$nav2.addClass('hide');
}//滑动距离不到导航2
if (sTop < imgH + main1H - nav1H) {
if (sTop < imgH + main1H) {
if (!$nav1.hasClass('fixed-top')) {
tra = 'translate3d(0, ' + (-scH) + 'px, 0)';
$nav1.addClass('fixed-top')
... ... @@ -337,7 +382,7 @@ myScroll.on('scroll', function() {
'-webkit-transform': tra
});
}
} else if (sTop < imgH + main1H) {
} else if (sTop < imgH + main1H + nav1H) {
if ($('#home-page').is(':hidden')) {
return false;
}
... ... @@ -345,7 +390,7 @@ myScroll.on('scroll', function() {
$nav1.addClass('absolute')
.removeClass('fixed-top');
}
tra = 'translate3d(0, ' + (imgH + main1H - nav1H - sTop - scH) + 'px, 0)';
tra = 'translate3d(0, ' + (imgH + main1H - sTop - scH) + 'px, 0)';
$nav1.css({
transform: tra,
'-moz-transform': tra,
... ... @@ -577,6 +622,8 @@ function search(opt) {
}
}
scH = $('#scroller').outerHeight();
nav.reload = false;
nav.page = page;
... ... @@ -585,10 +632,9 @@ function search(opt) {
window.rePosFooter();
setTimeout(function() {
myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
myScroll.refresh();
rePos();
bindGoodThumbClick();
},
error: function() {
... ... @@ -638,6 +684,12 @@ $subNav.on('touchend touchcancel', function(e) {
filter.showFilter();
if ($this.closest('.pos-list').length > 0) {
$('.filter-mask').addClass('call-by-fix').css('top', '');
} else {
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
}
myScroll.disable();
}
} else {
... ... @@ -734,7 +786,10 @@ $subNav.on('touchend touchcancel', function(e) {
});
filter.initFilter({
fCbFn: search,
fCbFn: function(option) {
search(option);
myScroll.enable();
},
hCbFn: function() {
//切换active状态到$pre上
... ...
... ... @@ -117,10 +117,6 @@
margin-bottom: 30px;
}
.hide {
display: hidden;
}
.coupon {
width: 100%;
padding: 30px 0;
... ... @@ -300,6 +296,24 @@
border-bottom: 1px solid #e0e0e0;
}
.pos-list {
li {
position: relative;
}
.new:after,
.price:after,
.discount:after {
height: 28px;
content: '';
border-left: 1px solid #e1e1e1;
position: absolute;
top: 25px;
left: 163px;
}
}
.discount-area {
@extend .discount-page;
... ... @@ -368,6 +382,7 @@
font-size: 28px;
background: #fff;
border-top: 1px solid #eaeaea;
z-index: 2;
ul {
... ... @@ -476,12 +491,12 @@
height: 100%;
color: #999;
b {
/*b {
height: 28px;
border-left: 1px solid #e1e1e1;
float: right;
margin-top: 25px;
}
}*/
}
}
... ... @@ -538,4 +553,18 @@
.category-list-last-full-row {
border-bottom: 1px solid #e0e0e0;
}
}
.shop-index + .filter-mask {
.filter-body {
overflow: auto;
}
.classify {
height: auto;
}
&.call-by-fix {
top: 78px;
}
}
\ No newline at end of file
... ...
... ... @@ -41,23 +41,18 @@
</div>
</div>
<ul id="nav" class="nav">
<li class="active color buriedpoint" tab="home-page" data-bp-id="shop_nav_index_1">首页</li>
<li tab="new-arrival" data-bp-id="shop_nav_new_1" class="buriedpoint">上新</li>
<li tab="popularity" data-bp-id="shop_nav_populary_1" class="buriedpoint">人气</li>
<li data-bp-id="shop_nav_all_1" class="all-goods buriedpoint">
<a href="{{allGoods}}" target="_blank">全部商品</a>
</li>
</ul>
<div id="home-page" class="main">
<div id="nav-main" class="nav-main">
<!-- 大导航 -->
<ul id="nav" class="nav">
<li class="active color buriedpoint" tab="home-page" data-bp-id="shop_nav_index_1">首页</li>
<li tab="new-arrival" data-bp-id="shop_nav_new_1" class="buriedpoint">上新</li>
<li tab="popularity" data-bp-id="shop_nav_populary_1" class="buriedpoint">人气</li>
<li data-bp-id="shop_nav_all_1" class="all-goods buriedpoint">
<a href="{{allGoods}}" target="_blank">全部商品</a>
</li>
</ul>
<div id="new-arrival" class="new-arrival hide"></div>
<div id="popularity" class="popularity hide"></div>
{{#if brandList}}
<div class="multi-brands first">
<p>品牌一览</p>
... ... @@ -167,11 +162,12 @@
<div class="price-goods container hide clearfix"></div>
<div class="discount-goods container hide clearfix"></div>
{{> filter}}
</div>
</div>
</div>
</div>
<div id="new-arrival" class="new-arrival main hide"></div>
<div id="popularity" class="popularity main hide"></div>
</div>
{{#unless appVersion}}
{{> product/shop-footer}}
... ... @@ -221,6 +217,7 @@
</li>
</ul>
</div>
{{> filter}}
{{/ shopIndex}}
{{> product/query-param}}
{{> layout/footer}}
\ No newline at end of file
... ...