forked from nsjcy/frontEnd/nsjcy

liyj
2020-02-11 e60e253cb3ce0597ded89b56a414c731e28c4ff1
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
const app = getApp()
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    loading: app.globalData.imgUrl +'/image/loading.svg',
    navbar: ['全部', '未完成', '已完成'],
    currentTab: 0,
    size: 10,
    size1: 10,
    size2: 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 = "&status=";
        sizeQty = 'size';
        break;
      case 1:
        str = "&status=1";
        sizeQty = 'size1';
        break;
      case 2:
        str = "&status=2";
        sizeQty = 'size2';
        break;
    }
    wx.request({
      url: app.globalData.url + '/api/businessAggr/draftQuery?page=1&size=' + that.data[sizeQty] + '&userId=' + id + '&flag=business' + str,
      success: function (res) {
        if (res.data.code == 0) {
          (res.data.data.content).forEach(e => {
            (e.createTime) = app.formatDate(e.createTime)
            switch (e.businessType) {
              case '案件进度查询':
                e.iconSrc = app.globalData.imgUrl +'/image/businessManage/jindu_b.png';
                break;
              case '司法救助':
                e.iconSrc = app.globalData.imgUrl +'/image/businessManage/jiuzhu_b.png';
                break;
              case '信访预约':
                e.iconSrc = app.globalData.imgUrl +'/image/businessManage/yuyue_b.png';
                break;
              case '国家赔偿':
                e.iconSrc = app.globalData.imgUrl +'/image/businessManage/peichang_b.png';
                break;
              case '在线申诉':
                e.iconSrc = app.globalData.imgUrl +'/image/businessManage/shensu_b.png';
                break;
            }
          });
          console.log(sizeQty)
          if (res.data.data.totalElements < that.data[sizeQty]) {
            that.setData({
              dataSet: res.data.data.content,
              hasMoreData: false,
              content: '------我是有底线的------'
            })
          } else {
            that.setData({
              dataSet: res.data.data.content,
              hasMoreData: true,
              content: '------加载更多------',
              [sizeQty]: that.data[sizeQty] + 10
            })
          }
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
      }
    })
  },
 
  businessSchedule: function (event) {
    var id = event.currentTarget.id;
    var businessType = this.data.dataSet[id].businessType;
    var businessId = this.data.dataSet[id].businessId;
    if (businessType == "案件进度查询") {
      wx.navigateTo({
        url: '../progressQuery/progressQuery?id=' + businessId,
      })
    } else if (businessType == "信访预约") {
      wx.navigateTo({
        url: '../petitionLetters/petitionLetters?id=' + businessId,
      })
    } else if (businessType == "国家赔偿") {
      wx.navigateTo({
        url: '../compensation/compensation?id=' + businessId,
      })
    } else if (businessType == "司法救助") {
      wx.navigateTo({
        url: '../judicial/judicial?id=' + businessId,
      })
    } else if (businessType == "在线申诉") {
      wx.navigateTo({
        url: '../complain/complain?id=' + businessId + '&status=3',
      })
    } else {
      wx.showModal({
        title: '提示',
        content: "文件错误!"
      })
    }
  },
 
  onLoad: function () {
    this.showList(0)
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (this.data.hasMoreData) {
      this.showList(this.data.currentTab)
      this.setData({
        content: '------加载更多------'
      })
    } else {
      this.setData({
        content: '------我是有底线的------'
      })
    }
  },
 
})