xusd
7 days ago 998218675eb243d43912c203174a6b72b299c0f8
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
const $$ = require('../../utils/util');
const app = getApp();
 
function pageZzQueryApi(param) {
  return $$.request({
    url: 'ctUnit/pageTjQuery',
    type: 'get',
    submitData: param || {},
    service: 'cust'
  })
}
 
Page({
  /**
   * 页面的初始数据
   */
  userInfo: {},
  location: [], // 省市区等地理资源
  data: {
    imgUrl: $$.url.img,
    search: {
      prov: '',
      provName: '',
      city: '',
      cityName: '',
      area: '',
      areaName: '',
      road: '',
      roadName: '',
      keyword: '',
      page: 1,
      size: 10,
    }, // 查询条件
    data: [], // 数据
    total: 0, // 总数
    popup: {
      formtype: '',
      index: 0,
    }, // 下拉弹出框数据
  },
 
  // 下拉框选择确认
  handleConfirmPicker({
    detail
  }) {
    let type = this.data.popup.type,
      value = detail.detail.value,
      arr = [];
    this.data.popup.visible = false;
    if (type === 'caseCause') {
      arr = ['caseType', 'caseTypeName'];
      arr.forEach((x, t) => {
        this.data.search[x] = value[0][t === 0 ? 'value' : 'label'];
      });
    } else if (type === 'location') {
      arr = [
        ['city', 'cityName'],
        ['area', 'areaName'],
        ['road', 'roadName'],
      ];
      arr.forEach((x, t) => {
        this.data.search[x[0]] = value[t]?.value || '';
        this.data.search[x[1]] = value[t]?.label || '';
      });
    }
    this.setData({
      popup: this.data.popup,
      search: this.data.search
    });
  },
 
  // 多行下拉选择时,省市区选择
  handleChangeColumns(e) {
    if (this.data.popup.type === 'location') {
      let selectData = $$.changeLocation(e, this.location, this.data.popup.selectData);
      this.setData({
        popup: {
          ...this.data.popup,
          selectData
        }
      });
    }
  },
 
  // 下拉框选择开启
  handleShowPopup(e) {
    let type = e.currentTarget.dataset.type;
    let selectData = [];
    if (type === 'location') {
      if (this.location.length === 0) {
        return false;
      }
      let selectOption = JSON.parse(JSON.stringify(this.location));
      let arr = $$.getLocationIndex(this.location, this.data.search); // 计算默认的市区县下标
      selectData = [{
          values: selectOption,
          defaultIndex: arr[0]
        },
        {
          values: selectOption[arr[0]].children,
          defaultIndex: arr[1]
        },
        {
          values: selectOption[arr[0]].children[arr[1]].children || [],
          defaultIndex: arr[2]
        },
      ];
      selectData.forEach((x) => {
        x.values.forEach((y) => {
          delete y.children;
        });
      });
    } else {
      let selectOption = this.select[type];
      selectData = [{
        values: selectOption,
        defaultIndex: 0
      }];
    }
    this.setData({
      popup: {
        formtype: e.currentTarget.dataset.formtype,
        index: e.currentTarget.dataset.index,
        visible: true,
        title: e.currentTarget.dataset.title,
        type: type,
        selectData: selectData,
      },
    });
  },
 
  // 关闭下拉框选择
  handleClosePopup() {
    this.data.popup.visible = false;
    this.setData({
      popup: this.data.popup
    });
  },
 
  searchButton() {
    this.pageZzQuery(this.data.search)
  },
 
  async pageZzQuery(params, type) {
    $$.showLoading();
    const res = await pageZzQueryApi(params);
    $$.hideLoading();
    if (this.data.loading) {
      this.setData({
        loading: false
      });
    }
    if (res.type) {
      if (params.page === 1) {
        this.data.data = res.data.content || [];
      } else {
        this.data.data = this.data.data.concat(res.data.content || []);
      }
      this.setData({
        search: params,
        data: this.data.data,
        total: res.data.totalElements || 0
      });
      if (type === 'onPullDownRefresh') {
        $$.showToast({
          title: '已是最新记录',
          duration: 1000
        });
        wx.stopPullDownRefresh();
      }
    }
  },
 
  // 关闭底部弹窗
  handleClosePopupMsg() {
    if (this.data.popupMsg.type === 1) {
      this.getUserInfo(this.data.popupMsg.intentionObj);
    } else {
      this.setData({
        popupMsg: {
          show: false
        }
      });
    }
  },
 
  // 滚动到底部获取案件
  handlescrolltolower() {
    if (this.data.data.length >= this.data.total) {
      return false;
    }
    if (!this.data.loading) {
      this.data.loading = true;
      this.setData({
        loading: this.data.loading
      });
      let submitData = {
        ...this.data.search
      };
      submitData.page = submitData.page + 1;
      this.pageZzQuery(submitData);
    }
  },
 
  // 返回首页
  handleGoHomepage() {
    if (this.data.changeVisible) {
      wx.navigateBack({
        delta: 1,
      });
      return false;
    }
    wx.reLaunch({
      url: '../../pages/homePage/index',
    });
  },
 
  // 获取省市区等地理资源
  async getLocationData() {
    $$.showLoading();
    const res = await $$.commonRequest({
      url: `${$$.url.assets}locationSelect.json`,
      type: 'get'
    });
    $$.hideLoading();
    if (res) {
      let location = [];
      $$.province.forEach((x) => {
        location.push(res[x][0]);
      });
      this.location = location;
    }
  },
 
  // 跳转详情
  _handleGoPage(e) {
    let url = e.currentTarget.dataset.url;
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: url + '?id=' + id,
    });
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.pageZzQuery(this.data.search)
    this.getLocationData();
  },
 
  onShow: function () {
    // this.pageZzQuery(this.data.search);
  },
 
  onHide: function () {},
 
  onUnload: function () {},
});