addinfo.js
22.8 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
// pages/main/addinfo/addinfo.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({
/**
* 页面的初始数据
*/
data: {
isshow01: false,
isshow02: false,
isshow03: false,
taxInfo: {},
proffessionlist: {},
banklist: {},
isself: false,
isIdCard: true,
name: '',
card_number: '',
birthday:'',
formData:{},
requestBody:{},
relativeData: {
isrequre: true,
label: '关系',
bindtype: 'relative',
selected:'',
placeholder: '请选择关系',
values: ["子女", "配偶"],
onChange: 'onPickerSelect'
},
personstatusData: {
isrequre: true,
label: '纳税人状态',
bindtype: 'personstatus',
selected: '',
placeholder: '请选择纳税人状态',
values: ["正常(在职)", "非正常"],
onChange: 'onPickerSelect'
},
cardtypeData: {
isrequre: true,
label: '证照类型',
bindtype: 'cardtype',
selected: '',
placeholder: '请选择证照类型',
values: ["居民身份证", "军官证", '士兵证', '武警警官证', '港澳居民来往大陆通行证', '外交官证', '中国护照',
'外国护照', '香港永久性居民身份证', '澳门特别行政区永久性居民身份证', '台湾身份证', '外国人永久居留证'
],
onChange: 'onPickerSelect'
},
forignerInfo: {
isrequre: true,
label: '是否境外人员',
bindtype: 'forigner',
selected: '否',
disabled:true,
values: ["否", "是"],
onChange: 'onPickerSelect'
},
bankInfo: {
label: '开户银行',
bindtype: 'bank',
selected: '',
placeholder: '请选择开户银行',
onChange: 'onPickerSelect'
},
genderData: {
label: '性别',
bindtype: 'gender',
selected: '',
placeholder: '请选择性别',
values: ["男", "女"],
onChange: 'onPickerSelect'
},
professionData: {
mode: 'multiSelector',
label: '职业',
bindtype: 'profession',
multiIndex: [0, 0, 0],
selected: '',
placeholder: '请选择职业',
onChange: 'onPickerSelect'
},
degreeData: {
label: '学历',
bindtype: 'degree',
selected: '',
placeholder: '请选择学历',
values: ["研究生", "大学本科", '大学本科以下'],
onChange: 'onPickerSelect'
},
disabilityInfo: {
label: '是否残疾',
bindtype: 'disable',
selected: '',
placeholder: '请选择是否残疾',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
lieshuInfo: {
label: '是否烈属',
bindtype: 'lieshu',
selected: '',
placeholder: '请选择是否烈属',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
lonelyolderInfo: {
label: '是否孤老',
bindtype: 'lonelyolder',
selected: '',
placeholder: '请选择是否孤老',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
investInfo: {
isrequre: true,
label: '是否股东、投资者',
bindtype: 'invest',
selected: '',
placeholder: '请选择是否股东、投资者',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
specificIndustryInfo: {
isrequre: true,
label: '是否特定行业',
bindtype: 'specificIndustry',
selected: '',
placeholder: '请选择是否特定行业',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
employeeInfo: {
label: '是否雇员',
bindtype: 'employee',
selected: '',
placeholder: '请选择是否雇员',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
investpersonalInfo: {
label: '是否天使投资个人',
bindtype: 'investpersonal',
selected: '',
placeholder: '请选择是否天使投资个人',
values: ["否", "是"],
onChange: 'onPickerSelect'
},
// 时间picker
birthDate: {
label: '出生年月',
bindtype: 'birthday',
selected: '',
placeholder: '请选择出生日期',
mode: "date",
fields: "day",
onChange: 'birthdayChange',
},
startDate: {
label: '在职受雇日期',
bindtype: 'startday',
selected: '',
placeholder: '请选择受雇日期',
mode: "date",
fields: "day",
onChange: 'startChange',
},
endDate: {
label: '离职日期',
bindtype: 'endday',
selected: '',
placeholder: '请选择离职日期',
mode: "date",
fields: "day",
onChange: 'endChange',
},
// 地址选择器
contactaddressInfo: {
label: '联系地址',
mode: 'region',
selected: '',
placeholder: '请选择联系地址',
onChange: 'contactAddressSelect'
},
currentaddressInfo: {
label: '居住地',
mode: 'region',
selected: '',
placeholder: '请选择居住地',
onChange: 'currentAddressSelect'
},
birthaddressInfo: {
label: '户籍所在地',
mode: 'region',
selected: '',
placeholder: '请选择户籍所在地',
onChange: 'birthAddressSelect'
},
title: '',
condition: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log('options.id', options.id)
// if (!options.id || options.id.length < 0) {
// this.setData({
// isself: false,
// })
// } else {
// this.getpersonalTax(options.id)
// }
this.getproffessiondata()
this.getbanklist()
},
getpersonalTax: function (id) {
var that = this
var Authorization = app.globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/personal-taxes/' + id,
method: "GET",
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
success: function (res) {
console.log(res)
that.setData({
taxInfo: res.data,
isself: res.data.family_ties ? false : true
})
},
fail(res) {
console.log(res)
}
})
},
getproffessiondata: function () {
var that = this
var Authorization = app.globalData.Authorization;
var proffession_info = that.data.professionData
wx.request({
url: baseUrl + 'common/v1/professions',
method: "GET",
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
success: function (res) {
console.log('proffessiondata', res.data)
proffession_info.values = that.handleProfession(res.data.items)
that.setData({
proffessionlist: res.data.items,
professionData: proffession_info
})
},
fail(res) {
console.log(res)
}
})
console.log('proffessionData--', that.data.professionData)
},
handleProfession: function (data) {
var newdata = []
var one = []
var two = []
var three = []
var oneObj = {}, twoObj = {}, threeObj = {}
if (data && data.length > 0) {
console.log('one', one)
data.map((d, i) => {
one.push(d.one_level_code) //三级联动中 第一级所有的code
two.push(d.two_level_code) //三级联动中 第二级所有的code
three.push(d.three_level_code) //三级联动中 第三级所有的code
oneObj[d.one_level_code] = {
"value": d.one_level_code,
"label": d.one_level_name,
"children": []
} //三级联动中 第一级所有的code + name
twoObj[d.two_level_code] = {
"value": d.two_level_code,
"label": d.two_level_name,
"children": []
} //三级联动中 第一级所有的code + name
threeObj[d.three_level_code] = {
"value": d.three_level_code,
"label": d.three_level_name
} //三级联动中 第一级所有的code + name
for (let b in twoObj) { //把第三级的数据的Code和第二级数据的code做判断 相等的 放到第二级的children数组中
for (let c in threeObj) {
if (b == c.slice(0, c.length - 1)) {
twoObj[b].children.push(threeObj[c])
}
}
}
for (let a in oneObj) { //把第二级的数据的Code和第二级数据的code做判断 相等的 放到第一级的children数组中
for (let b in twoObj) {
if (a == b.slice(0, b.length - 1)) {
oneObj[a].children.push(twoObj[b])
}
}
}
one = [...new Set(one)] //一级code去重
one.map((da, ind) => { //遍历 得到最终的三级联动数据
// console.log('oneObj', newdata)
newdata.push(oneObj[da])
})
})
}
console.log('newdata', newdata)
return newdata
},
getbanklist: function () {
var that = this
var Authorization = app.globalData.Authorization;
var bank_info = that.data.bankInfo
wx.request({
url: baseUrl + 'walletmgm/v1/bankinfos',
method: "GET",
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
success: function (res) {
console.log(res)
bank_info.values = that.handleBankinfo(res.data.items)
that.setData({
banklist: res.data.items,
bankInfo: bank_info
})
console.log("bankInfo", that.data.bankInfo)
},
fail(res) {
console.log(res)
}
})
},
handleBankinfo: function (data) {
var bank_name = []
for (var i = 0; i < data.length; i++) {
bank_name.push(data[i].bank_name)
}
return bank_name
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this
wx.getStorage({
key: 'id_info',
success: function (res) {
console.log(res.data)
var birth_day = res.data.birthday.year + '-' + res.data.birthday.month + '-' + res.data.birthday.day,
var cardtype_Data = that.data.cardtypeData
cardtype_Data.selected = res.data.id_card_number
that.setData({
name: res.data.name,
birthday: birth_day,
cardtypeData: cardtype_Data,
card_number: res.data.id_card_number
})
},
})
},
span: function (e) {
console.log(e)
if ("1" == e.target.id) {
this.setData({
isshow01: !this.data.isshow01
})
} else if ("2" == e.target.id) {
this.setData({
isshow02: !this.data.isshow02
})
} else if ("3" == e.target.id) {
this.setData({
isshow03: !this.data.isshow03
})
}
},
// =============普通单列picker选中处理==============
onPickerSelect: function (e) {
console.log('picker发送选择改变,携带值为', e)
switch (e.currentTarget.id) {
case 'relative':
var relative_data = this.data.relativeData
relative_data.selected = relative_data.values[e.detail.value]
this.setData({
relativeData: relative_data
})
break;
case 'personstatus':
var personstatus_data = this.data.personstatusData
personstatus_data.selected = personstatus_data.values[e.detail.value]
this.setData({
personstatusData: personstatus_data
})
break;
case 'cardtype':
var is_idcard = this.data.isIdCard
var cardtype_data = this.data.cardtypeData
cardtype_data.selected = cardtype_data.values[e.detail.value]
if (0 == e.detail.value) {
is_idcard = true
} else {
is_idcard = false
}
this.setData({
isIdCard: is_idcard,
cardtypeData: cardtype_data
})
break;
case 'forigner':
var forigner_data = this.data.forignerInfo
forigner_data.selected = forigner_data.values[e.detail.value]
this.setData({
forignerInfo: forigner_data
})
break;
case 'bank':
var bank_data = this.data.bankInfo
bank_data.selected = bank_data.values[e.detail.value]
this.setData({
bankInfo: bank_data
})
break;
case 'gender':
var gender_data = this.data.genderData
gender_data.selected = gender_data.values[e.detail.value]
this.setData({
genderData: gender_data
})
break;
case 'profession':
// var profession_data = this.data.professionData
// profession_data.selected = profession_data.values[e.detail.value]
// this.setData({
// professionData: profession_data
// })
break;
case 'degree':
var degree_data = this.data.degreeData
degree_data.selected = degree_data.values[e.detail.value]
this.setData({
degreeData: degree_data
})
break;
case 'disable':
var disable_data = this.data.disabilityInfo
disable_data.selected = disable_data.values[e.detail.value]
this.setData({
disabilityInfo: disable_data
})
break;
case 'lieshu':
var lieshu_data = this.data.lieshuInfo
lieshu_data.selected = lieshu_data.values[e.detail.value]
this.setData({
lieshuInfo: lieshu_data
})
break;
case 'lonelyolder':
var lonelyolder_data = this.data.lonelyolderInfo
lonelyolder_data.selected = lonelyolder_data.values[e.detail.value]
this.setData({
lonelyolderInfo: lonelyolder_data
})
break;
case 'invest':
var invest_data = this.data.investInfo
invest_data.selected = invest_data.values[e.detail.value]
this.setData({
investInfo: invest_data
})
break;
case 'specificIndustry':
var specificIndustry_data = this.data.specificIndustryInfo
specificIndustry_data.selected = specificIndustry_data.values[e.detail.value]
this.setData({
specificIndustryInfo: specificIndustry_data
})
break;
case 'employee':
var employee_data = this.data.employeeInfo
employee_data.selected = employee_data.values[e.detail.value]
this.setData({
employeeInfo: employee_data
})
break;
}
},
// =============日期picker选中处理==============
birthdayChange:function(e){
var birth_date = this.data.birthDate;
birth_date.selected = e.detail.value
this.setData({
birthday: e.detail.value,
birthDate: birth_date
})
},
startChange:function(e){
var start_date = this.data.startDate;
start_date.selected = e.detail.value
this.setData({
startDate: start_date
})
},
endChange: function (e) {
var end_date = this.data.endDate;
end_date.selected = e.detail.value
this.setData({
endDate: end_date
})
},
// =============地区picker选中处理==============
contactAddressSelect:function(e){
console.log('contactAddressSelect',e)
var contact_address = this.data.contactaddressInfo;
contact_address.address_value = e.detail.value
contact_address.address_code = e.detail.code
this.setData({
contactaddressInfo: contact_address
})
},
currentAddressSelect: function (e) {
console.log('currentAddressSelect', e)
var current_address = this.data.currentaddressInfo;
current_address.address_value = e.detail.value
current_address.address_code = e.detail.code
this.setData({
currentaddressInfo: current_address
})
},
birthAddressSelect: function (e) {
console.log('birthAddressSelect', e)
var birth_address = this.data.birthaddressInfo;
birth_address.address_value = e.detail.value
birth_address.address_code = e.detail.code
this.setData({
birthaddressInfo: birth_address
})
},
// =============其他数据选中处理==============
getIdInfo: function (e) {
if (this.data.isIdCard){
wx.navigateTo({
url: '../idinfo/idinfo',
success: function (res) { },
})
}
},
formSubmit: function (e) {
console.log("date", Date.parse(new Date(this.data.birthday))/1000)
var formdata = e.detail.value;
var toast_title = ''
console.log("formdata", formdata);
if (formdata.name.length < 1) {
this.showtoast('请输入姓名');
return
} else if (this.data.relativeData.selected.length < 1) {
this.showtoast('请选择成员关系');
return
} else if (this.data.personstatusData.selected.length < 1) {
this.showtoast('请选择纳税人状态');
return
} else if (this.data.cardtypeData.selected.length < 1) {
this.showtoast('请选择证照类型');
return
} else if (this.data.card_number.length<1||formdata.id_card_no.length < 1) {
this.showtoast('请输入证件号码');
return
// } else if (formdata.taxpayer_no.length < 1) {
// this.showtoast('请输入纳税人识别号');
// return
// } else if (formdata.disability_no.length < 1) {
// this.showtoast('请输入残疾证号');
// return
// } else if (formdata.martyr_family_no.length < 1) {
// this.showtoast('请输入烈属证号');
// return
} else if (formdata.mobile.length < 1) {
this.showtoast('请输入联系电话');
return
} else if (formdata.investInfo.selected.length < 1) {
this.showtoast('请输入是否股东投资者');
return
} else if (formdata.specificIndustryInfo.selected.length < 1) {
this.showtoast('请输入是否特定行业');
return
}
this.setData({
card_number: this.data.card_number.length > 0 ? this.data.card_number : formdata.id_card_no,
formData:formdata
})
// else if (formdata.contact_address_detail
// .length < 1) {
// this.showtoast('请输入联系详细地址');
// return
// } else if (formdata.bank_account.length < 1) {
// this.showtoast('请输入银行卡号');
// return
// } else if (formdata.email.length < 1) {
// this.showtoast('请输入邮箱');
// return
// } else if (formdata.current_address_detail.length < 1) {
// this.showtoast('请输入居住详细地址');
// return
// } else if (formdata.huji_address_detail.length < 1) {
// this.showtoast('请输入户籍详细地址');
// return
// }
this.goCommit();
},
goCommit: function () {
var that = this
var Authorization = app.globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/personal-taxes',
method: "GET",
data: {
"name": that.data.formdata.name,
"family_ties": that.data.relativeData.selected,
"native": "中国",
"id_card_type": that.data.relativeData.selected,
"id_card_no": that.data.card_number,
"gender": that.data.genderData.selected,
"birth_date": Date.parse(new Date(this.data.birthday)) / 1000,
"profession": {
"one_level_code": "1",
"one_level_name": "专业技术人员",
"two_level_code": "11",
"two_level_name": "科学研究人员",
"three_level_code": "111",
"three_level_name": "哲学研究人员"
},
"education": that.data.degreeData.selected,
"taxpayer_no": formdata.taxpayer_no,
"taxpayer_status": that.data.personstatusData.selected,
"is_martyr_family": that.data.lieshuInfo.selected,
"martyr_family_no": formdata.martyr_family_no,
"is_disability": that.data.disabilityInfo.selected,
"disability_no": formdata.disability_no,
"is_lonely_man": that.data.lonelyolderInfo.selected,
"is_overseas_personnel": "否",
"comment": formdata.comment,
"current_address": {
"province_code": that.data.currentaddressInfo.address_code[0],
"province": that.data.currentaddressInfo.address_value[0],
"city_code": that.data.currentaddressInfo.address_code[1],
"city": that.data.currentaddressInfo.address_value[1],
"district_code": that.data.currentaddressInfo.address_code[2],
"district": that.data.currentaddressInfo.address_value[2]
},
"current_address_detail": formdata.current_address_detail,
"huji_address": {
"province_code": that.data.birthaddressInfo.address_code[0],
"province": that.data.birthaddressInfo.address_value[0],
"city_code": that.data.birthaddressInfo.address_code[1],
"city": that.data.birthaddressInfo.address_value[1],
"district_code": that.data.birthaddressInfo.address_code[2],
"district": that.data.birthaddressInfo.address_value[2]
},
"huji_address_detail": formdata.huji_address_detail,
"mobile": formdata.mobile,
"contact_address": {
"province_code": that.data.contactaddressInfo.address_code[0],
"province": that.data.contactaddressInfo.address_value[0],
"city_code": that.data.contactaddressInfo.address_code[1],
"city": that.data.contactaddressInfo.address_value[1],
"district_code": that.data.contactaddressInfo.address_code[2],
"district": that.data.contactaddressInfo.address_value[2]
},
"contact_address_detail": formdata.contact_address_detail,
"email": formdata.email,
"bank": that.data.bankInfo.selected,
"bank_account": formdata.bank_account,
"join_date": Date.parse(new Date(that.data.startDate.selected)) / 1000,
"separate_date": Date.parse(new Date(that.data.endDate.selected)) / 1000,
"is_employee": that.data.employeeInfo.selected,
"is_specific_profession": that.data.specificIndustryInfo.selected,
"is_investor": that.data.investInfo.selected,
"is_business_angel": that.data.investpersonalInfo.selected,
"company_equity_total": formdata.company_equity_total,
"personal_equity_total": formdata.personal_equity_total,
"employee_no": formdata.employee_no
},
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
success: function (res) {
console.log(res)
},
fail(res) {
console.log(res)
}
})
},
showtoast: function (title) {
wx.showToast({
title: title,
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})