index.js
42.2 KB
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
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
import { commonApi, mineApi } from '~/api/api'
let isFirst = true;
import Dialog from '@vant/weapp/dialog/dialog';
import ActivityApi from "~/api/activityApi/index"
Page({
data: {
stepList: [{
title: '客户信息补充',
isActive: false,
}, {
title: '报案信息',
isActive: false,
}, {
title: '上传资料',
isActive: false,
},],
// 车辆信息
carInfo: {
plate: '',
billingDate: '',
vin: '',
engineNo: '',
invoicePrice: ''
},
// 客户信息
customerInfo: {
typeObj: {
name: '个人',
type: 1,
cardName: '身份证号'
},
customerName: '',
cardNo: '',
customerPhone: '',
customerAddress: ''
},
// 为了兼容车型选择组件
obj: {},
// 报案信息
reportCaseInfo: {
reporterName: '',
reporterPhone: '',
reportDate: '',
reimbursementDate: '',
address: '',
area: '',
code: []
},
// 核赔项目选择信息
projectInfo: [
{
serviceItemName: '代步车服务',
check: false,
approveAmount: '',
serviceItemCode: 'SC0023',
packageCode: 'PC0036'
},
{
serviceItemName: '车辆补漆服务',
check: false,
approveAmount: '',
serviceItemCode: 'SC0019',
packageCode: 'PC0036'
},
],
// 图片资料
imageInfo: {
idCard: [],//身份证
drivingLicense: '',//行驶证
accident: '',//事故责任认定书或相关凭证
vin: '',//车架号VIN照片
carAndPeople: '',//45°车头角度全车照片及人车合照
vehicleDamage: [],// 车辆受损细节照片 (可多张)
InsuranceLossStatement: '',//保险定损单
},
// 案件说明
caseDesc: '',
// 操作人信息
opraterInfo: {
name: '',
phone: ''
},
// 当前步骤索引
currentStep: 0,
// 客户信息映射值
customerMapItem: {
1: {
type: 1,
name: '个人',
cardName: '身份证号',
},
2: {
type: 2,
name: '企业',
cardName: '统一社会信息代码'
},
3: {
type: 3,
name: '个人(港澳)',
cardName: '港澳返乡证'
},
4: {
type: 4,
name: '个人(台)',
cardName: '台胞证'
},
5: {
type: 5,
name: '个人(军官)',
cardName: '军官证'
},
7: {
type: 7,
name: '外国人',
cardName: '护照'
},
},
// 动态输入项目
productList: [],
// 动态输入的内容
dynamicObj: {
}
},
onRoute(options) {
if (this.choosePlate) return
const { customerPhone,
licenseNumber,
customerName, packageCode } = options;
this.packageCode = packageCode
if (options.id) {
this.id = options.id
this.equityAndClaimsDetail(options.id)
} else {
this.equityAndClaimsInfo(customerPhone, licenseNumber)
this.getDymicProductList(packageCode)
}
this.getMerchantInfo()
this.setData({
options,
'carInfo.plate': licenseNumber,
'customerInfo.customerPhone': customerPhone || '',
'customerInfo.customerName': customerName || '',
'reportCaseInfo.reporterName': customerName || '',
'reportCaseInfo.reporterPhone': customerPhone || '',
endTime: new Date().format('yyyy-MM-dd')
})
if (options && options.operation) {
this.operation = options.operation
}
},
equityAndClaimsDetail(id) {
wx.$api.showLoading('加载中')
ActivityApi.equityAndClaimsDetail({ id, needDetail: true }).then(res => {
wx.hideLoading();
let { reporterName, reporterPhone, reimbursementDate, reporterDate, serviceItemsList, supplementList, reimbursementAddr, reimbursementProvinceCode, reimbursementCityCode, reimbursementCountiesCode } = res
const { vehicle, customerName, customerPhone, cardNo, customerAddress, customerType, packageCode, attributes } = res.equityOrderDetail
let { carInfo, obj, customerInfo, customerMapItem, reportCaseInfo, projectInfo, caseDesc } = this.data
carInfo = {
plate: vehicle.licensePlate,
billingDate: vehicle.billingDate ? new Date(vehicle.billingDate).format('yyyy-MM-dd') : '',
vin: vehicle.vin,
engineNo: vehicle.engineNo,
invoicePrice: vehicle.invoicePrice
}
obj = {
brandChildId: vehicle.vehicleSubBrandId,
brandChildName: vehicle.vehicleSubBrandName,
brandId: vehicle.vehicleBrandId,
brandName: vehicle.vehicleBrandName,
carTypeId: vehicle.vehicleShapeId,
carTypeName: vehicle.vehicleShapeName,
seriseId: vehicle.vehicleSeriesId,
seriseName: vehicle.vehicleSeriesName,
}
customerInfo = {
typeObj: customerMapItem[customerType],
customerName,
cardNo,
customerPhone,
customerAddress
}
let _reg = new RegExp("23:59:59", "g")
reporterDate = reporterDate ? reporterDate.replace(_reg, '') : ''
reimbursementDate = reimbursementDate ? reimbursementDate.replace(_reg, '') : ''
let _tt = {
reporterName,
reporterPhone,
reportDate: reporterDate,
reimbursementDate,
address: reimbursementAddr
}
Object.assign(reportCaseInfo, _tt)
// 此参数备用回显
this.areaQuery = {
reimbursementProvinceCode,
reimbursementCityCode,
reimbursementCountiesCode
}
if (serviceItemsList) {
serviceItemsList.forEach(el => {
projectInfo.forEach(k => {
if (k.serviceItemCode === el.serviceItemCode) {
k.check = true
k.approveAmount = el.applyAmount
}
})
})
}
if (supplementList) {
caseDesc = supplementList[0].content
this.detailSupplementList = supplementList
}
const file = res.files || [], imageInfo = { idCard: [], vehicleDamage: [] };
for (let i = 0; i < file.length; i++) {
if (file[i].mark == 'idCard') {
imageInfo[file[i].mark].push(file[i].fileUrl)
} else if (file[i].mark == 'vehicleDamage') {
imageInfo[file[i].mark].push(file[i].fileUrl)
} else {
imageInfo[file[i].mark] = file[i].fileUrl
}
}
this.setData({
carInfo,
obj,
customerInfo,
reportCaseInfo,
projectInfo,
imageInfo,
caseDesc
})
this.equityAndClaimsInfo(customerPhone, vehicle.licensePlate, true,attributes,serviceItemsList)
// this.packageCode = packageCode
// this.getDymicProductList(packageCode, attributes,serviceItemsList)
})
},
// 获取门店
getMerchantInfo() {
let { merchantId } = wx.$storage.get('userInfo') || wx.getStorageSync('merchant_info')
mineApi
.getMerchantDetail({
merchantId
})
.then(data => {
this.setData({
merchantDetail: data
})
})
},
onShow() {
this.getStorageOfOprater()
},
// 检查是否存在草稿
toCheckDraft() {
Dialog.confirm({
title: '',
message: `本车辆已存在核赔草稿,\n是否将本次填写覆盖原有草稿记录?`,
confirmButtonText: "是",
cancelButtonText: "否",
}).then(() => {
this.handerParams(2)
}).catch(() => {
})
},
// 获取操作人缓存回显
getStorageOfOprater() {
const _operater = wx.getStorageSync('GH_OPRATER_CLAIMS');
const _contact = wx.getStorageSync('GH_OPRATER_CLAIMS_PHONE');
this.setData({
opraterInfo: {
name: _operater || '',
phone: _contact || '',
}
})
},
// 处理步骤展示样式
handleStepCss() {
let { currentStep, stepList } = this.data
if (currentStep == 1) {
stepList[0].isActive = true
stepList[1].isActive = false
stepList[2].isActive = false
} else if (currentStep == 2) {
stepList[0].isActive = true
stepList[1].isActive = true
stepList[2].isActive = false
} else {
stepList[0].isActive = false
stepList[1].isActive = false
stepList[2].isActive = false
}
this.setData({
stepList
})
},
// 下一步
toNextStep() {
const { currentStep } = this.data
if (currentStep == 2) return
let _verify = {}, _verifyDynamic = {}
if (currentStep == 0) {
if (this.id) {
this.handlerShowArea()
}
_verify = this.toVerifyFirstStepInfo()
if (_verify._result) return wx.$api.showToast(_verify._error)
// 校验动态的值
_verifyDynamic = this.verifyDynamicObj()
if (_verifyDynamic._result) return wx.$api.showToast(_verifyDynamic._error)
}
if (currentStep == 1) {
_verify = this.toVerifySecondStepInfo()
if (_verify._result) return wx.$api.showToast(_verify._error)
}
this.setData({
currentStep: currentStep + 1
}, () => {
this.handleStepCss()
})
},
// 上一步
toPreStep() {
if (this.data.currentStep == 0) return
this.setData({
currentStep: this.data.currentStep - 1
}, () => {
this.handleStepCss()
})
},
// 去输入车牌
toIntPlate() {
const plate = this.selectComponent("#plate");
plate.toggle();
if (isFirst) {
isFirst = false;
plate.paste();
}
},
// 输入车牌信息
getCarPlate(e) {
this.setData({
'carInfo.plate': e.detail.value
})
},
// 选择车型
toSelectCarType() {
wx.$router.go('/packageShopmall/packageMine/pages/vehicleInfo/carBrandList/carBrandList',{notIntercept:true})
this.choosePlate = true
},
// 选择时间
toSelectDate(e) {
this.setData({
'carInfo.billingDate': e.detail.value
})
},
// 选择客户类型
toShowCustomerModal() {
this.setData({
showCustomer: true,
modalType: 3,
modalTitle: '客户类型'
})
},
// 选择客户类型结果
getCustomer(e) {
const { modalType, modalAttrName } = this.data
if (modalType == 3) {
this.setData({
'customerInfo.typeObj': e.detail.customer
})
} else {
this.setData({
[modalAttrName]: e.detail
})
}
},
// 车辆信息统一输入
intCarInfoFn(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
if (name === 'carInfo.invoicePrice') {
_value = this.priceVerify(_value, 2000000)
}
this.setData({
[name]: _value
})
},
// 价格输入校验规则
priceVerify(price, max, min = 0) {
let result = 0
// 1.限制小数点为2位
price = price.replace(/[^\d.]/g, "")
price = price.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
// 2.禁止第一位为小数点
if (price.indexOf('.') == 0) {
price = ''
}
// 3.如果第一位是0,那第二位开始禁止为数值,只可以为小数点
if (price.indexOf('0') == 0 && price.length > 1) {
if (price.indexOf('.') != 1) {
price = '0'
}
if (price[2] == '.') {
price = '0.'
}
}
// if (price.indexOf('.') != -1) {
// price = price.slice(0, price.indexOf('.'))
// }
result = price
// 4.判断最大值和最小值
if (price) {
price = Number(price)
max = Number(max)
if (max && price > max) {
result = max
}
if (min && price < min) {
result = min
}
}
return result
},
// 客户信息统一输入
intCustomerInfo(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
if (name === 'customerInfo.customerPhone' || name === 'customerInfo.cardNo') {
_value = _value.replace(/\s*/g, "")
}
this.setData({
[name]: _value
})
},
// 验证第一步信息
toVerifyFirstStepInfo() {
const { carInfo, obj, customerInfo } = this.data
const _phoneReg = /^[1]([3-9])[0-9]{9}$/
let _result = true
let _error = ''
let returnObj = { _error, _result }
if (!carInfo.plate) {
returnObj._error = '请输入车牌号码'
return returnObj
}
if (!obj.brandId) {
returnObj._error = '请选择品牌车型'
return returnObj
}
if (!carInfo.vin) {
returnObj._error = '请输入车架号'
return returnObj
}
if (carInfo.vin) {
let reg = /^[a-zA-Z0-9]{17}$/.test(carInfo.vin)
if (!reg) {
returnObj._error = '车架号请输入17位数字和字母'
return returnObj
}
}
if (!carInfo.engineNo) {
returnObj._error = '请输入发动机号'
return returnObj
}
if (carInfo.engineNo) {
let reg = /^[a-zA-Z0-9]{6,16}$/.test(carInfo.engineNo)
if (!reg) {
returnObj._error = '发动机号请输入6-16位数字和字母组合'
return returnObj
}
}
if (!carInfo.invoicePrice) {
returnObj._error = '请输入车辆价格'
return returnObj
}
if (!carInfo.billingDate) {
returnObj._error = '请选择购车日期'
return returnObj
}
if (!customerInfo.typeObj.type) {
returnObj._error = '请选择客户类型'
return returnObj
}
if (!customerInfo.customerName) {
returnObj._error = '请输入客户姓名'
return returnObj
}
if (!customerInfo.customerPhone) {
returnObj._error = '请输入联系电话'
return returnObj
}
if (customerInfo.customerPhone) {
let _flag = _phoneReg.test(customerInfo.customerPhone)
if (!_flag) {
returnObj._error = '请输入正确的手机号'
return returnObj
}
}
if (!customerInfo.cardNo) {
returnObj._error = `请输入${customerInfo.typeObj.cardName}`
return returnObj
}
if ([1, 2].includes(customerInfo.typeObj.type) && customerInfo.cardNo.length < 18) {
returnObj._error = `请输入正确的${customerInfo.typeObj.cardName}号码`
return returnObj
}
if (!customerInfo.customerAddress) {
returnObj._error = '请输入联系地址'
return returnObj
}
return { _result: false }
},
// 报案信息统一输入
intReporterInfo(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
if (name === 'reportCaseInfo.reporterPhone') {
_value = _value.replace(/\s*/g, "")
}
this.setData({
[name]: _value
})
},
// 报案信息时间统一选择
toSelectReportDate(e) {
const { name } = e.currentTarget.dataset
this.setData({
[name]: e.detail.value
})
},
// 打开选择地址
toSelectAddress() {
this.setData({
provinceShow: true
})
},
// 关闭选择地址
cancelProvince() {
this.setData({
provinceShow: false
})
},
// 获取选择的省市code
getProvinceCode(val) {
let address = val.detail.provinceNameData.toString()
address = address.replace(/,/g, "-")
this.setData({
'reportCaseInfo.code': val.detail.codeData,
"reportCaseInfo.area": address
})
},
// 验证第二步信息
toVerifySecondStepInfo() {
const { reportCaseInfo, projectInfo } = this.data
const _phoneReg = /^[1]([3-9])[0-9]{9}$/
let _result = true
let _error = ''
let returnObj = { _error, _result }
if (!reportCaseInfo.reporterName) {
returnObj._error = '请输入报案人'
return returnObj
}
if (!reportCaseInfo.reporterPhone) {
returnObj._error = '请输入报案人电话'
return returnObj
}
if (reportCaseInfo.reporterPhone) {
let _flag = _phoneReg.test(reportCaseInfo.reporterPhone)
if (!_flag) {
returnObj._error = '请输入正确的手机号'
return returnObj
}
}
if (!reportCaseInfo.reportDate) {
returnObj._error = '请输入报案时间'
return returnObj
}
if (!reportCaseInfo.reimbursementDate) {
returnObj._error = '请输入出险时间'
return returnObj
}
if (!reportCaseInfo.area) {
returnObj._error = '请选择出险地点'
return returnObj
}
if (!reportCaseInfo.address) {
returnObj._error = '请输入出险详细地址'
return returnObj
}
let _flag = false
let _priceFlag = false
projectInfo.forEach(el => {
if (el.check) {
_flag = true
if (!el.approveAmount) {
_priceFlag = true
}
}
})
if (!_flag) {
returnObj._error = '请选择核赔项目'
return returnObj
}
if (_priceFlag) {
returnObj._error = '核赔项目的价格不能为0'
return returnObj
}
// 出险日期不能大于报案时间
const _reportDate = new Date(reportCaseInfo.reportDate).getTime()
const _reimbursementDate = new Date(reportCaseInfo.reimbursementDate).getTime()
if (_reimbursementDate > _reportDate) {
returnObj._error = '出险时间不能大于报案时间'
return returnObj
}
return { _result: false }
},
// 选择核赔项目
toSelectProject(e) {
const { check, index } = e.currentTarget.dataset
let { projectInfo } = this.data
projectInfo[index].check = !check
this.setData({
projectInfo
})
},
// 核赔项目价格输入
toIntProjectPrice(e) {
const { index } = e.currentTarget.dataset
let { projectInfo } = this.data
let _value = e.detail.value
projectInfo[index].approveAmount = this.priceVerify(_value, 3000)
this.setData({
projectInfo
})
},
// 图片上传
toUploadImg(e) {
const { name } = e.currentTarget.dataset
let _this = this
wx.chooseImage({
count: 1
}).then(res => {
let [tempFiles] = res.tempFilePaths
let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success(_res) {
wx.$api.showLoading('上传中...')
commonApi
.uploadImg({
file: `${type}@${_res.data}`
})
.then(img => {
wx.$api.hideLoading()
let { imageInfo } = _this.data
if (name === 'imageInfo.vehicleDamage') {
imageInfo.vehicleDamage.push(img)
_this.setData({
imageInfo
})
} else {
_this.setData({
[name]: img
})
}
})
}
})
})
},
// 图片预览
previewImage(e) {
let params = e.currentTarget.dataset
wx.$api.previewImage(params)
},
// 图片删除
delCurrentImg(e) {
const { name, index } = e.currentTarget.dataset
let { imageInfo } = this.data
if (name === 'imageInfo.vehicleDamage') {
imageInfo.vehicleDamage.splice(index, 1)
this.setData({
imageInfo
})
} else {
this.setData({
[name]: ''
})
}
},
// 第三步-验证上传资料是否已上传/操作人
toVerifyImageInfo() {
const { imageInfo, caseDesc, opraterInfo } = this.data
const _phoneReg = /^[1]([3-9])[0-9]{9}$/
let _result = true
let _error = ''
let returnObj = { _error, _result }
if (!imageInfo.idCard[0]) {
returnObj._error = '请上传身份证人像面照片'
return returnObj
}
if (!imageInfo.idCard[1]) {
returnObj._error = '请上传身份证国徽面照片'
return returnObj
}
if (!imageInfo.drivingLicense) {
returnObj._error = '请上传行驶证照片'
return returnObj
}
if (!imageInfo.accident) {
returnObj._error = '请上传事故责任认定书或相关凭证'
return returnObj
}
if (!imageInfo.vin) {
returnObj._error = '请上传车架号VIN照片'
return returnObj
}
if (!imageInfo.carAndPeople) {
returnObj._error = '45°车头角度全车照片及人车合照'
return returnObj
}
if (!imageInfo.vehicleDamage.length) {
returnObj._error = '请上传车辆受损细节照片'
return returnObj
}
if (!imageInfo.InsuranceLossStatement) {
returnObj._error = '请上传保险定损单'
return returnObj
}
if (!caseDesc) {
returnObj._error = '请填写案件说明'
return returnObj
}
if (!opraterInfo.name) {
returnObj._error = '请填写操作人'
return returnObj
}
if (!opraterInfo.phone) {
returnObj._error = '请填写操作人电话'
return returnObj
}
let _flag = _phoneReg.test(opraterInfo.phone)
if (!_flag) {
returnObj._error = '请输入正确的手机号'
return returnObj
}
return { _result: false }
},
// 案件说明输入
intCaseDesc(e) {
this.setData({
caseDesc: e.detail.value
})
},
// 操作人输入
inOprater(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
if (name === 'opraterInfo.phone') {
_value = _value.replace(/\s*/g, "")
wx.setStorageSync('GH_OPRATER_CLAIMS_PHONE', _value);
} else {
wx.setStorageSync('GH_OPRATER_CLAIMS', _value);
}
this.setData({
[name]: _value
})
},
// 提交核赔
toSumbitClaims() {
let _verify = {}
_verify = this.toVerifyImageInfo()
if (_verify._result) return wx.$api.showToast(_verify._error)
this.handerParams(3)
},
// 报存草稿
toSaveCG() {
if (this.existDraftId) {
this.toCheckDraft()
} else {
this.handerParams(2)
}
},
// 提交核赔接口 参数处理
handerParams(operation) {
const { carInfo, obj, customerInfo, reportCaseInfo, opraterInfo, projectInfo, imageInfo, merchantDetail, caseDesc } = this.data
let _imgs = []
for (let k in imageInfo) {
if (k == 'idCard') {
imageInfo[k].forEach(el => {
let _tm = {
fileCode: 1,
fileUrl: el,
fileType: el.split('.').pop(),
fileName: '',
mark: k
}
_imgs.push(_tm)
})
} else if (k == 'vehicleDamage') {
imageInfo[k].forEach(el => {
let _tm = {
fileCode: 4,
fileUrl: el,
fileType: el.split('.').pop(),
fileName: '',
mark: k
}
_imgs.push(_tm)
})
} else {
let _tm = {
fileCode: 4,
fileUrl: imageInfo[k],
fileType: imageInfo[k].split('.').pop(),
fileName: '',
mark: k
}
_imgs.push(_tm)
}
}
let _project = [], _customProject = []
let _applyAmounts = {}
projectInfo.forEach(el => {
if (el.check) {
let _item = {
packageCode: this.packageCode || 'PC0036',
attributeDTOList: [{
attributeGroup: 'service_period',
attributeName: 'service_period',
attributeValue: 1,
sort: 0
}, {
attributeGroup: 'effective_date',
attributeName: 'effective_date',
attributeValue: new Date(+this.data.options.effectiveDate).format('yyyy-MM-dd hh:mm:ss'),
sort: 0,
}
]
}
if (!_project.length) {
_project.push(_item)
}
Object.assign(_applyAmounts, { [el.serviceItemCode]: el.approveAmount })
}
})
let _supplementList = []
if (this.detailSupplementList) {
this.detailSupplementList.forEach(el => {
let _temp = {
content: caseDesc || el.content,
suppType: 1,
claimsId: this.id,
id: el.id
}
_supplementList.push(_temp)
})
}
// 自定义套餐的项目参数值
if (this.isCustomPackage) {
const _customItem = this.handlerDynamicToSumbit()
_customProject.push(_customItem)
_project = _customProject
}
let params = {
operation, //1-提交至待核赔 2-草稿 3-提交至待定损 4-定损通过 5-定损不通过 6-上传发票
customerType: customerInfo.typeObj.type, // 客户类型
customerName: customerInfo.customerName, // 客户名称
cardNo: customerInfo.cardNo, // 证件号
customerPhone: customerInfo.customerPhone, // 客户手机号
customerAddress: customerInfo.customerAddress, // 客户联系地址
vehicle: {
vin: carInfo.vin,
engineNo: carInfo.engineNo,
licensePlate: carInfo.plate,
billingDate: carInfo.billingDate,
invoicePrice: carInfo.invoicePrice,
vehicleBrandId: obj.brandId,
vehicleBrandName: obj.brandName,
vehicleSubBrandId: obj.brandChildId,
vehicleSubBrandName: obj.brandChildName,
vehicleSeriesId: obj.seriseId,
vehicleSeriesName: obj.seriseName,
vehicleShapeId: obj.carTypeId,
vehicleShapeName: obj.carTypeName,
// vehicleColor: '白色',//车身颜色
// seatesNum: 5,
},
attributes: _project,
isOss: 0,
cardType: customerInfo.typeObj.type == 2 ? 2 : 1, //证件类型(1身份证、2统一社会信息代码),
merchantPhone: merchantDetail.merchantLegalPersonPhone, //店面联系号码
merchantAddress: merchantDetail.merchantAddress, //店面联系地址
reporterName: reportCaseInfo.reporterName,
reporterPhone: reportCaseInfo.reporterPhone,
reportDate: reportCaseInfo.reportDate ? reportCaseInfo.reportDate + ' 23:59:59' : '',
reimbursementDate: reportCaseInfo.reimbursementDate ? reportCaseInfo.reimbursementDate + ' 23:59:59' : '',
reimbursementProvinceCode: reportCaseInfo.code[0],
reimbursementCityCode: reportCaseInfo.code[1],
reimbursementCountiesCode: reportCaseInfo.code[2],
reimbursementAddr: reportCaseInfo.address,
handlerName: opraterInfo.name,
handlerPhone: opraterInfo.phone,
fileList: _imgs,
supplementList: _supplementList.length ? _supplementList : [{
content: caseDesc,
suppType: 1
}],
itemsList: projectInfo,
applyAmounts: JSON.stringify(_applyAmounts),
commitSource: 1,
contractNo: this.contractNo
}
if (this.existDraftId) {
params.id = this.existDraftId
}
if (this.id) {
params.id = this.id
}
console.log(params);
wx.$api.showLoading('提交中')
ActivityApi.saveOrSumbitClaimsAndEquity(params).then(res => {
wx.hideLoading();
wx.$api.showToast('提交成功')
wx.navigateBack({
delta: 1
});
})
},
// 查询客户是否有草稿记录
equityAndClaimsInfo(customerPhone, licenseNumber, isDetail,attributes,serviceItemsList) {
ActivityApi.equityAndClaimsInfo({ customerPhone, licenseNumber }).then(res => {
this.existDraftId = res.existDraftId
this.data.options.effectiveDate = res.effectiveDate
this.packageCode = res.packageCode
this.contractNo = res.contractNo
if (res.vin) {
this.setData({
'carInfo.vin': res.vin,
vinDisable: true
})
}
if (res.successCommit) {
this.handlerFirstepData(res)
}
if(isDetail){
this.getDymicProductList(this.packageCode, attributes,serviceItemsList)
}
})
},
// 获取省市区
getProvinceList(e) {
this.guorenAreaList = e.detail.list
},
// 处理省市区回显
handlerShowArea() {
this.inval = setInterval(() => {
if (this.guorenAreaList&&this.areaQuery) {
const { reimbursementProvinceCode, reimbursementCityCode, reimbursementCountiesCode } = this.areaQuery
if (reimbursementProvinceCode) {
const province = this.guorenAreaList.find(item => item.value === reimbursementProvinceCode)
const city = province.children.find(item => item.value === reimbursementCityCode)
const area = city.children.find(item => item.value === reimbursementCountiesCode)
const str = `${province.label}-${city.label}-${area.label}`
this.setData({
'reportCaseInfo.area': str,
'reportCaseInfo.code': [reimbursementProvinceCode, reimbursementCityCode, reimbursementCountiesCode]
})
}
clearInterval(this.inval)
} else {
setTimeout(() => {
clearInterval(this.inval)
}, 5000)
}
}, 20)
},
// 处理非第一次提单,自动填充数据
handlerFirstepData(info) {
const { vehicle, customerName, customerPhone, cardNo, customerAddress, customerType } = info.equityDetail
let { carInfo, obj, customerInfo, customerMapItem, currentStep } = this.data
obj = {
brandChildId: vehicle.vehicleSubBrandId,
brandChildName: vehicle.vehicleSubBrandName,
brandId: vehicle.vehicleBrandId,
brandName: vehicle.vehicleBrandName,
carTypeId: vehicle.vehicleShapeId,
carTypeName: vehicle.vehicleShapeName,
seriseId: vehicle.vehicleSeriesId,
seriseName: vehicle.vehicleSeriesName,
}
carInfo = {
plate: vehicle.licensePlate,
billingDate: vehicle.billingDate ? new Date(vehicle.billingDate).format('yyyy-MM-dd') : '',
vin: info.vin,
engineNo: vehicle.engineNo,
invoicePrice: vehicle.invoicePrice
}
customerInfo = {
typeObj: customerMapItem[customerType],
customerName,
cardNo,
customerPhone,
customerAddress
}
this.setData({
obj,
carInfo,
customerInfo,
currentStep: currentStep + 1,
disableFirstep: true
}, () => {
this.handleStepCss()
this.handlerShowArea()
})
},
/**2023-8月份需求 */
async getDymicProductList(packageCode, attributes,serviceItemsList) {
const { merchantId } = wx.$storage.get('userInfo')
const res = await ActivityApi.getDymicProduct({ merchantId, packageCode })
if (res&&res.length) {
this.isCustomPackage = true
let productList = [], dynamicObj = {}, servicePeriodList = [],projectInfo = []
res.forEach(el => {
if (el.groupAttributeList) {
el.groupAttributeList.forEach(ele => {
if(ele.groupName==='tireScale'){
if(ele.attributeList&&ele.attributeList.length){
ele.attributeList[0].attributeDesc = '规格型号(前轮)'
ele.attributeList.push({
...ele.attributeList[0],
attributeDesc:'规格型号(后轮)',
attributeName:'afterTireScale'
})
}
}
if (ele.attributeList) {
ele.attributeList.forEach(item => {
item.disable = false
Object.assign(dynamicObj, { [`${item.attributeName}`]: '' })
if (item.attributeName === 'effective_date') {
// const effectDate = new Date(this.data.options.effectiveDate).format('yyyy-MM-dd')
// item.disable = true
item.startTime = new Date().getTime() + 24 * 60 * 60 * 1000
item.startTime = new Date(item.startTime).format('yyyy-MM-dd')
// Object.assign(dynamicObj, { [`${item.attributeName}`]: effectDate })
} else if (item.attributeName === 'additional_date') {
item.endTime = new Date().format('yyyy-MM-dd')
}
productList.push(item)
})
}
})
}
if(el.serviceItemsList){
el.serviceItemsList.forEach(pro=>{
projectInfo.push({
serviceItemName:pro.serviceName,
check:false,
approveAmount:'',
serviceItemCode:pro.serviceCode,
packageCode:el.packageCode,
})
})
}
servicePeriodList = this.handleServicePeriod(el.servicePeriod)
})
this.setData({
productList,
dynamicObj,
servicePeriodList,
projectInfo
}, () => {
// 处理详情参数
if (attributes) {
this.handleDetailInfoForDynamic(dynamicObj, attributes,serviceItemsList)
}
})
}
},
// 获取项目服务年限的选择内容
handleServicePeriod(servicePeriod) {
if (servicePeriod) {
let arr = servicePeriod.split(','), result = []
arr.forEach(el => {
result.push({
type: el,
name: el + '年'
})
})
return result
}
return []
},
// 动态输入-选择
intDynamic(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
this.setData({
[name]: _value
})
},
toSelectDynamicDate(e) {
const { name } = e.currentTarget.dataset
let _value = e.detail.value
this.setData({
[name]: _value
})
},
toSelectDynamic(e) {
const { name } = e.currentTarget.dataset
let modalType = 4, modalTitle = '', modalAttrName = name
if (name === 'dynamicObj.service_period') {
modalType = 4
modalTitle = '服务期限'
} else if (name === 'dynamicObj.buy_car_type') {
modalType = 5
modalTitle = '购车类型'
}
this.setData({
modalType,
modalTitle,
showCustomer: true,
modalAttrName
})
},
// 校验动态属性填入值
verifyDynamicObj() {
const { dynamicObj, productList } = this.data
let noFillList = [], returnObj = { _error: '', _result: true }
for (let k in dynamicObj) {
if (!dynamicObj[k]) {
const target = productList.filter(t => t.attributeName === k)
noFillList.push(target[0].attributeDesc)
}
}
if (noFillList.length) {
returnObj._error = noFillList[0] + '不能为空'
return returnObj
}
return { _result: false }
},
// 动态属性值:提单+草稿
handlerDynamicToSumbit() {
const { dynamicObj } = this.data
let attributeDTOList = []
for (let k in dynamicObj) {
let target = {}
if (k === 'service_period' || k === 'buy_car_type') {
target = {
attributeGroup: k,
attributeName: k,
attributeValue: dynamicObj[k].type,
sort: 0
}
}else if(k==='afterTireScale'){
target = {
attributeGroup: 'tireScale',
attributeName: 'tireScale',
attributeValue: dynamicObj[k],
sort: 1
}
}else {
target = {
attributeGroup: k,
attributeName: k,
attributeValue: dynamicObj[k],
sort: 0
}
}
attributeDTOList.push(target)
}
return {
packageCode: this.packageCode,
attributeDTOList
}
},
// 处理详情进入对应的参数值
handleDetailInfoForDynamic(dynamicObj, attributes,serviceItemsList) {
let _tempArr = [],{projectInfo} = this.data
attributes.forEach(el => {
if (el.attributeDTOList) {
el.attributeDTOList.forEach(ele => {
_tempArr.push(ele)
})
}
})
for (let i = 0; i < _tempArr.length; i++) {
const element = _tempArr[i]
const value = element.attributeValue
const k = element.attributeName
if (k === 'service_period') {
dynamicObj[k] = { name: `${value}年`, type: value }
} else if (k === 'buy_car_type') {
dynamicObj[k] = { name: value == 0 ? '贷款车' : '全款车', type: value }
} else {
dynamicObj[k] = value
}
}
if (serviceItemsList) {
serviceItemsList.forEach(el => {
projectInfo.forEach(k => {
if (k.serviceItemCode === el.serviceItemCode) {
k.check = true
k.approveAmount = el.applyAmount
}
})
})
}
this.setData({
dynamicObj,
projectInfo
})
}
})