|
@@ -9,8 +9,10 @@ Page({
|
|
|
postList: [],
|
|
|
page: 1,
|
|
|
limit: 20,
|
|
|
+ scrollH: 500,
|
|
|
isEmpty: false,
|
|
|
isEnd: false,
|
|
|
+ isRefresh: false,
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -22,6 +24,7 @@ Page({
|
|
|
if (shareUid && shareUid.length) {
|
|
|
util.setStorageSync("SHAREUID", shareUid);
|
|
|
}
|
|
|
+ this.getScrollH();
|
|
|
this.loadPostsData({ isRefresh: true });
|
|
|
},
|
|
|
|
|
@@ -44,19 +47,32 @@ Page({
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
- onReachBottom: function () {
|
|
|
+ scrollToLower: function () {
|
|
|
+ if (this._isload) return false;
|
|
|
this.loadPostsData({
|
|
|
isRefresh: false,
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ getScrollH() {
|
|
|
+ const _this = this;
|
|
|
+ wx.createSelectorQuery()
|
|
|
+ .select("#navBar")
|
|
|
+ .boundingClientRect(function (res) {
|
|
|
+ const sys = wx.getSystemInfoSync();
|
|
|
+ _this.setData({
|
|
|
+ scrollH: sys.windowHeight - res.height,
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .exec();
|
|
|
+ },
|
|
|
+
|
|
|
loadPostsData(obj) {
|
|
|
- const { page, limit, postList } = this.data;
|
|
|
+ const { limit, postList } = this.data;
|
|
|
let params = {};
|
|
|
params.url = api_news_list;
|
|
|
params.data = {
|
|
|
type: 3,
|
|
|
- page: page,
|
|
|
limit: limit,
|
|
|
};
|
|
|
const len = postList.length;
|
|
@@ -76,6 +92,10 @@ Page({
|
|
|
isEnd: data.list.length < limit,
|
|
|
});
|
|
|
}
|
|
|
+ this.setData({
|
|
|
+ isRefresh: false,
|
|
|
+ });
|
|
|
+ this._isload = false;
|
|
|
this._refresh = false;
|
|
|
} else {
|
|
|
if (data.list.length) {
|
|
@@ -92,6 +112,13 @@ Page({
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
+ refresherrefresh() {
|
|
|
+ if (this._refresh) return;
|
|
|
+ this.setData({
|
|
|
+ isRefresh: true,
|
|
|
+ });
|
|
|
+ this.loadPostsData({ isRefresh: true });
|
|
|
+ },
|
|
|
refreshCallback() {
|
|
|
this.loadPostsData({ isRefresh: true });
|
|
|
},
|