Authored by yyq

filter fixed

@@ -37,11 +37,12 @@ Page({ @@ -37,11 +37,12 @@ Page({
37 query.select('.container .top-search').boundingClientRect(); 37 query.select('.container .top-search').boundingClientRect();
38 query.selectViewport().scrollOffset(); 38 query.selectViewport().scrollOffset();
39 query.exec(res => { 39 query.exec(res => {
40 - this.filterInitialTop = res[0].top;  
41 - this.topSearchHeight = res[1].bottom - res[1].top;  
42 - this.resetListScrollPos = res[0].top - (res[1].bottom - res[1].top); 40 + const [filter, search, scroll] = res;
43 41
44 - this.onPageScroll({scrollTop: res[2].scrollTop}); 42 + this.maxScrollTop = filter.top + scroll.scrollTop - search.bottom + search.top;
  43 + this.resetListScrollPos = this.maxScrollTop;
  44 +
  45 + this.onPageScroll({scrollTop: scroll.scrollTop});
45 }) 46 })
46 }, 1000); 47 }, 1000);
47 }, 48 },
@@ -75,19 +76,22 @@ Page({ @@ -75,19 +76,22 @@ Page({
75 }, 76 },
76 onPageScroll: function(e) { 77 onPageScroll: function(e) {
77 const { scrollTop } = e; 78 const { scrollTop } = e;
78 -  
79 - const floatFilter = scrollTop > this.filterInitialTop - this.topSearchHeight; 79 + const floatFilter = scrollTop > this.maxScrollTop;
80 const show = scrollTop > windowHeight * 2; 80 const show = scrollTop > windowHeight * 2;
81 81
  82 + let data;
  83 +
82 if (floatFilter !== this.data.floatFilter) { 84 if (floatFilter !== this.data.floatFilter) {
83 - this.setData({floatFilter}); 85 + data = data || {};
  86 + data.floatFilter = floatFilter;
84 } 87 }
85 88
86 if (show !== this.data.showBackTop) { 89 if (show !== this.data.showBackTop) {
87 - this.setData({  
88 - showBackTop: show  
89 - }); 90 + data = data || {};
  91 + data.showBackTop = show;
90 } 92 }
  93 +
  94 + data && this.setData(data);
91 }, 95 },
92 sortChange: function (e) { 96 sortChange: function (e) {
93 let params; 97 let params;
@@ -9,17 +9,18 @@ @@ -9,17 +9,18 @@
9 </view> 9 </view>
10 <resources 10 <resources
11 bindclickreport="resourceClickReport" 11 bindclickreport="resourceClickReport"
12 - content-code="{{resource.home.top}}" 12 + content-code="{{resource.home.top}}"
13 floor-index="1" refresh="{{pullRefresh}}"></resources> 13 floor-index="1" refresh="{{pullRefresh}}"></resources>
14 <view class="separator"></view> 14 <view class="separator"></view>
15 <view class="recommend-product"> 15 <view class="recommend-product">
16 - <view-title title="推荐商品" height="88"></view-title>  
17 - <view class="filter {{floatFilter ? 'float' : ''}}">  
18 - <product-list-filter bind:sortchange="sortChange"></product-list-filter> 16 + <view class="list-head">
  17 + <view-title title="推荐商品" height="88"></view-title>
  18 + <view class="filter {{floatFilter ? 'float' : ''}}">
  19 + <product-list-filter bind:sortchange="sortChange"></product-list-filter>
  20 + </view>
19 </view> 21 </view>
20 - <view wx:if="{{floatFilter}}" class="float-holder"></view>  
21 <view class="list"> 22 <view class="list">
22 - <product-list 23 + <product-list
23 list="{{productList}}" 24 list="{{productList}}"
24 show-no-more="{{showNoMore}}" 25 show-no-more="{{showNoMore}}"
25 show-loading="{{showLoading}}"> 26 show-loading="{{showLoading}}">
@@ -29,7 +30,7 @@ @@ -29,7 +30,7 @@
29 <view> 30 <view>
30 <copyright wx:if="{{showCopyright}}"></copyright> 31 <copyright wx:if="{{showCopyright}}"></copyright>
31 </view> 32 </view>
32 - <quick-navigation show-back-top="{{showBackTop}}" show="{{true}}" 33 + <quick-navigation show-back-top="{{showBackTop}}" show="{{true}}"
33 bindbacktop="backTop"></quick-navigation> 34 bindbacktop="backTop"></quick-navigation>
34 </view> 35 </view>
35 36
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 } 12 }
13 13
14 .scrollview{ 14 .scrollview{
15 - background-color:white; 15 + background-color:white;
16 } 16 }
17 17
18 .top-search { 18 .top-search {
@@ -59,24 +59,26 @@ @@ -59,24 +59,26 @@
59 margin-top: -15rpx; 59 margin-top: -15rpx;
60 } 60 }
61 61
  62 +.recommend-product .list-head {
  63 + padding-bottom: 92rpx;
  64 +}
  65 +
62 .recommend-product .filter { 66 .recommend-product .filter {
63 - position: relative; 67 + width: 100%;
  68 + height: 92rpx;
  69 + position: absolute;
64 border-top: 1rpx solid #eee; 70 border-top: 1rpx solid #eee;
65 border-bottom: 1rpx solid #eee; 71 border-bottom: 1rpx solid #eee;
  72 + box-sizing: border-box;
  73 + background-color: #fff;
66 } 74 }
67 75
68 .recommend-product .filter.float { 76 .recommend-product .filter.float {
69 position: fixed; 77 position: fixed;
70 top: 103rpx; 78 top: 103rpx;
71 - left: 0;  
72 - right: 0;  
73 z-index: 1000; 79 z-index: 1000;
74 } 80 }
75 81
76 -.recommend-product .float-holder {  
77 - height: 92rpx;  
78 -}  
79 -  
80 .recommend-product .list { 82 .recommend-product .list {
81 padding-bottom: 90rpx; 83 padding-bottom: 90rpx;
82 } 84 }