forked from nsjcy/frontEnd/nsjcy

liuwh
2020-03-25 ec511e31e01a195bfea5145f9e7e929a68cd9f7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// pages/rzcxList/rzcxList.js
const app = getApp()
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    loading: app.globalData.imgUrl + '/image/loading.svg',
    currentTab: 0,
    size: 10,
    size1: 10,
    size2: 10,
    content: '------加载中------',
    hasMoreData: true,
    createTime: '',
    dataSet: []
  },
 
 
  showList: function () {
    var userinfo = wx.getStorageSync("user");
    var that = this;
    var id = userinfo.id
    var str;
    var sizeQty;
    wx.request({
      url: app.globalData.url + '/api/entry/query?page=1&rows=' + that.data.size + '&type=' + 1 + '&userId=' + id,
      success: function (res) {
        console.log(res.data.rows)
        let dataSet = res.data.rows.map(({
          createTime,
          ...e
        }) => ({
          ...e,
          createTime: app.formatDate(createTime)
        }))
        console.log(dataSet)
        if (res.data.total < that.data.size) {
          that.setData({
            dataSet: dataSet,
            hasMoreData: false,
            content: '------我是有底线的------'
          })
        } else {
          that.setData({
            dataSet: dataSet,
            hasMoreData: true,
            content: '------加载更多------',
            size: that.data.size + 10
          })
        }
 
      }
    })
  },
 
  businessSchedule: function (event) {
    var id = event.currentTarget.id;
    wx.navigateTo({
      url: '../rzcx/rzcx?id=' + id + '&flag=wx' + '&disabled=' + true,
    })
  },
 
  onLoad: function () {
    this.showList()
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (this.data.hasMoreData) {
      this.showList(this.data.currentTab)
      this.setData({
        content: '------加载更多------'
      })
    } else {
      this.setData({
        content: '------我是有底线的------'
      })
    }
  },
 
})