forked from nsjcy/frontEnd/nsjcy

liuwh
2020-03-10 800ffe29f328c84d4de46e8867ad3ca5cbae0d4f
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// pages/wdjb/wdjb.js
const app = getApp()
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    loading: app.globalData.imgUrl + '/image/loading.svg',
    navbar: ['未检举报', '线索举报'],
    currentTab: 0,
    size: 10,
    size1: 10,
    content: '------加载中------',
    hasMoreData: true,
    createTime: '',
    dataSet: []
  },
 
  navbarTap: function (e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
    this.showList(this.data.currentTab)
 
  },
 
  showList: function (tab) {
    var userinfo = wx.getStorageSync("user");
    var that = this;
    var id = userinfo.id
    var str;
    var sizeQty;
    switch (tab) {
      case 0:
        str = "&businessType=1";
        sizeQty = 'size';
        break;
      case 1:
        str = "&businessType=2";
        sizeQty = 'size1';
        break;
    }
    wx.showLoading();
    wx.request({
      url: app.globalData.url + '/api/tipoff/query?page=1&rows=' + that.data[sizeQty] + '&createId=' + id+ str,
      success: function (res) {
        wx.hideLoading();
        console.log(res)
        if (res.data.code == 0) {
          let content = res.data.data.rows.map(({
            createTime,
            ...i
          }) => ({
            ...i,
            createTime: app.formatDate(createTime),
          }));
          if (res.data.data.total < that.data[sizeQty]) {
            that.setData({
              dataSet: content,
              hasMoreData: false,
              content: '------我是有底线的------'
            })
          } else {
            that.setData({
              dataSet: content,
              hasMoreData: true,
              content: '------加载更多------',
              size: that.data[sizeQty] + 10
            })
          }
        } else {
          wx.showToast({
            title: res.data.msg,
          })
        }
      }
    })
  },
 
  businessSchedule: function (event) {
    var id = event.currentTarget.dataset.id;
 
    console.log(id)
    console.log(event);
    wx.navigateTo({
      url: '../xsjb/xsjb?id=' + id,
    })
 
  },
 
  onLoad: function () {
    this.showList(0)
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (this.data.hasMoreData) {
      this.showList(this.data.currentTab)
      this.setData({
        content: '------加载更多------'
      })
    } else {
      this.setData({
        content: '------我是有底线的------'
      })
    }
  },
 
})