Showing
8 changed files
with
70 additions
and
18 deletions
@@ -4,6 +4,7 @@ import listModel from '../../../models/product/list'; | @@ -4,6 +4,7 @@ import listModel from '../../../models/product/list'; | ||
4 | import {parse} from '../../../vendors/query-stringify'; | 4 | import {parse} from '../../../vendors/query-stringify'; |
5 | 5 | ||
6 | const yas = new Yas(); | 6 | const yas = new Yas(); |
7 | +const {windowHeight} = getApp().getSystemInfo(); | ||
7 | 8 | ||
8 | Page({ | 9 | Page({ |
9 | data: { | 10 | data: { |
@@ -16,7 +17,7 @@ Page({ | @@ -16,7 +17,7 @@ Page({ | ||
16 | currentPage: 0, | 17 | currentPage: 0, |
17 | totalPage: 1, | 18 | totalPage: 1, |
18 | urlParams: {}, | 19 | urlParams: {}, |
19 | - showBackTop: true | 20 | + showBackTop: false |
20 | }, | 21 | }, |
21 | onLoad:function (options) { | 22 | onLoad:function (options) { |
22 | let title = decodeURIComponent(options.title) || '默认标题'; | 23 | let title = decodeURIComponent(options.title) || '默认标题'; |
@@ -32,6 +33,18 @@ Page({ | @@ -32,6 +33,18 @@ Page({ | ||
32 | this.productList(options); | 33 | this.productList(options); |
33 | yas.pageOpenReport(); | 34 | yas.pageOpenReport(); |
34 | }, | 35 | }, |
36 | + onPageScroll: function({scrollTop}) { | ||
37 | + if (scrollTop > windowHeight * 2 !== this.data.showBackTop) { | ||
38 | + this.setData({ | ||
39 | + showBackTop: scrollTop > windowHeight * 2 | ||
40 | + }); | ||
41 | + } | ||
42 | + }, | ||
43 | + backTop: function() { | ||
44 | + wx.pageScrollTo({ | ||
45 | + scrollTop: 0 | ||
46 | + }); | ||
47 | + }, | ||
35 | onReachBottom: function () { | 48 | onReachBottom: function () { |
36 | this.productList(this.data.urlParams); | 49 | this.productList(this.data.urlParams); |
37 | }, | 50 | }, |
@@ -77,6 +90,13 @@ Page({ | @@ -77,6 +90,13 @@ Page({ | ||
77 | totalPage: res.data.page_total, | 90 | totalPage: res.data.page_total, |
78 | showNoMore: params.page === res.data.page_total | 91 | showNoMore: params.page === res.data.page_total |
79 | }); | 92 | }); |
93 | + | ||
94 | + if (params.resetScroll) { | ||
95 | + wx.pageScrollTo({ | ||
96 | + scrollTop: 0, | ||
97 | + duration: 10 | ||
98 | + }); | ||
99 | + } | ||
80 | } | 100 | } |
81 | }); | 101 | }); |
82 | }, | 102 | }, |
@@ -89,6 +109,6 @@ Page({ | @@ -89,6 +109,6 @@ Page({ | ||
89 | this.data.totalPage = 1; | 109 | this.data.totalPage = 1; |
90 | 110 | ||
91 | this.data.productList = []; | 111 | this.data.productList = []; |
92 | - this.productList(this.data.urlParams); | 112 | + this.productList(Object.assign({resetScroll: true}, this.data.urlParams)); |
93 | } | 113 | } |
94 | }); | 114 | }); |
1 | -<scroll-view class="list-container"> | 1 | +<view class="list-container"> |
2 | <view class="filter-view"> | 2 | <view class="filter-view"> |
3 | <product-list-filter bind:sortchange="sortChange"></product-list-filter> | 3 | <product-list-filter bind:sortchange="sortChange"></product-list-filter> |
4 | </view> | 4 | </view> |
@@ -8,6 +8,5 @@ | @@ -8,6 +8,5 @@ | ||
8 | show-no-more="{{showNoMore}}"></product-list> | 8 | show-no-more="{{showNoMore}}"></product-list> |
9 | </view> | 9 | </view> |
10 | <copyright></copyright> | 10 | <copyright></copyright> |
11 | - <quick-navigation show-menu="{{false}}" show-back-top="{{showBackTop}}" show="{{true}}" | ||
12 | - bindbacktop="backTop"></quick-navigation> | ||
13 | -</scroll-view> | ||
11 | + <quick-navigation show-menu="{{true}}" show-back-top="{{showBackTop}}" bindbacktop="backTop"></quick-navigation> | ||
12 | +</view> |
@@ -121,6 +121,13 @@ Page({ | @@ -121,6 +121,13 @@ Page({ | ||
121 | currentPage: params.page, | 121 | currentPage: params.page, |
122 | totalPage: res.data.page_total | 122 | totalPage: res.data.page_total |
123 | }); | 123 | }); |
124 | + | ||
125 | + if (this.data.fixedFilter && params.resetScroll) { | ||
126 | + wx.pageScrollTo({ | ||
127 | + scrollTop: this.data.shopInfoHeight, | ||
128 | + duration: 10 | ||
129 | + }); | ||
130 | + } | ||
124 | } | 131 | } |
125 | }).catch(() => { | 132 | }).catch(() => { |
126 | this.data.isLoading = false; | 133 | this.data.isLoading = false; |
@@ -155,6 +162,7 @@ Page({ | @@ -155,6 +162,7 @@ Page({ | ||
155 | limit: 20 | 162 | limit: 20 |
156 | }; | 163 | }; |
157 | this.data.productList = []; | 164 | this.data.productList = []; |
165 | + params.resetScroll = true; | ||
158 | this.productList(params); | 166 | this.productList(params); |
159 | }, | 167 | }, |
160 | //店铺信息 | 168 | //店铺信息 |
@@ -252,13 +260,24 @@ Page({ | @@ -252,13 +260,24 @@ Page({ | ||
252 | }); | 260 | }); |
253 | }); | 261 | }); |
254 | }, | 262 | }, |
255 | - scroll: function (e) { | ||
256 | - const { scrollTop } = e.detail; | 263 | + onPageScroll: function({scrollTop}) { |
264 | + if (scrollTop >= this.data.shopInfoHeight !== this.data.fixedFilter) { | ||
257 | this.setData({ | 265 | this.setData({ |
258 | fixedFilter: scrollTop >= this.data.shopInfoHeight | 266 | fixedFilter: scrollTop >= this.data.shopInfoHeight |
259 | }); | 267 | }); |
268 | + } | ||
269 | + if (scrollTop > windowHeight * 2 !== this.data.showBackTop) { | ||
270 | + this.setData({ | ||
271 | + showBackTop: scrollTop > windowHeight * 2 | ||
272 | + }); | ||
273 | + } | ||
274 | + }, | ||
275 | + backTop: function() { | ||
276 | + wx.pageScrollTo({ | ||
277 | + scrollTop: 0 | ||
278 | + }); | ||
260 | }, | 279 | }, |
261 | - loadMore: function () { | 280 | + onReachBottom: function () { |
262 | if (this.data.currentPage < this.data.totalPage) { | 281 | if (this.data.currentPage < this.data.totalPage) { |
263 | this.setData({ | 282 | this.setData({ |
264 | showLoading: true | 283 | showLoading: true |
1 | <wxs src="../../../wxs/helper.wxs" module="helper"></wxs> | 1 | <wxs src="../../../wxs/helper.wxs" module="helper"></wxs> |
2 | <import src="../../../vendors/zanui/actionsheet/index.wxml"/> | 2 | <import src="../../../vendors/zanui/actionsheet/index.wxml"/> |
3 | -<scroll-view class="shop-container" scroll-y bindscroll="scroll" scroll-top="{{scrollTop}}" bindscrolltolower="loadMore" | 3 | +<view class="shop-container" scroll-y bindscroll="scroll" scroll-top="{{scrollTop}}" bindscrolltolower="loadMore" |
4 | style="height:{{windowHeight}}px;"> | 4 | style="height:{{windowHeight}}px;"> |
5 | <view class="shop-info"> | 5 | <view class="shop-info"> |
6 | <image class="shop-info-bg" src="{{bannerUrl}}"></image> | 6 | <image class="shop-info-bg" src="{{bannerUrl}}"></image> |
@@ -22,7 +22,6 @@ | @@ -22,7 +22,6 @@ | ||
22 | show-no-more="{{showNoMore}}"></product-list> | 22 | show-no-more="{{showNoMore}}"></product-list> |
23 | </view> | 23 | </view> |
24 | <copyright></copyright> | 24 | <copyright></copyright> |
25 | - <quick-navigation show-menu="{{false}}" show-back-top="{{showBackTop}}" show="{{true}}" | ||
26 | - bindbacktop="backTop"></quick-navigation> | ||
27 | -</scroll-view> | 25 | + <quick-navigation show-menu="{{true}}" show-back-top="{{showBackTop}}" bindbacktop="backTop"></quick-navigation> |
26 | +</view> | ||
28 | <template is="zan-actionsheet" data="{{...actionsheet}}" /> | 27 | <template is="zan-actionsheet" data="{{...actionsheet}}" /> |
@@ -3,6 +3,7 @@ import Yas from '../../../common/yas' | @@ -3,6 +3,7 @@ import Yas from '../../../common/yas' | ||
3 | import searchModel from '../../../models/product/search'; | 3 | import searchModel from '../../../models/product/search'; |
4 | 4 | ||
5 | const yas = new Yas(); | 5 | const yas = new Yas(); |
6 | +const {windowHeight} = getApp().getSystemInfo(); | ||
6 | 7 | ||
7 | Page({ | 8 | Page({ |
8 | data: { | 9 | data: { |
@@ -17,7 +18,7 @@ Page({ | @@ -17,7 +18,7 @@ Page({ | ||
17 | noResult: false, | 18 | noResult: false, |
18 | showLoading: false, | 19 | showLoading: false, |
19 | showNoMore: false, | 20 | showNoMore: false, |
20 | - showBackTop: true | 21 | + showBackTop: false |
21 | }, | 22 | }, |
22 | onReachBottom: function () { | 23 | onReachBottom: function () { |
23 | if (this.data.currentPage < this.data.totalPage) { | 24 | if (this.data.currentPage < this.data.totalPage) { |
@@ -40,6 +41,18 @@ Page({ | @@ -40,6 +41,18 @@ Page({ | ||
40 | onLoad: function() { | 41 | onLoad: function() { |
41 | yas.pageOpenReport(); | 42 | yas.pageOpenReport(); |
42 | }, | 43 | }, |
44 | + onPageScroll: function({scrollTop}) { | ||
45 | + if (scrollTop > windowHeight * 2 !== this.data.showBackTop) { | ||
46 | + this.setData({ | ||
47 | + showBackTop: scrollTop > windowHeight * 2 | ||
48 | + }); | ||
49 | + } | ||
50 | + }, | ||
51 | + backTop: function() { | ||
52 | + wx.pageScrollTo({ | ||
53 | + scrollTop: 0 | ||
54 | + }); | ||
55 | + }, | ||
43 | bindQueryInput: function(e) { | 56 | bindQueryInput: function(e) { |
44 | this.setData({ | 57 | this.setData({ |
45 | query: e.detail.value | 58 | query: e.detail.value |
@@ -105,10 +118,12 @@ Page({ | @@ -105,10 +118,12 @@ Page({ | ||
105 | noResult: this.data.productList.concat(list).length === 0 | 118 | noResult: this.data.productList.concat(list).length === 0 |
106 | }); | 119 | }); |
107 | 120 | ||
121 | + if (params.resetScroll) { | ||
108 | wx.pageScrollTo({ | 122 | wx.pageScrollTo({ |
109 | scrollTop: 0, | 123 | scrollTop: 0, |
110 | duration: 10 | 124 | duration: 10 |
111 | }); | 125 | }); |
126 | + } | ||
112 | wx.hideLoading(); | 127 | wx.hideLoading(); |
113 | } | 128 | } |
114 | }).catch(() => { | 129 | }).catch(() => { |
@@ -131,6 +146,7 @@ Page({ | @@ -131,6 +146,7 @@ Page({ | ||
131 | query: this.data.query | 146 | query: this.data.query |
132 | }; | 147 | }; |
133 | this.data.productList = []; | 148 | this.data.productList = []; |
149 | + params.resetScroll = true; | ||
134 | this.productList(params); | 150 | this.productList(params); |
135 | } | 151 | } |
136 | }); | 152 | }); |
@@ -20,6 +20,5 @@ | @@ -20,6 +20,5 @@ | ||
20 | </product-list> | 20 | </product-list> |
21 | </view> | 21 | </view> |
22 | </view> | 22 | </view> |
23 | - <quick-navigation show-menu="{{false}}" show-back-top="{{showBackTop}}" show="{{true}}" | ||
24 | - bindbacktop="backTop"></quick-navigation> | 23 | + <quick-navigation show-back-top="{{showBackTop}}" bindbacktop="backTop"></quick-navigation> |
25 | </view> | 24 | </view> |
-
Please register or login to post a comment