EntryInformation.js
11.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
// pages/EntryInformation/EntryInformation.js
const app = getApp();
Page({
data: {
sexArray: ['女', '男'],
card_Array: ['身份证', '护照', '出生证', '军官证', '港澳通行证'],
birth_date: '',
addsess_current: 0,
label_list: [],
list: {
name: '',
sex: '',
family_role: '',
money: '',
mobile: '',
birthday: '',
work: '',
work_address: '',
address: '',
mid: 0,
user_status: '',
status_num: '',
text: '',
},
label_ids: [],
familyid: 0, //家庭ID
hasimg: '',
DefId: ''
},
// 打电话
makePhoneCall() {
let that = this;
var list = that.data.list
var phoneNumber = list.mobile
wx.makePhoneCall({
phoneNumber: phoneNumber
})
},
//设置查询的关键词
setKeyWord(e) {
let that = this;
that.setData({
KeyWord: e.detail.value
})
},
//名字
setName(e) {
var list = this.data.list;
list.name = e.detail.value;
this.setData({
list: list
})
},
//选择性别
selectSex(e) {
var list = this.data.list;
var sexArray = this.data.sexArray
list.sex = e.detail.value;
this.setData({
sex_index: e.detail.value,
list: list
})
},
//选择家庭角色
familyRole(e) {
let list = this.data.list;
list.family_role = e.detail.value;
this.setData({
list: list
})
},
//选择年收入
income(e) {
let list = this.data.list;
list.money = e.detail.value;
this.setData({
list: list
})
},
//手机号
setMobile(e) {
let list = this.data.list;
list.mobile = e.detail.value;
this.setData({
list: list
})
},
//出生日期
birthDate(e) {
var list = this.data.list;
list.birthday = e.detail.value;
this.setData({
birth_date: e.detail.value,
list: list
})
},
//选择家庭角色
setWork(e) {
let list = this.data.list;
list.work = e.detail.value;
this.setData({
list: list
})
},
//选择家庭角色
setworkAddress(e) {
let list = this.data.list;
list.work_address = e.detail.value;
this.setData({
list: list
})
},
//设置家庭地址
setSddress(e) {
let list = this.data.list;
list.address = e.detail.value;
var address = list.address
if (this.data.familyid == 0) {
wx.setStorageSync('address', address)
}
this.setData({
list: list
})
},
//通讯切换
addressCharge(e) {
var that = this;
var list = this.data.list
list.mid = e.target.dataset.current
if (this.data.addsess_current === e.target.dataset.current) {
return false;
} else {
that.setData({
addsess_current: e.target.dataset.current,
list: list
})
}
},
//选择证件类型
selectIdCard(e) {
let list = this.data.list;
var card_Array = this.data.card_Array
list.user_status = parseInt(e.detail.value) + 1;
this.setData({
card_index: e.detail.value,
list: list
})
},
//选择家庭角色
setIdNum(e) {
let list = this.data.list;
list.status_num = e.detail.value;
this.setData({
list: list
})
},
//用户描述
descript(e) {
let list = this.data.list;
list.text = e.detail.value;
this.setData({
list: list
})
},
//添加成员标签
labelInfo() {
let that = this;
let url = 'counselor/DefAdd';
let params = {}
app.post(url, params).then((res) => {
if (res.data.code == 200) {
var list = this.data.list
that.setData({
label_list: res.data.data
})
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
//选择用户标签
selectLabel(e) {
var mindex = e.currentTarget.dataset.mindex
var sindex = e.currentTarget.dataset.sindex
var list = this.data.list
var id = e.currentTarget.dataset.id
var status = e.currentTarget.dataset.status
var label_list = this.data.label_list
var label_ids = this.data.label_ids;
//去重
const add = label_ids.every((label_ids) => {
return label_ids != id
})
// if (add) {
if (!(label_list[mindex].data[sindex].status)) {
label_ids.push(id)
} else {
for (var i = 0; i < label_ids.length; i++) {
// if (!(label_list[mindex].data[sindex].status)) {
if (label_list[mindex].data[sindex].id == label_ids[i]) {
label_ids.splice(i, 1);
console.log(11, label_ids)
}
// }
}
}
// }
label_list[mindex].data[sindex].status = !(label_list[mindex].data[sindex].status)
this.setData({
label_list: label_list,
label_ids: label_ids
});
},
// 选择上传的图片
chooseImg() { //这里是选取图片的方法
var that = this;
wx.chooseImage({
count: 1,
success: (res) => {
var tempFilePaths = res.tempFilePaths
let url = '/users/upload'
let strtime = +new Date()
let params = {
picurl: tempFilePaths[0],
strtime: strtime,
token: app.strTime(strtime)
}
wx.uploadFile({
url: 'https://insurance.w.broteam.cn/pubilc/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'picurl',
formData: {
'strtime': strtime,
'token': app.strTime(strtime)
},
success: function(res) {
var data = JSON.parse(res.data);
var picurl = data.data.picurl;
picurl = picurl.indexOf('http') != '-1' ? picurl : "http://" + picurl
var list = that.data.list
list.picurl = picurl
that.setData({
hasimg: picurl,
list: list
})
}
})
}
})
},
//成员信息的修改,新增
listVerify(e) {
let that = this;
var warn = "";
var flag = true;
var state = that.data.state
var list = this.data.list;
var sex_index = (this.data.sex_index)
var picurl = list.picurl
if (picurl == undefined) {
picurl = ''
}
// else if (list.mobile == '') {
// warn = '请填写您的手机号'
// } else if (!(/^[1][3,4,5,7,8][0-9]{9}$/.test(list.mobile))) {
// warn = "手机号格式不正确";
// }
if (list.name == "") {
warn = "请填写您的姓名";
} else if (sex_index == undefined) {
warn = "请填写您的性别";
} else if (list.family_role == '') {
warn = '请填写您的家庭角色'
} else if (list.birthday == '') {
warn = "请填选择您的出生日期"
} else {
flag = false; //若必要信息都填写,则不用弹框.正常调用接口
let paramlist = {
name: list.name,
sex: sex_index,
family_role: list.family_role,
money: list.money,
mobile: list.mobile,
birthday: list.birthday,
work: list.work,
work_address: list.work_address,
address: list.address,
mid: list.mid,
user_status: list.user_status,
status_num: list.status_num,
picurl: picurl,
text: list.text,
label_ids: this.data.label_ids,
family_id: that.data.familyid,
DefId: that.data.DefId,
UserId: app.globalData.UserId
}
let url = 'counselor/deflistdo'
app.post(url, paramlist).then((res) => {
console.log(res)
if (res.data.code == 200) {
wx.showToast({
title: '录入成功',
})
wx.setStorageSync('familyid', res.data.data.family_id)
setTimeout(() => {
if (this.data.familyid == 0) {
// wx.redirectTo({
// url: '/pages/index/CustomerManagement/CustomerManagement',
// })
wx.navigateTo({
url: '/pages/index/addNewFamily/addNewFamily',
})
} else {
wx.navigateBack()
}
}, 1500)
// wx.navigateTo({
// url: '/pages/index/addNewFamily/addNewFamily?familyid=' + res.data.data.family_id,
// })
}
}).catch((errMsg) => {
console.log(errMsg)
})
}
if (flag == true) {
wx.showToast({
title: warn,
icon: 'none',
duration: 2000
})
}
},
//获取成员详细信息
getUserInfo() {
let that = this;
let url = 'counselor/deflist';
let params = {
DefId: that.data.DefId
}
app.post(url, params).then((res) => {
if (res.data.code == 200) {
var list = res.data.data.list
if (res.data.data.list.picurl != '') {
this.setData({
hasimg: true
})
}
var label_ids = this.data.label_ids
var label_list = res.data.data.label_list
for (var i = 0; i < label_list.length; i++) {
for (var j = 0; j < label_list[i].data.length; j++) {
if (label_list[i].data[j].status == 1) {
label_ids.push(label_list[i].data[j].id)
label_list[i].data[j].status = true
} else {
label_list[i].data[j].status = false
}
}
}
var list = res.data.data.list;
list.sex = res.data.data.list.sex;
that.setData({
list: list,
label_list: label_list,
sex_index: res.data.data.list.sex,
card_index: parseInt(res.data.data.list.user_status) - 1,
addsess_current: res.data.data.list.mid,
label_ids: label_ids
})
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
//获取家庭地址
getAddress() {
let that = this;
let url = 'counselor/addUserAds';
app.post(url, {
family_id: this.data.familyid
}).then((res) => {
if (res.data.code == 200) {
var list = that.data.list
list.address = res.data.data.address
list.mobile=res.data.data.mobile
that.setData({
list: list
})
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.labelInfo()
this.setData({
familyid: options.familyid
})
if (options.DefId == undefined) {
this.setData({
DefId: ''
})
} else {
this.setData({
DefId: options.DefId
})
this.getUserInfo();
}
if (this.data.familyid != '') {
this.getAddress()
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})