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
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
// pages/register/index.js
const $$ = require('../../utils/util');
const app = getApp();
import Toast from '../../components/vant/toast/toast';
 
// 获取个人信息
function getUserInfoApi() {
  return $$.request({
    url: 'paUser/getUserInfo',
    type: 'get',
    service: 'cust'
  });
}
 
// 附件上传的id
function getByIdApi(param) {
  return $$.request({
    url: 'caseUtils/getNewTimeCaseId',
    type: 'get',
    submitData: param || {},
    service: 'utils'
  });
}
 
// 删除附件
function delfileApi(id) {
  return $$.request({
    url: 'fileInfo/deleteFileById?id=' + id,
    type: 'get',
    service: 'sys',
  });
}
 
function getawApi(submitData) {
  return $$.request({
    url: 'case-law/get-clain-rise-case',
    type: 'post',
    ai: true,
    submitData,
    service: 'mediate',
  });
}
 
// 获取案例
function getCaseApi(submitData) {
  return $$.request({
    url: 'case-law/get-case',
    type: 'post',
    ai: true,
    submitData,
    service: 'mediate',
  });
}
 
function caseRegisterSaveApi(submitData) {
  return $$.request({
    url: 'caseInfo/caseRegister',
    type: 'post',
    submitData,
    service: 'mediate'
  });
}
 
// 限制选择地图位置在白云区内
function checkRegisterAreaApi(submitData) {
  return $$.request({
    url: 'syRegion/checkRegisterArea',
    type: 'get',
    submitData,
    service: 'sys'
  });
}
 
Page({
  /**
   * 页面的初始数据
   */
  userInfo: {},
  location: [], // 省市区等地理资源
  select: {}, // 下拉框数据
  goToMaterialSave: false, // 避免跳转到材料上传页面重复保存草稿
  agreementMsg: '', // 服务协议
  ownerId: '', //附件上传id
  data: {
    stepText: 5, //用户须知倒计时5秒
    timer: null, // 用于存储定时器的引用
    popupVisibleText: false, //是否滚动到底部
    imgUrl: $$.url.img,
    steps: [{
        title: '填写人员',
        number: '1',
        activeIcon: 'steps-register-1-active.png'
      },
      {
        title: '描述纠纷',
        number: '2',
        activeIcon: 'steps-register-2-active.png'
      },
      {
        title: '提交申请',
        number: '3',
        activeIcon: 'steps-register-3-active.png'
      },
    ],
    saveStatus: false, //未提交,已提交
    oneList: [],
    titleShow: {
      '09_01001-1': ['自然人', '姓名', '真实姓名'],
      '09_01001-2': ['法人', '企业名称', '企业全名', '法定代表人姓名'],
      '09_01001-3': ['机构代表人', '机构名称', '机构全名', '机构代表人姓名'],
    }, // 用于判断显示的输入框标题
    stepsActive: 0, // 步骤条当前下标
    submitData: {
      occurTime: new Date().getTime(),
      occurTimeName: $$.moment(new Date().getTime()).format('YYYY-MM-DD'),
      caseType: '',
      caseTypeName: '',
      addr: '',
      lat: '',
      lng: '',
      peopleNum: '',
      amount: '',
      caseDes: '',
      caseClaim: '',
    }, // 表单数据
    fileList: [], //表单附件
    addPersonData: {}, //添加的当事人
    materialNum: 0, // 纠纷材料总数量
    userInfoVisible: false, // 是否采用个人信息更新申请人信息
    timePicker: false, //时间选择展示
    maxDate: new Date().getTime(),
    popup: {
      formtype: '', // 控制在纠纷信息 or 申请人信息 or 被申请人添加数据
      index: 0, // 如为申请人信息 or 被申请人确认下拉选择此参数为下标
    }, // 下拉弹出框数据
    changeVisible: false, // 是否是修改
    recordingVisible: false, // 录音界面是否显示
    popupMsg: {
      show: false,
      title: '',
      type: 1,
      editType: 'add',
      buttonText: ''
    }, // 弹窗, type: 1'恢复草稿',2'申请人',3'被申请人', editType: 'add'新增,'edit'修改
    tipData: {
      caseList: [].join("\n"),
      guideList: [],
    },
    caseText: '',
    caseTitle: '',
    similarity: '',
    showCase: false,
    popupSelect: {
      show: false,
      data: [],
      activeIndex: null
    }, // 选择人员
    threeAvtice: '1',
    caseDesNum: 0, //事项概况字数
    caseClaimNum: 0, //事项申请字数
  },
 
  // 获取服务协议
  async getAgreement() {
    var that = this;
    const res = await $$.commonRequest({
      url: `${$$.url.txt}agree.txt`,
      type: 'get'
    });
    if (res) {
      that.data.popupVisible = true;
      that.setData({
        popupVisible: true,
      });
      this.startCountdown(); // 启动倒计时
    }
  },
 
  //须知弹窗倒计时
  startCountdown: function () {
    let that = this;
    that.setData({
      timer: setInterval(function () {
        if (that.data.stepText > 0) {
          that.data.stepText--;
          that.setData({
            stepText: that.data.stepText
          });
        } else {
          clearInterval(that.data.timer); // 倒计时结束,清除定时器
          // 在这里执行销毁操作,比如隐藏或删除倒计时组件
        }
      }, 1000)
    })
  },
 
 
 
  // 表单修改
  handleChange(e) {
    let key = e.currentTarget.dataset.key,
      value = e.detail;
    this.data.submitData[key] = value;
    this.setData({
      submitData: this.data.submitData
    });
    if (key === 'caseDes' || key === 'caseClaim') {
      this.setData({
        [key + 'Num']: value.length
      });
    }
  },
 
  threeTagChange(e) {
    value = e.detail;
    this.setData({
      threeAvtice: value
    });
  },
  // 下拉框选择确认
  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.submitData[x] = value[0][t === 0 ? 'value' : 'label'];
      });
    } else if (type === 'location') {
      arr = [
        ['city', 'cityName'],
        ['area', 'areaName'],
        ['road', 'roadName']
      ];
      arr.forEach((x, t) => {
        this.data.submitData[x[0]] = value[t]?.value || '';
        this.data.submitData[x[1]] = value[t]?.label || '';
      });
    }
    this.setData({
      popup: this.data.popup,
      submitData: this.data.submitData
    });
  },
 
 
  // 下拉框选择开启
  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.submitData); // 计算默认的市区县下标
      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 if (type === 'occurTime') {
      this.setData({
        timePicker: true
      })
      return;
    } 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
    });
  },
 
 
 
  // 滚动到底部事件
  handlescrolltolower() {
    this.setData({
      popupVisibleText: true
    })
  },
 
  // 用户须知
  handleAgree(e) {
    let type = e.currentTarget.dataset.type;
    if (!this.data.popupVisibleText) {
      Toast('请阅读完整的用户须知');
      return;
    }
    if (type === 'agree') {
      // 同意协议之后退出登录后不重复弹出
      wx.setStorage({
        key: 'agreement',
        data: 1
      });
    }
    this.setData({
      popupVisible: false
    });
    if (this.data.oneList?.length === 0) {
      this.setData({
        addMePlaintiff: true
      })
    }
  },
 
  // 下一步 or 上一步
  handleNext(e) {
    let type = e.currentTarget.dataset.type;
    if (type === 'next' && this.data.stepsActive === 0) {
      if (this.data.oneList?.length <= 0) {
        $$.showToast({
          title: '请至少添加一名当事人',
          duration: 500
        });
      } else {
        this.setData({
          stepsActive: 1
        });
        this.getById();
      }
      return;
    }
    if (type === 'back' && this.data.stepsActive === 1) {
      this.setData({
        stepsActive: 0
      });
      return;
    }
    if (type === 'next' && this.data.stepsActive === 1) {
      let newData = this.data.submitData;
      if (!newData.caseType) {
        $$.showToast({
          title: '请选择纠纷类型',
          duration: 500
        });
        return;
      }
      if (!newData.occurTime) {
        $$.showToast({
          title: '请选择纠纷发生时间',
          duration: 500
        });
        return;
      }
      if (!newData.addr) {
        $$.showToast({
          title: '请选择纠纷发生地',
          duration: 500
        });
        return;
      }
      if (!newData.caseDes) {
        $$.showToast({
          title: '请填写事项概况',
          duration: 500
        });
        return;
      }
      if (!newData.caseClaim) {
        $$.showToast({
          title: '请填写事项申请',
          duration: 500
        });
        return;
      }
      // 提交AI接口
      // this.getaw(newData);
      if (this.data.fileList?.length <= 0) {
        // 附件上传提示
        this.setData({
          showFileTip: true
        })
        return;
      }
      this.setData({
        stepsActive: 2
      });
      return;
    }
    if (type === 'back' && this.data.stepsActive === 2) {
      this.setData({
        stepsActive: 1
      });
      return;
    }
    // 申请提交
    if (type === 'next' && this.data.stepsActive === 2) {
      let data = this.data.submitData;
      let list = this.data.oneList;
      let personList = []; //"15_020008-1" 申请方当事人 ,"15_020008-2" 被申请方当事人
      let agentList = []; //"24_00006-1" 申请方代理人 ,"24_00006-2" 被申请方代理人
      personList = list.filter(item => item.perType === '15_020008-1' || item.perType === '15_020008-2');
      agentList = list.filter(item => item.perType === '24_00006-1' || item.perType === '24_00006-2');
      this.caseRegisterSave({
        ...data,
        personList,
        agentList,
        id: this.data.ownerId,
      });
    }
  },
 
  async getaw(data) {
    let newData = {
      caseDes: data.caseDes,
      caseClaim: data.caseClaim,
      caseId: this.data.ownerId,
    }
    const res = await getawApi(newData);
    if (res.type) {
      this.setData({
        AIData: res.data || {}
      })
    }
  },
 
  async getById() {
    $$.showLoading();
    const res = await getByIdApi();
    $$.hideLoading();
    if (res.type) {
      this.setData({
        ownerId: res.data || ''
      })
    }
  },
 
  async caseRegisterSave(params) {
    $$.showLoading();
    const res = await caseRegisterSaveApi(params);
    $$.hideLoading();
    if (res.type) {
      // Toast('提交成功');
      this.setData({
        saveStatus: true
      })
    }
    const res1 = await getCaseApi({
      caseDes: params.caseDes,
      caseClaim: params.caseClaim,
      caseId: params.id,
    });
    if (res1.type) {
      wx.setStorage({
        key: 'AICase',
        data: {
          caseDes: params.caseDes,
          caseClaim: params.caseClaim,
          caseId: params.id,
        }
      });
    }
  },
 
  //选择纠纷类型 、跳转事项概况语音描述,跳转事项申请语音描述
  caseTypeGoPage(e) {
    let url = e.currentTarget.dataset.url;
    let type = e.currentTarget.dataset.type;
    let value = e.currentTarget.dataset.value;
    wx.navigateTo({
      url: url + '?type=' + type + '&value=' + value,
    });
  },
 
  // 图片识别
  ocrClick(e) {
    let key = e.currentTarget.dataset.key;
    let keyNum = e.currentTarget.dataset.keynum;
    let that = this;
    wx.chooseMedia({
      count: 1,
      mediaType: ['image'],
      success(res2) {
        const tempFiles = res2.tempFiles[0];
        $$.showLoading();
        wx.uploadFile({
          url: `${$$.baseUrl}${$$.url.sys}/api/wechat/fileInfo/recognitionText`,
          filePath: tempFiles.tempFilePath,
          name: 'file',
          header: {
            Authorization: app.globalData.token
          },
          complete(res3) {
            $$.hideLoading();
            if (res3.errMsg === 'uploadFile:ok') {
              let {
                code,
                data
              } = JSON.parse(res3.data);
              if (code == -1) {
                $$.errorModal({
                  content: '识别失败'
                });
                return;
              }
              let wordsResult = data?.ocrResult?.wordsResult.join('');
              let wordsResultNum = data?.ocrResult?.wordsResultNum;
              that.setData({
                submitData: {
                  ...that.data.submitData,
                  [key]: that.data.submitData[key] + wordsResult
                },
                [keyNum]: (that.data.submitData[keyNum] + wordsResult).length
              });
            }
          },
        });
      },
    });
  },
 
  //选择地址
  async openmap(e) {
    var that = this;
    console.log('latitude')
    wx.getLocation({
      type: 'gcj02', //返回可以用于wx.openLocation的经纬度
      success: function (res) {
        wx.chooseLocation({
          success: function (res) {
            that.checkRegisterArea(res)
 
          },
 
        })
      }
    })
  },
 
  async checkRegisterArea(item) {
    $$.showLoading();
    const res = await checkRegisterAreaApi({
      lng: item.longitude,
      lat: item.latitude
    });
    $$.hideLoading();
    if (res.type) {
      console.log('res', res);
      if (res.data) {
        this.setData({
          submitData: {
            ...this.data.submitData,
            addr: item.address,
            lng: item.longitude,
            lat: item.latitude,
          }
        })
      } else {
        $$.errorModal({
          title: '提示信息',
          content: res.msg,
          success: () => {
 
          },
        });
      }
    }
  },
 
  delAddress() {
    this.setData({
      submitData: {
        ...this.data.submitData,
        addr: '',
        lng: '',
        lat: ''
      }
    })
  },
 
  // 上传文件图片
  async handleUploadFile(e) {
    let id = e.currentTarget.dataset.id;
    let type = e.currentTarget.dataset.type;
    let key = e.currentTarget.dataset.key;
    if (key) {
      this.setData({
        showFileTip: false
      })
    }
    let that = this;
    this.filesArr = [];
    wx.chooseMedia({
      mediaType: ['image'],
      success(res2) {
        const tempFiles = res2.tempFiles;
        // 多个文件逐一上传
        tempFiles.forEach((x, t) => {
          $$.showLoading('上传中...');
          wx.uploadFile({
            url: `${$$.baseUrl}${$$.url.sys}/api/wechat/fileInfo/upload?mainId=${id}&ownerId=${id}&ownerType=${type}`,
            filePath: x.tempFilePath,
            name: 'file',
            header: {
              Authorization: app.globalData.token
            },
            complete(res) {
              $$.hideLoading();
              if (res.errMsg === 'uploadFile:ok') {
                const getData = JSON.parse(res.data)
                const file = {
                  ...getData.data[0],
                  wxurl: x.tempFilePath
                };
                that.setData({
                  fileList: that.data.fileList.concat(file)
                })
                $$.showToast({
                  icon: 'success',
                  title: '上传成功',
                  duration: 500
                });
              } else {
                $$.showToast({
                  title: '上传失败',
                  duration: 500
                });
              }
 
            },
          });
        });
      },
    });
  },
 
  // 弹窗取消上传附件
  noUploadNext() {
    this.setData({
      stepsActive: 2,
      showFileTip: false
    });
  },
 
  // 预览图片
  handlePreviewImage(e) {
    let item = e.currentTarget.dataset.item;
    console.log('item', item);
    let index = e.currentTarget.dataset.index;
    wx.previewImage({
      current: item.wxurl,
      urls: [item.wxurl] // 需要预览的图片http链接列表
    });
  },
 
  // 删除图片
  async handleDelImage(e) {
    let item = e.currentTarget.dataset.item;
    let index = e.currentTarget.dataset.index;
    let id = e.currentTarget.dataset.id;
    let type = e.currentTarget.dataset.type;
    $$.showModal({
      title: '删除材料确认',
      content: '确定删除材料' + item.name + '吗?',
      cancelText: '我再想想',
      confirmText: '确定删除',
      success: async (res) => {
        if (res.confirm) {
          $$.showLoading();
          const res = await delfileApi(id);
          if (res.type) {
            $$.showToast({
              icon: 'success',
              title: '删除成功',
              duration: 500
            });
            let list = this.data.fileList.filter((i, idx) => idx !== index);
            console.log('list', list);
            this.setData({
              fileList: list
            })
          }
        }
      },
    });
 
  },
 
  // 请求下拉框资源
  async getSelectOptionData() {
    const res = await $$.commonRequest({
      url: `${$$.url.assets}selectOption.json`,
      type: 'get'
    });
    if (res) {
      this.select.cardType = res.data.cardType || [];
      this.select.caseCause = this.data.caseCause || [];
      this.select.personClass = res.data.personClass || [];
    }
  },
 
 
  // 获取个人信息
  async getUserInfo() {
    $$.showLoading();
    const res = await getUserInfoApi();
    $$.hideLoading();
    if (res.type) {
      let data = res.data || {}
      this.setData({
        oneList: [{
          ...data,
          perType: '15_020008-1',
          perTypeName: '申请方当事人',
          perClass: '09_01001-1',
          perClassName: '自然人',
          certiNo: data.idcard || '',
          certiType: data.certiType || '09_00015-1',
          certiTypeName: data.certiTypeName || '身份证',
          agentCode: data.idcard || '',
        }]
      })
    };
  },
 
  // 自动添加申请人提醒
  oneAddMe(e) {
    let formtype = e.currentTarget.dataset.formtype;
    if (formtype === 'yes') {
      this.getUserInfo()
    }
    this.setData({
      addMePlaintiff: false
    })
  },
 
  // 填写人员
  oneDelPerson(e) {
    console.log('e', e);
    let index = e.currentTarget.dataset.index;
    let item = e.currentTarget.dataset.item;
 
    $$.showModal({
      title: '删除人员确认',
      content: '确定删除当事人' + item.trueName + '吗?',
      cancelText: '我再想想',
      confirmText: '确定删除',
      success: (res) => {
        if (res.confirm) {
          this.setData({
            oneList: this.data.oneList.filter((i, idx) => idx !== index)
          })
        }
      },
    });
  },
 
  // 添加当事人
  oneAddPerson(e) {
    let perType = e.currentTarget.dataset.pertype;
    let perTypeName = e.currentTarget.dataset.pertypename;
    let oneList = this.data.oneList;
    if (!perType) {
      this.setData({
        addPerson: true
      })
    } else {
      this.setData({
        addPerson: false
      })
      if (perTypeName === '申请方代理人') {
        // 申请方 或 被申请方
        let newList = oneList.filter(item => item.perType === "15_020008-1");
        let objs = newList.map(i => ({
          trueName: i.trueName,
          agentCode: i.agentCode,
        }));
        wx.navigateTo({
          url: `../../pages/addAgent/index?perType=${perType}&perTypeName=${perTypeName}&objs=${JSON.stringify(objs)}`,
        });
      } else if (perTypeName === '被申请方代理人') {
        // 申请方 或 被申请方
        let newList = oneList.filter(item => item.perType === "15_020008-2");
        let objs = newList.map(i => ({
          trueName: i.trueName,
          agentCode: i.agentCode,
        }));
        wx.navigateTo({
          url: `../../pages/addAgent/index?perType=${perType}&perTypeName=${perTypeName}&objs=${JSON.stringify(objs)}`,
        });
      } else {
        wx.navigateTo({
          url: `../../pages/addPerson/index?perType=${perType}&perTypeName=${perTypeName}`,
        });
      }
    }
  },
 
  // 修改当事人
  oneEditPerson(e) {
    let item = e.currentTarget.dataset.item;
    let index = e.currentTarget.dataset.index;
    let oneList = this.data.oneList;
    if (item.perType === '24_00006-1') {
      let newList = oneList.filter(item => item.perType === "15_020008-1");
      let objs = newList.map(i => ({
        trueName: i.trueName,
        agentCode: i.agentCode,
      }));
      wx.navigateTo({
        url: `../../pages/addAgent/index?data=${JSON.stringify(item)}&index=${index}&objs=${JSON.stringify(objs)}`,
      });
    } else if (item.perType === '24_00006-2') {
      let newList = oneList.filter(item => item.perType === "15_020008-2");
      let objs = newList.map(i => ({
        trueName: i.trueName,
        agentCode: i.agentCode,
      }));
      wx.navigateTo({
        url: `../../pages/addAgent/index?data=${JSON.stringify(item)}&index=${index}&objs=${JSON.stringify(objs)}`,
      });
    } else {
      wx.navigateTo({
        url: `../../pages/addPerson/index?data=${JSON.stringify(item)}&index=${index}`,
      });
    }
  },
 
  // 关闭自定义弹窗
  addClosePopup(e) {
    let key = e.currentTarget.dataset.key;
    this.setData({
      [key]: false
    })
  },
 
  // 选择发生事件确定
  onInput(e) {
    let key = e.currentTarget.dataset.key;
    let value = e.detail;
    this.setData({
      [key]: false,
      submitData: {
        ...this.data.submitData,
        occurTime: value,
        occurTimeName: $$.moment(value).format('YYYY-MM-DD'),
      }
    })
  },
 
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    let agreement = wx.getStorageSync('agreement');
    if (!agreement) {
      this.getAgreement();
    } else {
      if (this.data.oneList?.length === 0) {
        this.setData({
          addMePlaintiff: true
        })
      }
    }
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (this.data.oneData?.trueName) {
      let list = this.data.oneList;
      if (this.data.editIndex) {
        list[this.data.editIndex] = this.data.oneData;
      } else {
        list = list.concat(this.data.oneData)
      }
      console.log('list', list);
      this.setData({
        oneList: list,
        oneData: {},
        editIndex: false,
      })
    }
 
    if (this.data.twoData?.label) {
      this.setData({
        submitData: {
          ...this.data.submitData,
          caseType: this.data.twoData.value,
          caseTypeName: this.data.twoData.label,
        },
        twoData: {}
      })
    }
    if (this.data.twoValue) {
      console.log('this.data.twoValue', this.data.twoValue);
      console.log('this.data.twoKey', this.data.twoKey);
      this.setData({
        submitData: {
          ...this.data.submitData,
          [this.data.twoKey]: this.data.submitData[this.data.twoKey] + this.data.twoValue,
        },
        [this.data.twoKey + 'Num']: (this.data.submitData[this.data.twoKey] + this.data.twoValue).length,
        twoValue: '',
        twoKey: ''
      })
    }
  },
 
  onHide: function () {
    // this.handleCheckSave();
  },
 
  onUnload: function () {
    // this.handleCheckSave();
  },
});