添加拼团列表上拉加载 reivew by 黄敬囿
Showing
1 changed file
with
37 additions
and
3 deletions
@@ -73,6 +73,8 @@ Page(Object.assign({ | @@ -73,6 +73,8 @@ Page(Object.assign({ | ||
73 | isLogin: false, | 73 | isLogin: false, |
74 | bannerSrc:null, | 74 | bannerSrc:null, |
75 | bannerUrl: null, | 75 | bannerUrl: null, |
76 | + loading: false, | ||
77 | + page: 1, | ||
76 | 78 | ||
77 | actionsheet: { | 79 | actionsheet: { |
78 | componentId: 'shareActionSheet', | 80 | componentId: 'shareActionSheet', |
@@ -197,7 +199,14 @@ Page(Object.assign({ | @@ -197,7 +199,14 @@ Page(Object.assign({ | ||
197 | * 页面上拉触底事件的处理函数 | 199 | * 页面上拉触底事件的处理函数 |
198 | */ | 200 | */ |
199 | onReachBottom: function() { | 201 | onReachBottom: function() { |
200 | - | 202 | + if (this.data.loading) return; |
203 | + let page = this.data.page || 1; | ||
204 | + page = page + 1; | ||
205 | + this.setData({ | ||
206 | + page, | ||
207 | + loading: true | ||
208 | + }) | ||
209 | + this._loadGroupList(page); | ||
201 | }, | 210 | }, |
202 | 211 | ||
203 | /** | 212 | /** |
@@ -207,10 +216,10 @@ Page(Object.assign({ | @@ -207,10 +216,10 @@ Page(Object.assign({ | ||
207 | 216 | ||
208 | }, | 217 | }, |
209 | 218 | ||
210 | - _getGroupList(page) { | 219 | + _getGroupList() { |
211 | this.commonService.getGroupList({ | 220 | this.commonService.getGroupList({ |
212 | limit: 20, | 221 | limit: 20, |
213 | - page | 222 | + page: 1 |
214 | }).then(res => { | 223 | }).then(res => { |
215 | if (res.code === 200 && res.data) { | 224 | if (res.code === 200 && res.data) { |
216 | this.setData({ | 225 | this.setData({ |
@@ -220,6 +229,31 @@ Page(Object.assign({ | @@ -220,6 +229,31 @@ Page(Object.assign({ | ||
220 | }); | 229 | }); |
221 | }, | 230 | }, |
222 | 231 | ||
232 | + _loadGroupList(page) { | ||
233 | + this.commonService.getGroupList({ | ||
234 | + limit: 20, | ||
235 | + page | ||
236 | + }).then(res => { | ||
237 | + if (res.code === 200 && res.data) { | ||
238 | + let groupList = this.data.groupList || []; | ||
239 | + if (res.data.list.length > 0) { | ||
240 | + this.setData({ | ||
241 | + groupList: groupList.concat(res.data.list), | ||
242 | + loading: false, | ||
243 | + }) | ||
244 | + } else { | ||
245 | + this.setData({ | ||
246 | + loading: false | ||
247 | + }) | ||
248 | + } | ||
249 | + } | ||
250 | + }).catch(error => { | ||
251 | + this.setData({ | ||
252 | + loading: false | ||
253 | + }); | ||
254 | + }); | ||
255 | + }, | ||
256 | + | ||
223 | _init() { | 257 | _init() { |
224 | let params = { | 258 | let params = { |
225 | actPrizeId: this.data.actPrizeId | 259 | actPrizeId: this.data.actPrizeId |
-
Please register or login to post a comment