EntryInformation.js
7.9 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
// pages/EntryInformation/EntryInformation.js
const app = getApp();
Page({
data: {
sexArray: ['男', '女'],
card_Array: ['身份证', '护照', '出生证', '军官证', '港澳通行证'],
birth_date: '',
addsess_current: 0,
label_type: [],
list: {
name: '',
sex: '',
family_role: '',
income: '',
mobile: '',
birthday: '',
work: '',
work_address: '',
address: '',
mail_address: 0,
id_type: '',
id_num: '',
text: '',
label_ids: []
},
familyid: 0, //家庭ID
hasimg: '',
DefId: ''
},
//名字
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 = sexArray[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.income = 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;
this.setData({
list: list
})
},
//通讯切换
addressCharge(e) {
var that = this;
var list = this.data.list
list.mail_address = 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.id_type = parseInt(e.detail.value) + 1;
this.setData({
card_index: e.detail.value,
list: list
})
},
//选择家庭角色
setIdNum(e) {
let list = this.data.list;
list.id_num = e.detail.value;
this.setData({
list: list
})
},
//用户描述
descript(e) {
let list = this.data.list;
list.text = e.detail.value;
this.setData({
list: list
})
},
//选择用户标签
selectLabel(e) {
var list = this.data.list
var id = e.currentTarget.dataset.id
var label_ids = list.label_ids
label_ids.push(id)
console.log(label_ids)
var status = e.currentTarget.dataset.status
var label_type = this.data.label_type
var mindex = e.currentTarget.dataset.mindex
var sindex = e.currentTarget.dataset.sindex
label_type[mindex].data[sindex].status = !(label_type[mindex].data[sindex].status)
this.setData({
label_type: label_type,
list: list
});
},
// 选择上传的图片
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) {
var list = this.data.list;
console.log(e)
var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
let that = this;
var warn = ""; //弹框时提示的内容
var flag = true; //判断信息输入是否完整
var state = that.data.state
if (list.name == "") {
warn = "请填写您的姓名!";
} else if (list.family_role == '') {
warn = '请填写您的家庭角色'
} else if (list.status_num != '' && !idcardReg.test(list.status_num) && state == 0) {
warn = "请填写正确的身份号"
} else {
flag = false; //若必要信息都填写,则不用弹框.正常调用接口
let paramlist = {
name: list.name,
sex: list.sex,
family_role: list.family_role,
money: list.income,
mobile: list.mobile,
birthday: list.birthday,
work: list.work,
work_address: list.work_address,
address: list.address,
mid: list.mail_address,
user_status: list.id_type,
status_num: list.id_num,
picurl: list.picurl,
text: list.text,
label_ids: list.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: '操作成功',
icon: 'success',
duration: 2000
})
if (this.data.flag == 'add') {
wx.navigateBack({
delta: 2
})
} else {
wx.navigateBack({
delta: 1
})
}
}
}).catch((errMsg) => {
console.log(errMsg)
})
}
if (flag == true) {
wx.showToast({
title: warn,
icon: 'none',
duration: 2000
})
}
},
//获取成员详细信息
labelInfo() {
let that = this;
let url = 'counselor/DefAdd';
let params = {}
app.post(url, params).then((res) => {
console.log(res)
if (res.data.code == 200) {
var list = this.data.list
// label_type = res.data.data
that.setData({
label_type: res.data.data
})
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.labelInfo()
this.setData({
DefId: options.DefId,
familyid: options.familyid
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})