|
@@ -13,13 +13,21 @@ Page({
|
|
|
// 此页面 页面内容距最顶部的距离
|
|
|
height: app.globalData.height * 2 + 20,
|
|
|
},
|
|
|
- },
|
|
|
+ messageList: [],
|
|
|
+ skip: 0,
|
|
|
+ limit: 10,
|
|
|
+ total: 0,
|
|
|
+ listshow: 1,
|
|
|
+ // 是否到底
|
|
|
+ hasMoreData: true
|
|
|
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
+ var that = this;
|
|
|
+ that.searchInfo('正在加载数据...')
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -50,24 +58,84 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+ // 列表查询
|
|
|
+ searchInfo: function (message) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: message,
|
|
|
+ })
|
|
|
+ var that = this;
|
|
|
+ wx.request({
|
|
|
+ url: 'http://124.235.209.122:88/api/financial/viewnews/select', //真是接口
|
|
|
+ method: 'post',
|
|
|
+ data: {
|
|
|
+ qyid: '5e903455d72a944fd899c59c',
|
|
|
+ skip: that.data.skip,
|
|
|
+ limit: that.data.limit
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json', // 默认值
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ console.log(res)
|
|
|
+ if (res.data.errcode == '0') {
|
|
|
+ if (res.data.res.length !== 0) {
|
|
|
+ if (that.data.messageList.isEmpty) {
|
|
|
+ that.setData({ // 设置页面列表的内容
|
|
|
+ messageList: res.data.res,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({ // 设置页面列表的内容
|
|
|
+ messageList: that.data.messageList.concat(res.data.res),
|
|
|
+ total: res.data.total
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: "没有更多数据了",
|
|
|
+ duration: 1000,
|
|
|
+ icon: 'none',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ wx.hideLoading();
|
|
|
+ // complete
|
|
|
+ wx.hideNavigationBarLoading() //完成停止加载
|
|
|
+ wx.stopPullDownRefresh() //停止下拉刷新
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
-
|
|
|
+ wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
|
+ this.data.skip = 0
|
|
|
+ this.searchInfo('正在刷新数据')
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
-
|
|
|
+ const pageNum = this.data.skip;
|
|
|
+ const _pagenum = Math.ceil(this.data.total / this.data.limit);
|
|
|
+ if (pageNum < _pagenum) {
|
|
|
+ this.setData({
|
|
|
+ skip: pageNum + 1 //设置下一页
|
|
|
+ })
|
|
|
+ this.searchInfo('正在刷新数据'); //查询数据
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '没有更多数据',
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage: function () {
|
|
|
-
|
|
|
- }
|
|
|
})
|