apply.js
12.1 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
// pages/apply/apply.js
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
photo: '',
name: '',
enddata:'',
arraysex: ['男', '女'],
region:['天津市','天津市','西青区'],
sex: '',
birthday: '', //生日
nation: '', //民族
nationarr: ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族",
"哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族",
"土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族",
"俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族"
],
politics: '', //政治面貌
politicsarr: ['共青团员', '中共预备党员', '中共党员', '群众', '无党派人士', '其他'], //
education: '', //学历
educationarr: ['小学', '中学', '专科', '本科', '硕士研究生', '博士研究生', '其他'], //
unit: '', //工作单位
duty: '', //职务
addr: '', //通讯地址,
postcode: '', //邮编
school: '', //
card_number: '', //身份证号码
fixed_phone: '', //固定电话
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: [{
start_time: '',
end_time: '',
unit: '',
duty: '',
name: '',
phone: ''
},
{
start_time: '',
end_time: '',
unit: '',
duty: '',
name: '',
phone: ''
},
{
start_time: '',
end_time: '',
unit: '',
duty: '',
name: '',
phone: ''
}
],
front_card: '', //身份证正面照
reverse_card: '' //身份证反面照
},
setname(e) {
this.setData({
name: e.detail.value
})
},
setunit(e) {
this.setData({
unit: e.detail.value
})
},
setduty(e) {
this.setData({
duty: e.detail.value
})
},
setaddr(e) {
this.setData({
addr: e.detail.value
})
},
setpostcode(e) {
this.setData({
postcode: e.detail.value
})
},
setschool(e) {
this.setData({
school: e.detail.value
})
},
setcard_number(e) {
this.setData({
card_number: e.detail.value
})
},
setemail(e) {
this.setData({
email: e.detail.value
})
},
seturgency_phone(e) {
this.setData({
urgency_phone: e.detail.value
})
},
setqq(e) {
this.setData({
qq: e.detail.value
})
},
bindsex(e) {
this.setData({
sex: parseInt(e.detail.value) + 1
})
},
setfixed_phone(e) {
this.setData({
fixed_phone: e.detail.value
})
},
setmove_phone(e) {
this.setData({
move_phone: e.detail.value
})
},
bindbirthdayChange(e) {
this.setData({
birthday: e.detail.value
})
},
bindnationChange(e) {
let nationarr = this.data.nationarr;
this.setData({
nation: nationarr[e.detail.value]
})
},
bindeducationChange(e) {
let educationarr = this.data.educationarr;
this.setData({
education: educationarr[e.detail.value]
})
},
bindpoliticsChange(e) {
let politicsarr = this.data.politicsarr;
this.setData({
politics: politicsarr[e.detail.value]
})
},
bindtypeChange(e) {
console.log(e)
let typearr = this.data.typearr;
this.setData({
type: parseInt(e.detail.value) +1
})
},
bindRegionChange(e){
let that=this;
console.log(e);
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]
})
},
chooseaddress() {
let that = this;
// wx.chooseAddress({
// success: function(res) {
// that.setData({
// province: res.provinceName,
// city: res.cityName,
// county: res.countyName,
// address: res.provinceName + res.cityName + res.countyName + res.detailInfo
// })
// }
// })
},
bindstartChange(e) {
let that = this;
let apply_nav = parseInt(that.data.apply_nav);
let record = that.data.record;
record[apply_nav].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].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].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].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].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].phone = e.detail.value;
that.setData({
record: record
})
},
//上传头像1为头像,2为省份证正面,3为省份证反面
uploadImages(e) {
let tem = e.currentTarget.dataset.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 = '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);
console.log('上传图temdata', temdata);
if (temdata.code == 20000) {
if (tem == '1') {
that.setData({
photo: temdata.data.url
})
} else if (tem == '2') {
that.setData({
front_card: temdata.data.url
})
} else if (tem == '3') {
that.setData({
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() {
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.fixed_phone==''){
err = '请输入您的固定电话!';
} else if (!AuglyTest_tel.test(that.data.fixed_phone)){
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.type==''){
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.start_time);
record_end_time.push(obj.end_time);
record_unit.push(obj.unit);
record_duty.push(obj.duty);
record_name.push(obj.name);
record_phone.push(obj.phone);
}
let url = 'index/member_center/submit_form';
let head = {
'XX-Token': wx.getStorageSync('token')
}
let params = {
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,
type: that.data.type,
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
}
app.post(url, params, head).then((res) => {
wx.showToast({
title: '提交成功,等待审核',
icon: 'none',
duration: 2000
})
setTimeout(function(){
wx.switchTab({
url: '/pages/my/my'
})
},1000)
}).catch((err) => {
console.log(err)
})
}else{
wx.showToast({
title: err,
icon: 'none',
duration: 2000
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
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
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})