apply.js
21.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
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
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
//
ifempower: true, //是否授权
showapply: false,
provincearr: [],
cityarr: [],
countryarr: [],
confirmvalarr: [0, 0, 0],
valarr: [0, 0, 0],
photo: '',
name: '',
enddata: '',
arraysex: ['男', '女'],
sex: '',
birthday: '', //生日
nation: '', //民族
nationarr: ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族",
"哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族",
"土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族",
"俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族"
],
politics: '', //政治面貌
politicsarr: ['共青团员', '中共预备党员', '中共党员', '群众', '无党派人士', '其他'], //
education: '', //学历
educationarr: ['小学', '中学', '专科', '本科', '硕士研究生', '博士研究生', '其他'], //
unit: '', //工作单位
duty: '', //职务
addr: '', //通讯地址,
postcode: '', //邮编
school: '', //
card_number: '', //身份证号码
move_phone: '', //
email: '', //
urgency_phone: '', //
qq: '',
province: '',
city: '',
county: '',
address: '', //详细地址,
type: '', //1医院志愿者,2社会志愿者,3办事处志愿者
typearr: ['医院志愿者', '社会志愿者', '办事处志愿者'],
apply_nav: 0, //0为履历1,1为履历2,2为履历3,
record: [{
record_start_time: '',
record_end_time: '',
record_unit: '',
record_duty: '',
record_name: '',
record_phone: ''
},
{
record_start_time: '',
record_end_time: '',
record_unit: '',
record_duty: '',
record_name: '',
record_phone: ''
},
{
record_start_time: '',
record_end_time: '',
record_unit: '',
record_duty: '',
record_name: '',
record_phone: ''
}
],
front_card: '', //身份证正面照
reverse_card: '', //身份证反面照
id: '', //用户id,
status:''//状态
},
onShow: function () {
var that = this;
// 登记表缓存
that.setData({
name: wx.getStorageSync('name'),
sex: wx.getStorageSync('sex'),
photo: wx.getStorageSync('photo'),
front_card: wx.getStorageSync('front_card'),
reverse_card: wx.getStorageSync('reverse_card'),
birthday: wx.getStorageSync('birthday'),
nation: wx.getStorageSync('nation'),
education: wx.getStorageSync('education'),
politics: wx.getStorageSync('politics'),
unit: wx.getStorageSync('unit'),
duty: wx.getStorageSync('duty'),
addr: wx.getStorageSync('addr'),
postcode: wx.getStorageSync('postcode'),
school: wx.getStorageSync('school'),
card_number: wx.getStorageSync('card_number'),
fixed_phone: wx.getStorageSync('fixed_phone'),
move_phone: wx.getStorageSync('move_phone'),
email: wx.getStorageSync('email'),
urgency_phone: wx.getStorageSync('urgency_phone'),
qq: wx.getStorageSync('qq'),
address: wx.getStorageSync('address'),
})
},
// 姓名
setname(e) {
this.setData({
name: e.detail.value
})
wx.setStorageSync('name', e.detail.value)
},
// 性别
bindsex(e) {
this.setData({
sex: parseInt(e.detail.value) + 1
})
wx.setStorageSync('sex', parseInt(e.detail.value) + 1)
},
// 出生日期
bindbirthdayChange(e) {
this.setData({
birthday: e.detail.value
})
wx.setStorageSync('birthday', e.detail.value)
},
// 民族
bindnationChange(e) {
let nationarr = this.data.nationarr;
this.setData({
nation: nationarr[e.detail.value]
})
wx.setStorageSync('nation', nationarr[e.detail.value])
},
// 学历
bindeducationChange(e) {
let educationarr = this.data.educationarr;
this.setData({
education: educationarr[e.detail.value]
})
wx.setStorageSync('education', educationarr[e.detail.value])
},
// 政治面貌
bindpoliticsChange(e) {
let politicsarr = this.data.politicsarr;
this.setData({
politics: politicsarr[e.detail.value]
})
wx.setStorageSync('politics', politicsarr[e.detail.value])
},
// 工作单位
setunit(e) {
this.setData({
unit: e.detail.value
})
wx.setStorageSync('unit', e.detail.value)
},
// 职务
setduty(e) {
this.setData({
duty: e.detail.value
})
wx.setStorageSync('duty', e.detail.value)
},
// 通讯地址
setaddr(e) {
this.setData({
addr: e.detail.value
})
wx.setStorageSync('addr', e.detail.value)
},
//邮编
setpostcode(e) {
this.setData({
postcode: e.detail.value
})
wx.setStorageSync('postcode', e.detail.value)
},
// 就读学校
setschool(e) {
this.setData({
school: e.detail.value
})
wx.setStorageSync('school', e.detail.value)
},
// 身份证号
setcard_number(e) {
this.setData({
card_number: e.detail.value
})
wx.setStorageSync('card_number', e.detail.value)
},
//固定电话
setfixed_phone(e) {
this.setData({
fixed_phone: e.detail.value
})
wx.setStorageSync('fixed_phone', e.detail.value)
},
//移动电话
setmove_phone(e) {
this.setData({
move_phone: e.detail.value
})
wx.setStorageSync('move_phone', e.detail.value)
},
// 电子邮箱
setemail(e) {
this.setData({
email: e.detail.value
})
wx.setStorageSync('email', e.detail.value)
},
// 紧急联系人
seturgency_phone(e) {
this.setData({
urgency_phone: e.detail.value
})
wx.setStorageSync('urgency_phone', e.detail.value)
},
// QQ号码
setqq(e) {
this.setData({
qq: e.detail.value
})
wx.setStorageSync('qq', e.detail.value)
},
//选择省市区
getarea() {
let that = this;
let url = 'index/area/index';
app.post(url, {}).then((res) => {
let country = res.country;
let tem = {
id: 0,
city_id: res.country[0].city_id,
country_id: 0,
country_name: ''
}
country.push(tem);
let temcountry = country.reverse();
let cityarr = res.city;
let countryarr = res.country;
let provincearr = res.province;
that.setData({
cityarr: cityarr,
countryarr: temcountry,
provincearr: provincearr
})
if (that.data.is_submit == undefined) {
that.setData({
ifempower: false
})
} else if (that.data.is_submit == '1') {
that.getdatalist();
}
}).catch((err) => {
})
},
//切换省份获取市和区/县
get_city(province_id = 0) {
let that = this;
let url = 'index/area/get_city';
let params = {
'province_id': province_id
}
app.post(url, params).then((res) => {
let country = res.country;
let tem = {
id: 0,
city_id: res.country[0].city_id,
country_id: 0,
country_name: ' '
}
country.push(tem);
let temcountry = country.reverse();
that.setData({
cityarr: res.city,
countryarr: temcountry
})
}).catch((err) => {
})
},
//切换市获取区/县
get_country(city_id = 0) {
let that = this;
let url = 'index/area/get_country';
let params = {
'city_id': city_id
}
app.post(url, params).then((res) => {
let country = res.country;
let tem = {
id: 0,
city_id: res.country[0].city_id,
country_id: 0,
country_name: ' '
}
country.push(tem);
let temcountry = country.reverse();
that.setData({
countryarr: temcountry
})
}).catch((err) => {
})
},
bindChange: function (e) {
let that = this;
let valarr = that.data.valarr;
let provincearr = that.data.provincearr;
let cityarr = that.data.cityarr;
const val = e.detail.value;
if (valarr[0] != val[0]) { //改变省
let i = val[0];
that.get_city(provincearr[i].province_id);
valarr[0] = val[0];
valarr[1] = 0;
valarr[2] = 0;
that.setData({
valarr: valarr
})
} else if (valarr[1] != val[1]) { //改变市
let j = val[1];
that.get_country(cityarr[j].city_id);
valarr[1] = val[1];
valarr[2] = 0;
that.setData({
valarr: valarr
})
} else { //改变区
valarr[2] = val[2];
that.setData({
valarr: valarr
})
}
},
//取消地区选择
setno() {
let that = this;
that.setData({
valarr: that.data.confirmvalarr,
showapply: false
})
},
//确定选择区域
setyes() {
let that = this;
let valarr = that.data.valarr;
let i = valarr[0];
let j = valarr[1];
let k = valarr[2];
let provincearr = that.data.provincearr;
let cityarr = that.data.cityarr;
let countryarr = that.data.countryarr;
that.setData({
confirmvalarr: valarr,
province: provincearr[i].province_name,
city: cityarr[j].city_name,
county: countryarr[k].country_name,
address: provincearr[i].province_name + cityarr[j].city_name + countryarr[k].country_name,
showapply: false
})
wx.setStorageSync('address', this.data.address)
},
setshowapply() {
let that = this;
that.setData({
showapply: true
})
},
setshowapply_no() {
let that = this;
that.setData({
showapply: false
})
},
void_fun() {},
bindRegionChange(e) {
let that = this;
this.setData({
region: e.detail.value,
province: e.detail.value[0],
city: e.detail.value[1],
county: e.detail.value[2],
address: e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
})
},
bindstartChange(e) {
let that = this;
let apply_nav = parseInt(that.data.apply_nav);
let record = that.data.record;
record[apply_nav].record_start_time = e.detail.value;
that.setData({
record: record
})
},
bindendChange(e) {
let that = this;
let apply_nav = that.data.apply_nav;
let record = that.data.record;
record[apply_nav].record_end_time = e.detail.value;
that.setData({
record: record
})
},
setrecordunit(e) {
let that = this;
let apply_nav = that.data.apply_nav;
let record = that.data.record;
record[apply_nav].record_unit = e.detail.value;
that.setData({
record: record
})
},
setrecordname(e) {
let that = this;
let apply_nav = that.data.apply_nav;
let record = that.data.record;
record[apply_nav].record_name = e.detail.value;
that.setData({
record: record
})
},
setrecordduty(e) {
let that = this;
let apply_nav = that.data.apply_nav;
let record = that.data.record;
record[apply_nav].record_duty = e.detail.value;
that.setData({
record: record
})
},
setrecordphone(e) {
let that = this;
let apply_nav = that.data.apply_nav;
let record = that.data.record;
record[apply_nav].record_phone = e.detail.value;
that.setData({
record: record
})
},
uploadImages(e) {
let that = this;
let tem = e.currentTarget.dataset.tem;
that.uploadImage(tem);
},
//上传头像1为头像,2为省份证正面,3为省份证反面
uploadImage(tem) {
let that = this;
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
success: function (res) {
let tempFilePaths = res.tempFilePaths //总文件
let head = {
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type': ''
}
// let url = 'https://volunteer.cnpu.org/api/user/upload/one';
let url = 'http://volunteer.w.bronet.cn/api/user/upload/one';
wx.uploadFile({
url: url, //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
header: head,
formData: {},
success: function (res) {
let temdata = JSON.parse(res.data);
if (temdata.code == 20000) {
if (tem == '1') {
that.setData({
photo: temdata.data.url
})
wx.setStorageSync('photo', temdata.data.url)
} else if (tem == '2') {
that.setData({
front_card: temdata.data.url
})
wx.setStorageSync('front_card', temdata.data.url)
} else if (tem == '3') {
that.setData({
reverse_card: temdata.data.url
})
wx.setStorageSync('reverse_card', temdata.data.url)
}
}
},
fail: function (res) {},
complete: () => {}
})
},
fail: function (res) {}
})
},
setapply_nav(e) {
let that = this;
that.setData({
apply_nav: e.currentTarget.dataset.apply_nav
})
},
submit(e) {
let that = this;
let err = '';
//匹配中国邮政编码
// var AuglyTest_PostalCode = /^[0-9]\\d{5}$/;
//匹配身份证
var AuglyTest_ID = /\d{15}|\d{18}/;
//验证手机号
var AuglyTest_phone = /^1(3|4|5|6|7|8)\d{9}$/;
//验证腾讯QQ号
var AuglyTest_QQ = /^[1-9]*[1-9][0-9]*$/;
//匹配国内电话号码
var AuglyTest_tel = /(\d{3}-|\d{4}-)?(\d{8}|\d{7})?/;
//email地址
var AuglyTest_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (that.data.photo == '') {
err = '请上传您的头像!'
} else if (that.data.name == '') {
err = '请输入您的姓名!'
} else if (that.data.sex == '') {
err = '请选择您的姓别!';
} else if (that.data.birthday == '') {
err = '请选择您的出生日期!';
} else if (that.data.nation == '') {
err = '请选择您的民族!';
} else if (that.data.education == '') {
err = '请选择您的学历!';
} else if (that.data.politics == '') {
err = '请选择您的政治面貌!';
} else if (that.data.unit == '') {
err = '请填写您的工作单位!';
} else if (that.data.duty == '') {
err = '请填写您的职务!';
} else if (that.data.addr == '') {
err = '请填写您的通讯地址!';
} else if (that.data.postcode == '') {
err = '请填写您的邮编!';
} else if (that.data.school == '') {
err = '请输入就读/毕业院校!';
} else if (that.data.card_number == '') {
err = '请输入您的身份证号!';
} else if (!AuglyTest_ID.test(that.data.card_number)) {
err = '请输入正确的身份证号!';
} else if (that.data.move_phone == '') {
err = '请输入您的移动电话!';
} else if (!AuglyTest_phone.test(that.data.move_phone)) {
err = '请输入正确的移动电话!';
} else if (that.data.email == '') {
err = '请输入您的电子邮箱!';
} else if (!AuglyTest_email.test(that.data.email)) {
err = '请输入正确的电子邮箱!';
} else if (that.data.urgency_phone == '') {
err = '请输入紧急联系人及电话!';
} else if (that.data.qq == '') {
err = '请输入您的QQ!';
} else if (!AuglyTest_QQ.test(that.data.qq)) {
err = '请输入正确的QQ号!';
} else if (that.data.address == '') {
err = '请选择您的服务区域';
} else if (that.data.front_card == '') {
err = '请上传身份证正面!';
} else if (that.data.reverse_card == '') {
err = '请上传身份证反面!';
}
if (err == '') {
let record = that.data.record;
let record_start_time = [];
let record_end_time = [];
let record_unit = [];
let record_duty = [];
let record_name = [];
let record_phone = [];
for (let obj of record) {
record_start_time.push(obj.record_start_time);
record_end_time.push(obj.record_end_time);
record_unit.push(obj.record_unit);
record_duty.push(obj.record_duty);
record_name.push(obj.record_name);
record_phone.push(obj.record_phone);
}
// let url = 'index/member_center/submit_form';
let head = {
'XX-Token': wx.getStorageSync('token')
}
let params = {
form_id: e.detail.formId,
name: that.data.name,
sex: that.data.sex,
birthday: that.data.birthday,
nation: that.data.nation,
politics: that.data.politics,
education: that.data.education,
unit: that.data.unit,
duty: that.data.duty,
addr: that.data.addr,
school: that.data.school,
card_number: that.data.card_number,
fixed_phone: that.data.fixed_phone,
move_phone: that.data.move_phone,
postcode: that.data.postcode,
email: that.data.email,
urgency_phone: that.data.urgency_phone,
qq: that.data.qq,
province: that.data.province,
city: that.data.city,
county: that.data.county,
address: that.data.address,
record_start_time: record_start_time,
record_end_time: record_end_time,
record_unit: record_unit,
record_duty: record_duty,
record_name: record_name,
record_phone: record_phone,
front_card: that.data.front_card,
reverse_card: that.data.reverse_card,
photo: that.data.photo
}
wx.showModal({
title: '请仔细核对信息,确认无误!',
content: '如需修改个人信息,请在微信公众号申请:关注微信公众号“白求恩志愿者中心”,点击菜单按钮“修改个人信息”,申请提交。',
confirmText:'确认提交',
cancelText:'我再想想',
success(res) {
if (res.confirm) {
let url = 'index/member_center/submit_form';
app.post(url, params, head).then((res) => {
wx.showToast({
title: '提交成功,等待审核',
mask: true,
icon: 'none',
duration: 2000
})
setTimeout(function () {
wx.switchTab({
url: '/pages/my/my'
})
}, 1000)
console.log('用户点击确定')
}).catch((err) => {})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
} else {
wx.showToast({
title: err,
icon: 'none',
mask: true,
duration: 2000
})
}
},
getdatalist() {
let that = this;
let url = '/index/member_center/edit';
let params = {
'id': that.data.id
};
let head = {
'XX-Token': wx.getStorageSync('token')
}
app.post(url, params, head).then((res) => {
console.log(res)
let provincearr = that.data.provincearr;
let cityarr = that.data.cityarr;
let countryarr = that.data.countryarr;
let val = [0, 0, 0];
for (let i = 0; i < provincearr.length; i++) {
if (provincearr[i].province_name == res.province) {
val[0] = i;
}
}
for (let i = 0; i < cityarr.length; i++) {
if (cityarr[i].city_name == res.city) {
val[1] = i;
}
}
for (let i = 0; i < countryarr.length; i++) {
if (countryarr[i].country_name == res.county) {
val[2] = i;
}
}
that.setData({
valarr: val,
confirmvalarr: val,
addr: res.addr,
address: res.address,
birthday: res.birthday,
card_number: res.card_number,
city: res.city,
county: res.county,
duty: res.duty,
education: res.education,
email: res.email,
front_card: res.front_card,
move_phone: res.move_phone,
name: res.name,
nation: res.nation,
photo: res.photo,
fixed_phone: res.fixed_phone,
politics: res.politics,
postcode: res.postcode,
province: res.province,
qq: res.qq,
record: res.record,
reverse_card: res.reverse_card,
school: res.school,
sex: res.sex,
unit: res.unit,
urgency_phone: res.urgency_phone,
type: res.type,
status:res.status
})
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
let that = this;
that.setData({
is_submit: options.is_submit ? options.is_submit : null,
id: options.id,
page_type: options.type ? options.type : null
})
let now = new Date();
let time = now.getFullYear() + "-" + ((now.getMonth() + 1) < 10 ? "0" : "") + (now.getMonth() + 1) + "-" + (now.getDate() < 10 ? "0" : "") + now.getDate();
this.setData({
enddata: time
})
that.getarea();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})