Showing
3 changed files
with
25 additions
and
18 deletions
@@ -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; |
@@ -13,11 +13,12 @@ | @@ -13,11 +13,12 @@ | ||
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 class="list-head"> | ||
16 | <view-title title="推荐商品" height="88"></view-title> | 17 | <view-title title="推荐商品" height="88"></view-title> |
17 | <view class="filter {{floatFilter ? 'float' : ''}}"> | 18 | <view class="filter {{floatFilter ? 'float' : ''}}"> |
18 | <product-list-filter bind:sortchange="sortChange"></product-list-filter> | 19 | <product-list-filter bind:sortchange="sortChange"></product-list-filter> |
19 | </view> | 20 | </view> |
20 | - <view wx:if="{{floatFilter}}" class="float-holder"></view> | 21 | + </view> |
21 | <view class="list"> | 22 | <view class="list"> |
22 | <product-list | 23 | <product-list |
23 | list="{{productList}}" | 24 | list="{{productList}}" |
@@ -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 | } |
-
Please register or login to post a comment