forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-02-13 a2789abb73725738127b03d95c95081b66954916
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
86
var app = getApp()
Page({
  data: {
    // navbar: ['全部', '未进行', '进行中', '已结束'],
    currentTab: 0,
    src: app.globalData.imgUrl + '/image/bg.jpg',
    itemIcon: app.globalData.imgUrl + '/image/ceshi.jpg',
    icon: app.globalData.imgUrl + '/image/fzl.svg',
    user: app.globalData.imgUrl + '/image/user.svg',
    dataSet: [{
      imgPath: 'https://c-ssl.duitang.com/uploads/item/202001/29/20200129204135_uxfox.png',
      activityTitle: '关于法制基地参观的活动',
      startTime: '2020/2/11 14:26',
      applyNum: 2,
      totalNum: 100,
      flag: false
    }],
    content: '------加载中------',
    size: 10,
    hasMoreData: true,
  },
 
  onLoad: function() {
    // this.showList()
  },
 
  showList: function() {
    var userinfo = wx.getStorageSync("user");
    var that = this;
    var id = userinfo.id;
    wx.request({
      url: app.globalData.url + '/api/activityInfo/preview?page=1&size=' + that.data.size + '&userId=' + id,
      success: function(res) {
        console.log(res)
        if (res.data.code == 0) {
          (res.data.data.content).forEach(e => {
            (e.startTime) = app.formatDate(e.startTime)
          })
 
          if (res.data.data.totalElements < that.data.size) {
            that.setData({
              dataSet: res.data.data.content,
              hasMoreData: false,
              content: '------我是有底线的------'
            })
          } else {
            that.setData({
              dataSet: res.data.data.content,
              hasMoreData: true,
              content: '------加载更多------',
              size: that.data.size + 10
            })
          }
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
 
      }
    })
  },
 
  link: function(event) {
    var id = event.currentTarget.dataset['id'];
    var flag = event.currentTarget.dataset['flag'];
    console.log(flag)
    wx.navigateTo({
      url: '../activityDetail/activityDetail?id=' + id + '&flag=' + flag,
    })
  },
 
  onReachBottom: function() {
    if (this.data.hasMoreData) {
      this.showList()
      this.setData({
        content: '------加载更多------'
      })
    } else {
      this.setData({
        content: '------我是有底线的------'
      })
    }
  },
})