forked from nsjcy/frontEnd/nsjcy

xuxj
2020-05-09 d7004986135c0885c1b9a92fb48919179732c00d
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// pages/progressQuery/progressQuery.js
const app = getApp();
var Validator = require("../../utils/validate.tools.js");
const verify = Validator.Validator;
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    array: ['请选择性别', '男', '女'],
    nature: ['请选择举报性质', '涉黑涉恶违法犯罪行为', '涉黑涉恶违法犯罪保护伞', '其他'],
    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',
    yes: app.globalData.imgUrl + '/image/yes.svg',
    add: app.globalData.imgUrl + '/image/add.svg',
    del: app.globalData.imgUrl + '/image/del.svg',
    banner: app.globalData.imgUrl + '/image/sgce_banner.png',
    disabled: false,
    disabled1: false,
    id1: '',
    id2: '',
    evalList: {},
    scanData: {},
    peopleInfo: {},
    ReplyLogs: [],
    switch: true,
  },
 
  inputChange: function(e) {
    var name = e.currentTarget.dataset.name;
    if (name == "nature" || name == "content") {
      this.setData({
        scanData: {
          ...this.data.scanData,
          [name]: e.detail.value
        }
      })
    } else {
      this.setData({
        peopleInfo: {
          ...this.data.peopleInfo,
          [name]: e.detail.value
        }
      })
    }
  },
 
  selectChange: function(e) {
    var name = e.currentTarget.dataset.name;
    if (name === "nature") {
      this.setData({
        scanData: {
          ...this.data.scanData,
          'showNature': e.detail.value, //举报性质,1:涉黑涉恶违法犯罪行为,2:涉黑涉恶违法犯罪保护伞,3:其他
          [name]: Number(e.detail.value)
        }
      })
    } else if (name === "userSex") {
      this.setData({
        peopleInfo: {
          ...this.data.peopleInfo,
          "showUserSex": e.detail.value,
          [name]: Number(e.detail.value)
        }
      })
    } else if (name == 'userBirthday') {
      this.setData({
        peopleInfo: {
          ...this.data.peopleInfo,
          [name]: e.detail.value
        }
      })
    } else {
      this.setData({
        scanData: {
          ...this.data.scanData,
          [name]: e.detail.value
        }
      })
    }
 
  },
 
  //举报人按钮
  switchChange: function(e) {
    this.setData({
      switch: e.detail.value,
    })
  },
  onLoad: function(option) {
    var openId = wx.getStorageSync("openId");
    var userinfo = wx.getStorageSync("user");
    var that = this;
    this.setData({
      id: option.id,
    })
    wx.request({
      url: app.globalData.url + '/api/v1/crackdown/find?id=' + that.data.id + '&flag=WX',
      success: function(res) {
        if (res.data.code == 0) {
          var data1 = res.data.data.crimeCrackdown;
          var data2 = res.data.data.userInfo || {};
          var data3 = res.data.data.ReplyLogs || [];
          for (var i = 0; i < data3.length; i++) {
            data3[i].createTime = app.formatDate(data3[i].createTime)
          }
          var status = data1.status;
          var disabled = app.judgeDisable(status);
          data1.createId = userinfo.id;
          var evalList1017 = data1.attList || [];
          var evalList1001 = data2.attList || [];
          var evalList = {
            evalList1001,
            evalList1017
          }
          for (var i in evalList) {
            evalList[i] = evalList[i].map(({
              path: pic,
              id: id
            }) => ({
              pic,
              id
            }))
          }
          data1.showNature = data1.nature;
          data2.showUserSex = Number(data2.userSex);
          data2.userBirthday = data2.userBirthday || '1985-01-01';
          if (that.data.id != 'new') {
            that.setData({
              switch: data1.isRealName == 1 ? true : false,
            })
          }
          that.setData({
            scanData: data1,
            peopleInfo: data2,
            disabled: disabled,
            id1: data1.id || '',
            id2: data2.id || '',
            showTime: app.formatDate(data1.createTime),
            status,
            evalList,
            ReplyLogs: data3
          })
        } else {
          wx.showModal({
            title: '提示',
            content: "初始化请求失败!"
          })
        }
      }
    })
  },
 
  submit: function(e) {
    var scanData = this.data.scanData;
    var status = e.currentTarget.dataset.type;
    scanData.status = status;
    var that = this;
    var title = '';
    if (status == "1") {
      if (!scanData.nature) {
        return app.showModal("请选择举报性质!");
      }
      if (!scanData.content) {
        return app.showModal("请填写举报事项!");
      }
      
      const {
        evalList1017,
        evalList1001
      } = this.data.evalList;
      if (evalList1017.length == 0) {
        return app.showModal("请上传相关材料/照片!");
      }
      debugger;
      if (that.data.switch) {
        scanData.isRealName = 1;
        var peopleInfo = that.data.peopleInfo;
        if (!(peopleInfo.userName && peopleInfo.mobile && peopleInfo.address && peopleInfo.cardNo && peopleInfo.userBirthday && evalList1001.length > 0)) {
          if (!peopleInfo.userName) {
            return app.showModal("请填写姓名!");
          }
          if (!peopleInfo.userSex) {
            return app.showModal("请选择性别!");
          }
          if (!peopleInfo.mobile) {
            return app.showModal("请填写联系方式!");
          } else {
            if (!verify.phone(peopleInfo.mobile)) {
              return app.showModal("手机号码格式不正确!")
            }
          }
          if (!peopleInfo.address) {
            return app.showModal("请填写住所!");
          }
          if (!peopleInfo.cardNo) {
            return app.showModal("请填写身份证号码!");
          } else {
            if (!verify.carIdNumber(peopleInfo.cardNo)) {
              return app.showModal("身份证格式不正确!")
            }
          }
        } else {
          if (evalList1001.length < 2) {
            return app.showModal("请至少上传两张身份证附件!")
          }
        }
      } else {
        scanData.isRealName = 0;
      }
    }
    if (that.data.switch) {
      scanData.isRealName = 1;
    } else {
      scanData.isRealName = 0;
    }
    var obj = {
      crimeCrackdown: that.data.scanData,
      userInfo: that.data.peopleInfo,
    };
    wx.request({
      url: app.globalData.url + '/api/v1/crackdown/save',
      data: obj,
      method: 'POST',
      header: {
        "Content-Type": "application/json"
      },
      success: function(res) {
        if (res.data.code == 0) {
          if (status == 0) {
            title = '保存草稿成功!';
          } else {
            title = '提交成功!';
          }
          wx.showToast({
            title,
            icon: 'success',
            duration: 2000
          })
          setTimeout(function() {
            wx.reLaunch({
              url: '../index/index',
            })
          }, 2000)
        } else {
          wx.showModal({
            title: '提示',
            content: "提交失败!"
          })
        }
      }
    })
  },
  reply: function(e) {
    var that = this;
    var openId = wx.getStorageSync("openId")
    var obj = {
      openId: openId,
      content: that.data.peopleInfo.replyContent,
      busType: 26,
      busId: that.data.id1
    };
    wx.request({
      url: app.globalData.url + '/api/v1/crackdown/reply',
      data: obj,
      method: 'POST',
      header: {
        "Content-Type": "application/json"
      },
      success: function(res) {
        if (res.data.code == 0) {
          wx.showToast({
            title: '提交回复成功',
            icon: 'success',
            duration: 2000
          })
          setTimeout(function() {
            wx.navigateBack({
              changed: true
            }); //返回上一页
          }, 2000)
        } else {
          wx.showModal({
            title: '提示',
            content: "提交失败!"
          })
        }
      }
    })
  },
  //添加图片
  joinPicture1: function(e) {
    var that = this;
    app.joinPicture(e, that, e.currentTarget.dataset.associatetypeid, that.data.id1);
  },
 
  //添加图片
  joinPicture2: function(e) {
    var that = this;
    app.joinPicture(e, that, e.currentTarget.dataset.associatetypeid, that.data.id2);
  },
 
  joinVideo: function(e) {
    var that = this;
    app.joinVideo(e, that);
  },
 
  // 删除图片
  clearImg: function(e) {
    var that = this;
    app.clearImg(e, that);
  },
 
  //预览图片
  previewImage: function(e) {
    app.previewImage(e);
  },
 
  goback: function() {
    wx.navigateBack({
      changed: true
    }); //返回上一页
  },
 
  // 跳转扫黑除恶举报须知页面
  scanEvildoingInfo: function() {
    wx.navigateTo({
      url: '../scanEvildoingInfo/scanEvildoingInfo',
    })
  }
})