作者 刘晓艳
@@ -2,1295 +2,1302 @@ @@ -2,1295 +2,1302 @@
2 const app = getApp() 2 const app = getApp()
3 Page({ 3 Page({
4 4
5 - /**  
6 - * 页面的初始数据  
7 - */  
8 - data: {  
9 - recognizee: ['被保人', '被保人2'],  
10 - recognizee_index: 0,  
11 - period_time: ['10年', '20年'],  
12 - period_index: -1,  
13 - compact_time: '',  
14 - impletion_time: '',  
15 - popup_state: false,  
16 - projectlist: [],  
17 - label_state: false,  
18 - insure: ['投保人', '投保人2'],  
19 - insureindex: -1,  
20 - beneficiary_list: [{  
21 - name_array: ['受益人1', '受益人2'],  
22 - unit: ''  
23 - }],  
24 - beneficiaryindex: -1,  
25 - tempfavoree: [], // 已选择的受益人  
26 - beneficiaryList: [],  
27 - name: '', //受益人的名字,  
28 - beneficiary_name: '',  
29 - imgs: [],  
30 - main_risk: [],  
31 - unit: '',  
32 - unit2: '',  
33 - unit3: '',  
34 - unit4: '',  
35 - applicant_name: '',  
36 - recognizee_name: '',  
37 - rang_beneficiary: [],  
38 - risk_list: [{  
39 - name: '',  
40 - mo: [],  
41 - project_time: '',  
42 - title: '',  
43 - num: ''  
44 - }],  
45 - main_array: [],  
46 - warranty_one: '',  
47 - warranty_two: {},  
48 - guarantee_name: '',  
49 - long_money: {},  
50 - time_name: '',  
51 - type_money: '',  
52 - more: [],  
53 - guarantee: [],  
54 - InfoId: 0,  
55 - def_id: '',  
56 - edit_state: false,  
57 - risk_listitm: '',  
58 - storge_state: false,  
59 - },  
60 -  
61 - //保单号  
62 - policyNum(e) {  
63 - this.setData({  
64 - in_num: e.detail.value,  
65 - })  
66 - },  
67 -  
68 - //保单号  
69 - setFirm(e) {  
70 - this.setData({  
71 - firm: e.detail.value,  
72 - })  
73 - },  
74 -  
75 - //投保人  
76 - insureSelect(e) {  
77 - var insure = this.data.insure  
78 - this.setData({  
79 - insureindex: e.detail.value,  
80 - applicant_name: insure[e.detail.value],  
81 - })  
82 - },  
83 -  
84 - //选择被保险人  
85 - recognizeeSelect(e) {  
86 - var recognizee = this.data.recognizee  
87 - this.setData({  
88 - recognizeeindex: e.detail.value,  
89 - recognizee_name: recognizee[e.detail.value]  
90 - })  
91 - },  
92 -  
93 - //主险名称  
94 - setRiskName(e) {  
95 - // console.log(e)  
96 - this.setData({  
97 - main_risks: e.detail.value,  
98 - })  
99 - // console.log(this.data.main_risks)  
100 - },  
101 -  
102 - //保费  
103 - yearMoney(e) {  
104 - this.setData({  
105 - year_money: e.detail.value,  
106 - })  
107 - },  
108 -  
109 - //设置银行  
110 - setBank(e) {  
111 - this.setData({  
112 - bank: e.detail.value,  
113 - })  
114 - },  
115 -  
116 - //设置账号  
117 - setBankNum(e) {  
118 - this.setData({  
119 - bank_num: e.detail.value,  
120 - })  
121 - },  
122 -  
123 - //合同生效日  
124 - compactTime(e) {  
125 - this.setData({  
126 - compact_time: e.detail.value,  
127 - })  
128 - this.countImpletionTime()  
129 - this.countImpletionTime2()  
130 - },  
131 -  
132 - //缴费期满日  
133 - impletionTime(e) {  
134 - this.setData({  
135 - impletion_time: e.detail.value,  
136 - })  
137 - },  
138 -  
139 - //主险保障期  
140 - periodTime(e) {  
141 - this.setData({  
142 - period_index: e.detail.value,  
143 - })  
144 - },  
145 -  
146 - //保障项目弹窗  
147 - ensureProject(e) {  
148 - this.setData({  
149 - edit_state: false  
150 - })  
151 -  
152 - let that = this;  
153 - let type = e.currentTarget.dataset.type;  
154 - let index = e.currentTarget.dataset.xulie;  
155 - let tempProjectlist = Object.assign(this.data.projectlist, {});  
156 - // 已经添加的附加险  
157 - let risk_list = Object.assign(this.data.risk_list, {});  
158 - console.log(risk_list)  
159 - let tempRist = risk_list[index].mo;  
160 - console.log(tempRist)  
161 - // 已经添加的主险  
162 - let tempMain_list = Object.assign(this.data.main_array, {})  
163 - if (type == 'zhuxian') {  
164 - if (tempMain_list.length > 0) {  
165 - for (let i in tempProjectlist) {  
166 - for (let j in tempMain_list) {  
167 - if (tempProjectlist[i].id == tempMain_list[j].id) {  
168 - tempProjectlist[i] = tempMain_list[j]  
169 - }  
170 - }  
171 - }  
172 - }  
173 - } else {  
174 - if (tempRist.length) {  
175 - for (let i in tempProjectlist) {  
176 - for (let j in tempRist) {  
177 - if (tempProjectlist[i].id == tempRist[j].id) {  
178 - tempProjectlist[i] = tempRist[j]  
179 - }  
180 - }  
181 - }  
182 - }  
183 - }  
184 -  
185 - wx.setNavigationBarTitle({  
186 - title: '选择保障项目',  
187 - })  
188 -  
189 - this.setData({  
190 - popup_state: true,  
191 - addType: type,  
192 - xulie: index,  
193 - projectlist: tempProjectlist  
194 - })  
195 - // }  
196 - },  
197 -  
198 - // 调取保障项目接口  
199 - ensureProjectList() {  
200 - var main_risk = this.data.main_risk  
201 - let url = 'counselor/sageguard'  
202 - let params = {}  
203 - app.post(url, params).then((res) => {  
204 - if (res.data.code == 200) {  
205 - var projectlist = res.data.data.def;  
206 - for (var i = 0; i < projectlist.length; i++) {  
207 - projectlist[i].choose_status = false  
208 - for (var j = 0; j < projectlist[i].title.length; j++) {  
209 - projectlist[i].title[j].label_state = false  
210 - }  
211 - projectlist[i].title[0].current = 0  
212 - projectlist[i].title[0].label_state = true  
213 - } 5 + /**
  6 + * 页面的初始数据
  7 + */
  8 + data: {
  9 + recognizee: ['被保人', '被保人2'],
  10 + recognizee_index: 0,
  11 + period_time: ['10年', '20年'],
  12 + period_index: -1,
  13 + compact_time: '',
  14 + impletion_time: '',
  15 + popup_state: false,
  16 + projectlist: [],
  17 + label_state: false,
  18 + insure: ['投保人', '投保人2'],
  19 + insureindex: -1,
  20 + beneficiary_list: [{
  21 + name_array: ['受益人1', '受益人2'],
  22 + unit: ''
  23 + }],
  24 + beneficiaryindex: -1,
  25 + tempfavoree: [], // 已选择的受益人
  26 + beneficiaryList: [],
  27 + name: '', //受益人的名字,
  28 + beneficiary_name: '',
  29 + imgs: [],
  30 + main_risk: [],
  31 + unit: '',
  32 + unit2: '',
  33 + unit3: '',
  34 + unit4: '',
  35 + applicant_name: '',
  36 + recognizee_name: '',
  37 + rang_beneficiary: [],
  38 + risk_list: [{
  39 + name: '',
  40 + mo: [],
  41 + project_time: '',
  42 + title: '',
  43 + num: ''
  44 + }],
  45 + main_array: [],
  46 + warranty_one: '',
  47 + warranty_two: {},
  48 + guarantee_name: '',
  49 + long_money: {},
  50 + time_name: '',
  51 + type_money: '',
  52 + more: [],
  53 + guarantee: [],
  54 + InfoId: 0,
  55 + def_id: '',
  56 + edit_state: false,
  57 + risk_listitm: '',
  58 + storge_state: false,
  59 + },
  60 +
  61 + //保单号
  62 + policyNum(e) {
214 this.setData({ 63 this.setData({
215 - projectlist: res.data.data.def 64 + in_num: e.detail.value,
216 }) 65 })
217 - // console.log(this.data.projectlist)  
218 - }  
219 - })  
220 - },  
221 -  
222 - //保障项目单位  
223 - getUnit(e) {  
224 - var main_risk = this.data.main_risk  
225 - var index = e.currentTarget.dataset.index;  
226 - var sindex = e.currentTarget.dataset.sindex;  
227 - var projectlist = this.data.projectlist;  
228 - var title = projectlist[index].title  
229 - for (var i = 0; i < title.length; i++) {  
230 - title[i].current = ''  
231 - if (title[i].current == '') {  
232 - title[i].label_state = false  
233 - }  
234 - }  
235 - projectlist[index].title[sindex].current = sindex  
236 - if (projectlist[index].title[sindex].current == sindex) {  
237 - projectlist[index].title[sindex].label_state = true  
238 - }  
239 - this.setData({  
240 - projectlist: projectlist,  
241 - })  
242 - },  
243 -  
244 - //保障项目金额  
245 - popupNum(e) {  
246 - var index = e.currentTarget.dataset.index;  
247 - var projectlist = this.data.projectlist;  
248 - if (projectlist[index].choose_status) {  
249 - projectlist[index].num = e.detail.value  
250 - }  
251 - console.log(main_risk)  
252 - this.setData({  
253 - projectlist: projectlist  
254 - })  
255 - },  
256 -  
257 - //选择保障项目  
258 - popupState(e) {  
259 - var index = e.currentTarget.dataset.index;  
260 - var projectlist = this.data.projectlist;  
261 - projectlist[index].choose_status = !projectlist[index].choose_status;  
262 - // console.log(projectlist)  
263 - this.setData({  
264 - projectlist: projectlist,  
265 - })  
266 - if (this.data.inforid != 0) {  
267 - edit_state: false  
268 - }  
269 - },  
270 -  
271 - //确认选择的推荐方案  
272 - confirmCase() {  
273 - let index = this.data.xulie;  
274 - let type = this.data.addType;  
275 - var that = this  
276 - var main_array = []  
277 -  
278 - var projectlist = Object.assign(this.data.projectlist, {})  
279 - for (var i = 0; i < projectlist.length; i++) {  
280 - if (projectlist[i].choose_status) {  
281 - main_array.push(projectlist[i])  
282 - console.log(main_array)  
283 - }  
284 - }  
285 -  
286 - if (main_array != '') {  
287 - wx.showToast({  
288 - title: '添加成功',  
289 - icon: 'none'  
290 - })  
291 -  
292 - if (type == 'fujiaxian') {  
293 - let tempRist = that.data.risk_list;  
294 - console.log(tempRist)  
295 - tempRist[index]['mo'] = main_array;  
296 - that.setData({  
297 - risk_list: tempRist,  
298 - risk_listitm: tempRist 66 + },
  67 +
  68 + //保单号
  69 + setFirm(e) {
  70 + this.setData({
  71 + firm: e.detail.value,
299 }) 72 })
300 - console.log(this.data.risk_list)  
301 - } else {  
302 - that.setData({  
303 - main_array: main_array, 73 + },
  74 +
  75 + //投保人
  76 + insureSelect(e) {
  77 + var insure = this.data.insure
  78 + this.setData({
  79 + insureindex: e.detail.value,
  80 + applicant_name: insure[e.detail.value],
304 }) 81 })
305 - }  
306 - console.log(this.data.main_array)  
307 - }  
308 - setTimeout(function() {  
309 - that.ensureProjectList()  
310 - that.setData({  
311 - popup_state: false  
312 - })  
313 - wx.setNavigationBarTitle({  
314 - title: '添加保单',  
315 - })  
316 - }, 800)  
317 -  
318 -  
319 - console.log(this.data.risk_list)  
320 - },  
321 -  
322 - //重组主险的保障项目  
323 - tempMain() {  
324 - var main_array = this.data.main_array  
325 - var warranty_one1 = []  
326 - // console.log(main_array)  
327 - for (var i = 0; i < main_array.length; i++) {  
328 - var temp = {}  
329 - for (var j = 0; j < main_array[i].title.length; j++) {  
330 - if (main_array[i].choose_status) {  
331 - if (main_array[i].title[j].label_state) {  
332 - temp.id = main_array[i].id  
333 - temp.name = main_array[i].name  
334 - temp.num = main_array[i].num  
335 - temp.title = main_array[i].title[j].name  
336 - temp.t_id = main_array[i].title[j].t_id  
337 - }  
338 - }  
339 - }  
340 - warranty_one1.push(temp)  
341 - this.setData({  
342 - guarantee: warranty_one1  
343 - })  
344 - }  
345 -  
346 - },  
347 -  
348 - //主险名称  
349 - addRiskName(e) {  
350 - var risk_list = this.data.risk_list  
351 - var index = e.currentTarget.dataset.index  
352 - risk_list[index].name = e.detail.value  
353 - this.setData({  
354 - risk_list: risk_list  
355 - })  
356 - },  
357 -  
358 - //主险保障其  
359 - addRiskUnit(e) {  
360 - var risk_list = this.data.risk_list  
361 - var index = e.currentTarget.dataset.index  
362 - risk_list[index].num = e.detail.value  
363 - this.setData({  
364 - risk_list: risk_list  
365 - })  
366 - },  
367 -  
368 - //重组附加险整体数据结构  
369 - tempAddRisk() {  
370 - var risk_list = this.data.risk_list  
371 -  
372 - var sub_array = []  
373 - var temp_risk = this.data.risk_listitm;  
374 - var temp = this.data.risk_listitm;  
375 -  
376 - for (var i = 0; i < temp.length; i++) {  
377 - for (var j = 0; j < temp[i].mo.length; j++) {  
378 - for (var k = 0; k < temp[i].mo[j].title.length; k++) {  
379 - if (temp[i].name != '') {  
380 - // var temp = {}  
381 - // var subtemp = {}  
382 - if (temp[i].mo[j].choose_status) {  
383 - if (temp[i].mo[j].title[k].label_state) {  
384 - temp_risk[i].name = temp[i].name  
385 - temp_risk[i].num = temp[i].num  
386 - temp_risk[i].title = temp[i].title  
387 - temp_risk[i].mo[j].t_id = temp[i].mo[j].title[k].t_id  
388 - temp_risk[i].mo[j].id = temp[i].mo[j].id  
389 - temp_risk[i].mo[j].name = temp[i].mo[j].name  
390 - temp_risk[i].mo[j].num = temp[i].mo[j].num  
391 - temp_risk[i].mo[j].title = temp[i].mo[j].title[k].name  
392 - console.log(temp_risk)  
393 - }  
394 - }  
395 - }  
396 - }  
397 - }  
398 -  
399 - this.setData({  
400 - more: temp_risk  
401 - })  
402 - }  
403 -  
404 - },  
405 -  
406 - //选择受益人姓名  
407 - beneficiarySelect(e) {  
408 - if (this.data.inforid != 0) {  
409 - this.setData({  
410 - edit_state: false  
411 - })  
412 - }  
413 - var index = e.currentTarget.dataset.mindex  
414 - var beneficiary_list = Object.assign(this.data.beneficiary_list, {});  
415 - // 获取当前已选择的收益人  
416 - let tempBenefice = Object.assign(this.data.beneficiaryList, {})  
417 - // 当前选择的收益人  
418 - let nowPerson = beneficiary_list[index].name_array[e.detail.value];  
419 - // 判断受益人是否已经添加  
420 - const add = tempBenefice.every((tempBenefice) => {  
421 - return tempBenefice != nowPerson  
422 - })  
423 - if (add) {  
424 - beneficiary_list[index].beneficiary_name = nowPerson;  
425 - tempBenefice.push(nowPerson)  
426 - } else {  
427 - wx.showToast({  
428 - title: '请不要重复添加受益人',  
429 - icon: 'none'  
430 - })  
431 - }  
432 -  
433 - this.setData({  
434 - beneficiary_list: beneficiary_list,  
435 - beneficiaryList: tempBenefice  
436 - })  
437 -  
438 - },  
439 -  
440 - //添加收益比例  
441 - addUnit(e) {  
442 - var beneficiary_list = this.data.beneficiary_list;  
443 - beneficiary_list[beneficiary_list.length - 1].unit = e.detail.value;  
444 - this.setData({  
445 - beneficiary_list: beneficiary_list,  
446 - })  
447 - },  
448 -  
449 - //添加受益人  
450 - addPersons(e) {  
451 - var list = this.data.beneficiary_list;  
452 - var len = list.length  
453 - if (list[len - 1].beneficiary_name == undefined) {  
454 - wx.showToast({  
455 - title: '请选择受益人',  
456 - icon: 'none'  
457 - })  
458 - } else if (list[len - 1].unit == '') {  
459 - console.log('unit')  
460 - wx.showToast({  
461 - title: '请输入收益比',  
462 - icon: 'none'  
463 - })  
464 - } else {  
465 - list[len] = {  
466 - name_array: this.data.insure,  
467 - unit: ''  
468 - }  
469 - }  
470 - this.setData({  
471 - beneficiary_list: list  
472 - })  
473 - console.log(this.data.beneficiary_list)  
474 - },  
475 -  
476 - //重组添加受益人  
477 - tempBeneficiary() {  
478 - var beneficiary_list = this.data.beneficiary_list  
479 - var len = beneficiary_list.length;  
480 - var tempfavoree1 = [];  
481 - for (var i = 0; i < beneficiary_list.length; i++) {  
482 - var temp = {}  
483 - if (beneficiary_list[i].unit != '') {  
484 - temp.name = beneficiary_list[i].beneficiary_name  
485 - temp.unit = beneficiary_list[i].unit;  
486 - }  
487 - tempfavoree1.push(temp)  
488 - this.setData({  
489 - tempfavoree: tempfavoree1  
490 - })  
491 -  
492 - }  
493 - },  
494 -  
495 - //删除收益人  
496 - deletebenefict(e) {  
497 - let index = e.currentTarget.dataset.index;  
498 - let tempbenefict = Object.assign(this.data.beneficiary_list, {});  
499 - let beneficiaryList = Object.assign(this.data.beneficiaryList, {});  
500 - // 获取当前选项的受益人  
501 - let person = tempbenefict[index].beneficiary_name;  
502 - tempbenefict.splice(index, 1);  
503 - if (person) beneficiaryList.splice(beneficiaryList.indexOf(person), 1)  
504 -  
505 - this.setData({  
506 - beneficiaryList: beneficiaryList,  
507 - beneficiary_list: tempbenefict  
508 - })  
509 - },  
510 -  
511 - //添加附加险  
512 - addRisk() {  
513 - if (this.data.inforid != 0) {  
514 - this.setData({  
515 - edit_state: false  
516 - })  
517 - }  
518 - var risk_list = Object.assign(this.data.risk_list, {});  
519 - var len = risk_list.length  
520 - risk_list[len] = {  
521 - name: '',  
522 - mo: [],  
523 - project_time: '',  
524 - title: '',  
525 - num: ''  
526 - }  
527 - this.setData({  
528 - risk_list: risk_list  
529 - })  
530 - },  
531 -  
532 - //删除附加险  
533 - deleteRisk(e) {  
534 - let index = e.currentTarget.dataset.index;  
535 - let risk_list = Object.assign(this.data.risk_list, {});  
536 - risk_list.splice(index, 1);  
537 - this.setData({  
538 - risk_list: risk_list  
539 - })  
540 - },  
541 -  
542 - //上传图片  
543 - uploadImage() {  
544 - let that = this;  
545 - wx.chooseImage({  
546 - count: 6,  
547 - sizeType: ['original', 'compressed'],  
548 - success: function(res) {  
549 - let successUp = 0; //成功个数  
550 - let failUp = 0; //失败个数  
551 - let i = 0; //第几个  
552 - let tempFilePaths = res.tempFilePaths //总文件  
553 - let length = res.tempFilePaths.length //总共个数  
554 - wx.showNavigationBarLoading()  
555 - wx.showLoading({  
556 - title: '上传中', 82 + },
  83 +
  84 + //选择被保险人
  85 + recognizeeSelect(e) {
  86 + var recognizee = this.data.recognizee
  87 + this.setData({
  88 + recognizeeindex: e.detail.value,
  89 + recognizee_name: recognizee[e.detail.value]
557 }) 90 })
558 - that.uploadAllfile(tempFilePaths, successUp, failUp, i, length)  
559 }, 91 },
560 - fail: function(res) {}  
561 - })  
562 - },  
563 -  
564 - //上传图片接口调取  
565 - uploadAllfile(filePaths, successUp, failUp, i, length) {  
566 - let that = this  
567 - let strtime = +new Date()  
568 - wx.uploadFile({  
569 - url: 'https://insurance.w.broteam.cn/pubilc/upload', //仅为示例,非真实的接口地址  
570 - filePath: filePaths[i],  
571 - name: 'picurl',  
572 - formData: {  
573 - 'strtime': strtime,  
574 - 'token': app.strTime(strtime) 92 +
  93 + //主险名称
  94 + setRiskName(e) {
  95 + // console.log(e)
  96 + this.setData({
  97 + main_risks: e.detail.value,
  98 + })
  99 + // console.log(this.data.main_risks)
575 }, 100 },
576 - success: function(res) {  
577 - wx.hideNavigationBarLoading()  
578 - wx.hideLoading()  
579 - if (res.statusCode == '200') {  
580 - let imgTemp = that.data.imgs;  
581 - let curImg = JSON.parse(res.data).data.picurl;  
582 - if (imgTemp.length < 6) {  
583 - imgTemp.push("http://" + curImg)  
584 - that.setData({  
585 - imgs: imgTemp  
586 - })  
587 - wx.showToast({  
588 - title: '上传成功',  
589 - icon: 'none',  
590 - duration: 2000,  
591 - })  
592 - } else {  
593 - wx.showToast({  
594 - title: '图片上限6张',  
595 - icon: 'none',  
596 - duration: 2000,  
597 - })  
598 - }  
599 - } else {  
600 - wx.showModal({  
601 - title: '提示',  
602 - content: res.msg,  
603 - showCancel: false  
604 - })  
605 - } 101 +
  102 + //保费
  103 + yearMoney(e) {
  104 + this.setData({
  105 + year_money: e.detail.value,
  106 + })
606 }, 107 },
607 - fail: function(res) {  
608 - wx.hideNavigationBarLoading()  
609 - wx.hideLoading() 108 +
  109 + //设置银行
  110 + setBank(e) {
  111 + this.setData({
  112 + bank: e.detail.value,
  113 + })
610 }, 114 },
611 - complete: () => {  
612 - i++;  
613 - if (i == length) {  
614 - // console.log('总共' + successUp + '张上传成功,' + failUp + '张上传失败!');  
615 - } else { //递归调用uploadDIY函数  
616 - this.uploadAllfile(filePaths, successUp, failUp, i, length);  
617 - } 115 +
  116 + //设置账号
  117 + setBankNum(e) {
  118 + this.setData({
  119 + bank_num: e.detail.value,
  120 + })
618 }, 121 },
619 - })  
620 - },  
621 -  
622 - //预览图片  
623 - viewImg(e) {  
624 - var imgs = this.data.imgs  
625 - var current = e.currentTarget.dataset.index  
626 - wx.previewImage({  
627 - //当前显示图片  
628 - current: imgs[current],  
629 - //所有图片  
630 - urls: imgs  
631 - })  
632 - },  
633 -  
634 - //删除图片  
635 - deleteImg(e) {  
636 - var imgs = this.data.imgs;  
637 - var index = e.currentTarget.dataset.index;  
638 - imgs.splice(index, 1);  
639 - this.setData({  
640 - imgs: imgs  
641 - });  
642 - },  
643 -  
644 - //保障期  
645 - warrantyTwo(e) {  
646 - if (this.data.inforid != 0) {  
647 - this.setData({  
648 - edit_state: false  
649 - })  
650 - }  
651 - var guarantee_name = e.detail.value  
652 - this.setData({  
653 - guarantee_name: e.detail.value  
654 - })  
655 - this.countImpletionTime2()  
656 - },  
657 -  
658 - //选择各项单位  
659 - selectUnit(e) {  
660 - var unit = e.currentTarget.dataset.unit  
661 - this.setData({  
662 - unit: unit  
663 - })  
664 - this.countImpletionTime2()  
665 - },  
666 -  
667 - //重组保障期数据格式  
668 - tempWarranty() {  
669 - var guarantee_name = this.data.guarantee_name  
670 - var unit = this.data.unit  
671 - var warranty_two = this.data.warranty_two  
672 - warranty_two.num = guarantee_name  
673 - warranty_two.title = unit  
674 - this.setData({  
675 - warranty_two: warranty_two  
676 - })  
677 - },  
678 -  
679 -  
680 - //计算缴费期满日,主线保障其  
681 - countImpletionTime2() {  
682 - var guarantee_name = parseInt(this.data.guarantee_name)  
683 - var unit = this.data.unit  
684 - var compact_time = this.data.compact_time  
685 - var year = parseInt(new Date(compact_time).getFullYear())  
686 - console.log(year)  
687 - var month = parseInt(new Date(compact_time).getMonth() + 1)  
688 - var day = parseInt(new Date(compact_time).getDate())  
689 - // var impletion_time = this.data.impletion_time  
690 - var warranty_one = this.data.warranty_one  
691 -  
692 - var tempbirth_time = ''  
693 - var birthday = '1995-04-20'  
694 - var birthday_year = parseInt(new Date(birthday).getFullYear())  
695 -  
696 - if (compact_time == '') {  
697 - wx.showToast({  
698 - title: '请选择合同生效日',  
699 - icon: 'none'  
700 - })  
701 - } else {  
702 - if (unit == '年') {  
703 - var temp_year = (year + guarantee_name)  
704 - var temp_day = day - 1  
705 - if (month < 10) month = "0" + month;  
706 - if (temp_day < 10) temp_day = "0" + temp_day;  
707 - // impletion_time = temp_year + '-' + month + '-' + temp_day  
708 - warranty_one = temp_year + '-' + month + '-' + temp_day  
709 - } else if (unit == '岁') {  
710 - var temp_year = (birthday_year + guarantee_name - 1)  
711 - var temp_year2 = (birthday_year + guarantee_name)  
712 - var temp_month = month  
713 - if (temp_month < 10) temp_month = "0" + temp_month;  
714 - if (month < 10) month = "0" + month;  
715 - if (day < 10) day = "0" + day;  
716 - // impletion_time = temp_year + '-' + temp_month + '-' + day  
717 - warranty_one = temp_year2 + '-' + month + '-' + day  
718 - } else if (unit == '终身') {  
719 - // impletion_time = '终身缴费'  
720 - warranty_one = '终身'  
721 - }  
722 - this.setData({  
723 - // impletion_time: impletion_time,  
724 - warranty_one: warranty_one  
725 - })  
726 - }  
727 - },  
728 -  
729 - //缴费时长  
730 - burningTime(e) {  
731 - if (this.data.inforid != 0) {  
732 - this.setData({  
733 - edit_state: false  
734 - })  
735 - }  
736 - var time_name = e.detail.value  
737 - this.setData({  
738 - time_name: time_name  
739 - })  
740 - this.countImpletionTime()  
741 - },  
742 -  
743 - selectUnit2(e) {  
744 - var unit = e.currentTarget.dataset.unit  
745 - this.setData({  
746 - unit2: unit  
747 - })  
748 - this.countImpletionTime()  
749 - },  
750 -  
751 - //重组缴费时长数据格式  
752 - tempburningTime() {  
753 - var time_name = this.data.time_name  
754 - var unit = this.data.unit2  
755 - var long_money = this.data.long_money  
756 - long_money.num = time_name  
757 - long_money.title = unit  
758 - this.setData({  
759 - long_money: long_money  
760 - })  
761 - },  
762 -  
763 -  
764 - //计算缴费期满日,主线保障其  
765 - countImpletionTime() {  
766 - var time_name = parseInt(this.data.time_name)  
767 - var unit = this.data.unit2  
768 - var compact_time = this.data.compact_time  
769 - var year = parseInt(new Date(compact_time).getFullYear())  
770 - var month = parseInt(new Date(compact_time).getMonth() + 1)  
771 - var day = parseInt(new Date(compact_time).getDate())  
772 - var impletion_time = this.data.impletion_time  
773 - // var warranty_one = this.data.warranty_one  
774 -  
775 - var tempbirth_time = ''  
776 - var birthday = '1995-04-20'  
777 - var birthday_year = parseInt(new Date(birthday).getFullYear())  
778 -  
779 - if (compact_time == '') {  
780 - wx.showToast({  
781 - title: '请选择合同生效日',  
782 - icon: 'none'  
783 - })  
784 - } else {  
785 - if (unit == '年') {  
786 - var temp_year = (year + time_name)  
787 - var temp_day = day - 1  
788 - if (month < 10) month = "0" + month;  
789 - if (temp_day < 10) temp_day = "0" + temp_day;  
790 - impletion_time = temp_year + '-' + month + '-' + temp_day  
791 - // warranty_one = temp_year + '-' + month + '-' + temp_day  
792 - } else if (unit == '岁') {  
793 - var temp_year = (birthday_year + time_name - 1)  
794 - var temp_year2 = (birthday_year + time_name)  
795 - var temp_month = month  
796 - if (temp_month < 10) temp_month = "0" + temp_month;  
797 - if (month < 10) month = "0" + month;  
798 - if (day < 10) day = "0" + day;  
799 - impletion_time = temp_year + '-' + temp_month + '-' + day  
800 - // warranty_one = temp_year2 + '-' + month + '-' + day  
801 - } else if (unit == '终身') {  
802 - impletion_time = '终身缴费'  
803 - // warranty_one = '终身'  
804 - }  
805 - this.setData({  
806 - impletion_time: impletion_time,  
807 - // warranty_one: warranty_one  
808 - })  
809 - }  
810 - },  
811 -  
812 - //缴费方式  
813 - selectUnit3(e) {  
814 - var unit = e.currentTarget.dataset.unit  
815 - this.setData({  
816 - unit3: unit,  
817 - type_money: unit  
818 - })  
819 - },  
820 -  
821 - //附加险保障其  
822 - selectUnit4(e) {  
823 - var unit = e.currentTarget.dataset.unit;  
824 - let index = e.currentTarget.dataset.index;  
825 - let risk_list = Object.assign(this.data.risk_list, {});  
826 - risk_list[index].title = unit  
827 - this.setData({  
828 - risk_list: risk_list  
829 - })  
830 - },  
831 -  
832 - //家庭成员  
833 - familyMember() {  
834 - var FamilyId = this.data.FamilyId  
835 - let url = 'counselor/familyname'  
836 - let params = {  
837 - FamilyId: FamilyId,  
838 - }  
839 - app.post(url, params).then((res) => {  
840 - // console.log(res)  
841 - var beneficiary_list = this.data.beneficiary_list  
842 - for (var i in beneficiary_list) {  
843 - beneficiary_list[i].name_array = res.data.data.list  
844 - }  
845 - // console.log(beneficiary_list)  
846 -  
847 - if (res.data.code == 200) { 122 +
  123 + //合同生效日
  124 + compactTime(e) {
848 this.setData({ 125 this.setData({
849 - insure: res.data.data.list,  
850 - recognizee: res.data.data.list,  
851 - beneficiary_list: beneficiary_list, 126 + compact_time: e.detail.value,
852 }) 127 })
853 - }  
854 - })  
855 - },  
856 -  
857 - //设置缓存  
858 - setStorge(e) {  
859 - this.tempBeneficiary()  
860 - this.tempWarranty()  
861 - this.tempburningTime()  
862 - this.tempMain()  
863 - this.tempAddRisk()  
864 - var favoree = JSON.stringify(this.data.tempfavoree)  
865 - var warranty_two = JSON.stringify(this.data.warranty_two)  
866 - var long_money = JSON.stringify(this.data.long_money)  
867 - var more = JSON.stringify(this.data.more)  
868 - var guarantee = JSON.stringify(this.data.guarantee)  
869 - var warn = ""; //弹框时提示的内容  
870 - var in_num = this.data.in_num  
871 - var firm = this.data.firm  
872 - var applicant = this.data.applicant_name  
873 - var recognizee = this.data.recognizee_name  
874 - var main_risks = this.data.main_risks  
875 - var year_money = this.data.year_money  
876 - var compact_time = this.data.compact_time  
877 - var impletion_time = this.data.impletion_time  
878 - var warranty_one = JSON.stringify(this.data.warranty_one)  
879 - var type_money = this.data.type_money  
880 - var bank = this.data.bank  
881 - var bank_num = this.data.bank_num  
882 - var picurl = JSON.stringify(this.data.imgs)  
883 - let url = 'counselor/inforsave'  
884 - let params = {  
885 - // InfoId: this.data.inforid,  
886 - def_id: this.data.def_id,  
887 - in_num: in_num,  
888 - firm: firm,  
889 - applicant: applicant,  
890 - recognizee: recognizee,  
891 - favoree: favoree,  
892 - main_risks: main_risks,  
893 - guarantee: guarantee,  
894 - year_money: year_money,  
895 - warranty_two: warranty_two,  
896 - compact_time: compact_time,  
897 - impletion_time: impletion_time,  
898 - warranty_one: warranty_one,  
899 - long_money: long_money,  
900 - type_money: type_money,  
901 - bank: bank,  
902 - bank_num: bank_num,  
903 - more: more,  
904 - picurl: picurl,  
905 - }  
906 - app.post(url, params).then((res) => {  
907 - if (res.data.code == 200) {  
908 - wx.navigateBack({  
909 - delta: 1, 128 + this.countImpletionTime()
  129 + this.countImpletionTime2()
  130 + },
  131 +
  132 + //缴费期满日
  133 + impletionTime(e) {
  134 + this.setData({
  135 + impletion_time: e.detail.value,
910 }) 136 })
  137 + },
  138 +
  139 + //主险保障期
  140 + periodTime(e) {
911 this.setData({ 141 this.setData({
912 - storge_state: true 142 + period_index: e.detail.value,
913 }) 143 })
914 - var storge_state = true  
915 - wx.setStorageSync('storge_state', storge_state)  
916 - }  
917 - })  
918 - },  
919 -  
920 - //获取缓存内容  
921 - getStorage() {  
922 - let url = 'counselor/inforCopy'  
923 - let params = {  
924 - def_id: this.data.def_id,  
925 - }  
926 - app.post(url, params).then((res) => {  
927 - console.log(res)  
928 - if (res.data.code == 200) {  
929 - var warranty_two = res.data.data.def.warranty_two  
930 - var unit = this.data.unit  
931 - unit = warranty_two.title  
932 - var long_money = res.data.data.def.long_money  
933 - var unit2 = this.data.unit2  
934 - unit2 = long_money.title  
935 - var type_money = res.data.data.def.type_money  
936 - var unit3 = this.data.unit3  
937 - unit3 = type_money  
938 - var beneficiary_list = res.data.data.def.favoree  
939 - for (var obj in beneficiary_list) {  
940 - beneficiary_list[obj].beneficiary_name = beneficiary_list[obj].name  
941 - beneficiary_list[obj].name_array = this.data.insure  
942 - } 144 + },
943 145
  146 + //保障项目弹窗
  147 + ensureProject(e) {
944 this.setData({ 148 this.setData({
945 - imgs: res.data.data.def.picurl,  
946 - type_money: res.data.data.def.type_money,  
947 - unit3: unit3,  
948 - year_money: res.data.data.def.year_money,  
949 - long_money: res.data.data.def.long_money,  
950 - unit2: unit2,  
951 - in_num: res.data.data.def.in_num,  
952 - firm: res.data.data.def.firm,  
953 - main_risks: res.data.data.def.main_risks,  
954 - main_array: res.data.data.def.guarantee,  
955 - applicant_name: res.data.data.def.applicant,  
956 - recognizee_name: res.data.data.def.recognizee,  
957 - warranty_one: res.data.data.def.warranty_one,  
958 - warranty_two: res.data.data.def.warranty_two,  
959 - unit: unit,  
960 - compact_time: res.data.data.def.compact_time,  
961 - impletion_time: res.data.data.def.impletion_time,  
962 - bank: res.data.data.def.bank,  
963 - bank_num: res.data.data.def.bank_num,  
964 - risk_list: res.data.data.def.more,  
965 - beneficiary_list: beneficiary_list,  
966 - edit_state: true, 149 + edit_state: false
967 }) 150 })
968 - }  
969 - })  
970 - },  
971 -  
972 - //完成保单添加  
973 - listVerify(e) {  
974 - if (this.data.inforid == 0 || this.data.inforid == undefined) {  
975 - this.tempBeneficiary()  
976 - this.tempWarranty()  
977 - this.tempburningTime()  
978 - this.tempMain()  
979 - this.tempAddRisk()  
980 - var favoree = JSON.stringify(this.data.tempfavoree)  
981 - var warranty_two = JSON.stringify(this.data.warranty_two)  
982 - var long_money = JSON.stringify(this.data.long_money)  
983 - var more = JSON.stringify(this.data.more)  
984 - var guarantee = JSON.stringify(this.data.guarantee)  
985 - } else if (this.data.edit_state) {  
986 - var favoree = JSON.stringify(this.data.beneficiary_list)  
987 - var warranty_two = JSON.stringify(this.data.warranty_two)  
988 - var long_money = JSON.stringify(this.data.long_money)  
989 - var more = JSON.stringify(this.data.risk_list)  
990 - var guarantee = JSON.stringify(this.data.main_array)  
991 - } else {  
992 - this.tempBeneficiary()  
993 - this.tempWarranty()  
994 - this.tempburningTime()  
995 - this.tempMain()  
996 - this.tempAddRisk()  
997 - var favoree = JSON.stringify(this.data.tempfavoree)  
998 - var warranty_two = JSON.stringify(this.data.warranty_two)  
999 - var long_money = JSON.stringify(this.data.long_money)  
1000 - var more = JSON.stringify(this.data.more)  
1001 - var guarantee = JSON.stringify(this.data.guarantee)  
1002 - }  
1003 -  
1004 - var warn = ""; //弹框时提示的内容  
1005 - var flag = true; //判断信息输入是否完整判断弹窗  
1006 - var in_num = e.detail.value.policy_num  
1007 - var firm = e.detail.value.company;  
1008 - var applicant = this.data.applicant_name  
1009 - var recognizee = this.data.recognizee_name  
1010 - var main_risks = e.detail.value.main_risks  
1011 -  
1012 - var year_money = e.detail.value.year_money  
1013 - var compact_time = this.data.compact_time  
1014 - var impletion_time = this.data.impletion_time  
1015 - var warranty_one = JSON.stringify(this.data.warranty_one)  
1016 - var type_money = this.data.type_money  
1017 - var bank = e.detail.value.bank  
1018 - var bank_num = e.detail.value.bank_num  
1019 - var picurl = JSON.stringify(this.data.imgs)  
1020 -  
1021 - var continue1 = e.detail.target.dataset.type  
1022 - var complete = e.detail.target.dataset.type  
1023 -  
1024 - if (in_num == '') {  
1025 - warn = '请输入保单号!'  
1026 - } else if (firm == '') {  
1027 - warn = '请输入所属公司!'  
1028 - } else if (applicant == '') {  
1029 - warn = '请输入投保人!'  
1030 - } else if (recognizee == '') {  
1031 - warn = '请输入被保险人!'  
1032 - } else if (favoree == '') {  
1033 - warn = '请输入受益人!'  
1034 - } else if (main_risks == '') {  
1035 - warn = '请输入主险名称!'  
1036 - } else if (year_money == '') {  
1037 - warn = '请输入年交保费!'  
1038 - } else if (compact_time == '') {  
1039 - warn = '请输入合同生效日!'  
1040 - } else if (warranty_two.num == '') {  
1041 - warn = '请输入保障期!'  
1042 - } else if (long_money.num == '') {  
1043 - warn = '请输入缴费时长!'  
1044 - } else if (type_money == '') {  
1045 - warn = '请输入缴费方式!'  
1046 - } else if (bank == '') {  
1047 - warn = '请输入续费银行!'  
1048 - } else if (bank_num == '') {  
1049 - warn = '请输入续费账号!'  
1050 - } else if (!(/^[0-9]+.?[0-9]*/.test(bank_num))) {  
1051 - warn = '请输入正确续费账号!'  
1052 - } else if (impletion_time == '') {  
1053 - warn = '请输入缴费期满日!'  
1054 - } else if (warranty_one == '') {  
1055 - warn = '请输入主险保障期!'  
1056 - } else if (more == '') {  
1057 - warn = '请输入附加险!'  
1058 - } else if (picurl.length == 2) {  
1059 - warn = '请选择图片!'  
1060 - } else {  
1061 - flag = false  
1062 - // 添加、修改保单接口调取  
1063 - let url = 'counselor/inforuodate'  
1064 - let params = {  
1065 - InfoId: this.data.inforid,  
1066 - def_id: this.data.def_id,  
1067 - in_num: in_num,  
1068 - firm: firm,  
1069 - applicant: applicant,  
1070 - recognizee: recognizee,  
1071 - favoree: favoree,  
1072 - main_risks: main_risks,  
1073 - guarantee: guarantee,  
1074 - year_money: year_money,  
1075 - warranty_two: warranty_two,  
1076 - compact_time: compact_time,  
1077 - impletion_time: impletion_time,  
1078 - warranty_one: warranty_one,  
1079 - long_money: long_money,  
1080 - type_money: type_money,  
1081 - bank: bank,  
1082 - bank_num: bank_num,  
1083 - more: more,  
1084 - picurl: picurl,  
1085 - }  
1086 - app.post(url, params).then((res) => {  
1087 - if (res.data.code == 200) {  
1088 - if (continue1 == 'continue1') {  
1089 - wx.showToast({  
1090 - title: '添加成功',  
1091 - icon: 'none',  
1092 - duration: 2000, 151 +
  152 + let that = this;
  153 + let type = e.currentTarget.dataset.type;
  154 + let index = e.currentTarget.dataset.xulie;
  155 + let tempProjectlist = Object.assign(this.data.projectlist, {});
  156 + // 已经添加的附加险
  157 + let risk_list = Object.assign(this.data.risk_list, {});
  158 + console.log(risk_list)
  159 + let tempRist = risk_list[index].mo;
  160 + console.log(tempRist)
  161 + // 已经添加的主险
  162 + let tempMain_list = Object.assign(this.data.main_array, {})
  163 + if (type == 'zhuxian') {
  164 + if (tempMain_list.length > 0) {
  165 + for (let i in tempProjectlist) {
  166 + for (let j in tempMain_list) {
  167 + if (tempProjectlist[i].id == tempMain_list[j].id) {
  168 + tempProjectlist[i].choose_status = true
  169 + for (let g in tempProjectlist[i].title) {
  170 + tempProjectlist[i].title[g].t_id == tempMain_list[j].t_id ? tempProjectlist[i].title[g].label_state = true : ''
  171 +
  172 + }
  173 + }
  174 + }
  175 + }
  176 + }
  177 + } else {
  178 + if (tempRist.length) {
  179 + for (let i in tempProjectlist) {
  180 + for (let j in tempRist) {
  181 + if (tempProjectlist[i].id == tempRist[j].id) {
  182 + tempProjectlist[i].choose_status = true
  183 + for (let g in tempProjectlist[i].title) {
  184 + console.log(tempProjectlist[i].title[g])
  185 + tempProjectlist[i].title[g].t_id == tempMain_list[j].t_id ? tempProjectlist[i].title[g].label_state = true : ''
  186 + }
  187 + }
  188 + }
  189 + }
  190 + }
  191 + }
  192 +
  193 + wx.setNavigationBarTitle({
  194 + title: '选择保障项目',
  195 + })
  196 +
  197 + this.setData({
  198 + popup_state: true,
  199 + addType: type,
  200 + xulie: index,
  201 + projectlist: tempProjectlist
  202 + })
  203 + },
  204 +
  205 + // 调取保障项目接口
  206 + ensureProjectList() {
  207 + var main_risk = this.data.main_risk
  208 + let url = 'counselor/sageguard'
  209 + let params = {}
  210 + app.post(url, params).then((res) => {
  211 + if (res.data.code == 200) {
  212 + var projectlist = res.data.data.def;
  213 + for (var i = 0; i < projectlist.length; i++) {
  214 + projectlist[i].choose_status = false
  215 + for (var j = 0; j < projectlist[i].title.length; j++) {
  216 + projectlist[i].title[j].label_state = false
  217 + }
  218 + projectlist[i].title[0].current = 0
  219 + projectlist[i].title[0].label_state = true
  220 + }
  221 + this.setData({
  222 + projectlist: res.data.data.def
  223 + })
  224 + // console.log(this.data.projectlist)
  225 + }
1093 }) 226 })
  227 + },
  228 +
  229 + //保障项目单位
  230 + getUnit(e) {
  231 + var main_risk = this.data.main_risk
  232 + var index = e.currentTarget.dataset.index;
  233 + var sindex = e.currentTarget.dataset.sindex;
  234 + var projectlist = this.data.projectlist;
  235 + var title = projectlist[index].title
  236 + for (var i = 0; i < title.length; i++) {
  237 + title[i].current = ''
  238 + if (title[i].current == '') {
  239 + title[i].label_state = false
  240 + }
  241 + }
  242 + projectlist[index].title[sindex].current = sindex
  243 + if (projectlist[index].title[sindex].current == sindex) {
  244 + projectlist[index].title[sindex].label_state = true
  245 + }
1094 this.setData({ 246 this.setData({
1095 - in_num:'',  
1096 - firm:'',  
1097 - applicant_name:'',  
1098 - recognizee_name:'',  
1099 - // beneficiary_list: [{  
1100 - // name_array: [],  
1101 - // unit: ''  
1102 - // }],  
1103 - main_risks:'',  
1104 - main_array:'',  
1105 - year_money:'',  
1106 - compact_time:'',  
1107 - warranty_two:'',  
1108 - long_money:'',  
1109 - bank:'',  
1110 - bank_num:'',  
1111 - impletion_time:'',  
1112 - warranty_one:'',  
1113 - // risk_list:'',  
1114 - imgs:'',  
1115 - unit:'',  
1116 - unit2: '',  
1117 - unit3: '',  
1118 - unit4: '', 247 + projectlist: projectlist,
1119 }) 248 })
1120 - } else if (complete == 'complete') {  
1121 - wx.showToast({  
1122 - title: '添加成功',  
1123 - icon: 'none',  
1124 - duration: 2000, 249 + },
  250 +
  251 + //保障项目金额
  252 + popupNum(e) {
  253 + var index = e.currentTarget.dataset.index;
  254 + var projectlist = this.data.projectlist;
  255 + if (projectlist[index].choose_status) {
  256 + projectlist[index].num = e.detail.value
  257 + }
  258 + console.log(main_risk)
  259 + this.setData({
  260 + projectlist: projectlist
1125 }) 261 })
1126 - wx.navigateBack({  
1127 - delta: 1, 262 + },
  263 +
  264 + //选择保障项目
  265 + popupState(e) {
  266 + var index = e.currentTarget.dataset.index;
  267 + var projectlist = this.data.projectlist;
  268 + projectlist[index].choose_status = !projectlist[index].choose_status;
  269 + // console.log(projectlist)
  270 + this.setData({
  271 + projectlist: projectlist,
1128 }) 272 })
1129 - }  
1130 - }  
1131 - })  
1132 - }  
1133 -  
1134 - if (flag == true) {  
1135 - wx.showToast({  
1136 - title: warn,  
1137 - icon: 'none'  
1138 - })  
1139 - }  
1140 -  
1141 - },  
1142 -  
1143 -  
1144 -  
1145 - //获取编辑保单接口  
1146 - getlistVerify() {  
1147 - let url = 'counselor/infordef'  
1148 - let params = {  
1149 - InfoId: this.data.inforid,  
1150 - }  
1151 - app.post(url, params).then((res) => {  
1152 - if (res.data.code == 200) {  
1153 - var warranty_two = res.data.data.def.warranty_two  
1154 - var unit = this.data.unit  
1155 - unit = warranty_two.title  
1156 - var long_money = res.data.data.def.long_money  
1157 - var unit2 = this.data.unit2  
1158 - unit2 = long_money.title  
1159 - var type_money = res.data.data.def.type_money  
1160 - var unit3 = this.data.unit3  
1161 - unit3 = type_money  
1162 - var beneficiary_list = res.data.data.def.favoree  
1163 - for (var obj in beneficiary_list) {  
1164 - beneficiary_list[obj].beneficiary_name = beneficiary_list[obj].name  
1165 - beneficiary_list[obj].name_array = this.data.insure  
1166 - }  
1167 -  
1168 - var risk_list = res.data.data.def.more  
1169 - var projectlist = this.data.projectlist  
1170 -  
1171 - for (var i = 0; i < risk_list.length; i++) {  
1172 - for (var j = 0; j < projectlist.length; j++) {  
1173 - for (var k = 0; k < projectlist[j].title.length; k++) {  
1174 - if (risk_list[i].id == projectlist[j].id) {  
1175 - if (risk_list[i].title == projectlist[j].title[k].name) {  
1176 - var title = {}  
1177 - title.name = projectlist[j].title[k] 273 + if (this.data.inforid != 0) {
  274 + edit_state: false
  275 + }
  276 + },
  277 +
  278 + //确认选择的推荐方案
  279 + confirmCase() {
  280 + let index = this.data.xulie;
  281 + let type = this.data.addType;
  282 + var that = this
  283 + var main_array = []
  284 +
  285 + var projectlist = Object.assign(this.data.projectlist, {})
  286 + for (var i = 0; i < projectlist.length; i++) {
  287 + if (projectlist[i].choose_status) {
  288 + main_array.push(projectlist[i])
  289 + console.log(main_array)
  290 + }
  291 + }
  292 +
  293 + if (main_array != '') {
  294 + wx.showToast({
  295 + title: '添加成功',
  296 + icon: 'none'
  297 + })
  298 +
  299 + if (type == 'fujiaxian') {
  300 + let tempRist = that.data.risk_list;
  301 + console.log(tempRist)
  302 + tempRist[index]['mo'] = main_array;
  303 + that.setData({
  304 + risk_list: tempRist,
  305 + risk_listitm: tempRist
  306 + })
  307 + console.log(this.data.risk_list)
  308 + } else {
  309 + that.setData({
  310 + main_array: main_array,
  311 + })
  312 + }
  313 + console.log(this.data.main_array)
  314 + }
  315 + setTimeout(function() {
  316 + that.ensureProjectList()
  317 + that.setData({
  318 + popup_state: false
  319 + })
  320 + wx.setNavigationBarTitle({
  321 + title: '添加保单',
  322 + })
  323 + }, 800)
  324 +
  325 +
  326 + console.log(this.data.risk_list)
  327 + },
  328 +
  329 + //重组主险的保障项目
  330 + tempMain() {
  331 + var main_array = this.data.main_array
  332 + var warranty_one1 = []
  333 + // console.log(main_array)
  334 + for (var i = 0; i < main_array.length; i++) {
  335 + var temp = {}
  336 + for (var j = 0; j < main_array[i].title.length; j++) {
  337 + if (main_array[i].choose_status) {
  338 + if (main_array[i].title[j].label_state) {
  339 + temp.id = main_array[i].id
  340 + temp.name = main_array[i].name
  341 + temp.num = main_array[i].num
  342 + temp.title = main_array[i].title[j].name
  343 + temp.t_id = main_array[i].title[j].t_id
  344 + }
1178 } 345 }
1179 } 346 }
  347 + warranty_one1.push(temp)
  348 + this.setData({
  349 + guarantee: warranty_one1
  350 + })
1180 } 351 }
1181 - }  
1182 - }  
1183 352
1184 - var warranty_two = res.data.data.def.warranty_two  
1185 - var guarantee_name = warranty_two.num 353 + },
1186 354
1187 - var long_money = res.data.data.def.long_money  
1188 - var time_name = long_money.num 355 + //主险名称
  356 + addRiskName(e) {
  357 + var risk_list = this.data.risk_list
  358 + var index = e.currentTarget.dataset.index
  359 + risk_list[index].name = e.detail.value
  360 + this.setData({
  361 + risk_list: risk_list
  362 + })
  363 + },
1189 364
1190 - this.setData({  
1191 - imgs: res.data.data.def.picurl,  
1192 - type_money: res.data.data.def.type_money,  
1193 - unit3: unit3,  
1194 - year_money: res.data.data.def.year_money,  
1195 - long_money: res.data.data.def.long_money,  
1196 - unit2: unit2,  
1197 - in_num: res.data.data.def.in_num,  
1198 - firm: res.data.data.def.firm,  
1199 - main_risks: res.data.data.def.main_risks,  
1200 - main_array: res.data.data.def.guarantee,  
1201 - applicant_name: res.data.data.def.applicant,  
1202 - recognizee_name: res.data.data.def.recognizee,  
1203 - warranty_one: res.data.data.def.warranty_one,  
1204 - warranty_two: res.data.data.def.warranty_two,  
1205 - unit: unit,  
1206 - compact_time: res.data.data.def.compact_time,  
1207 - impletion_time: res.data.data.def.impletion_time,  
1208 - bank: res.data.data.def.bank,  
1209 - bank_num: res.data.data.def.bank_num,  
1210 - risk_list: risk_list,  
1211 - beneficiary_list: beneficiary_list,  
1212 - edit_state: true,  
1213 - guarantee_name: guarantee_name,  
1214 - time_name: time_name,  
1215 - })  
1216 - }  
1217 - })  
1218 - },  
1219 -  
1220 - /**  
1221 - * 生命周期函数--监听页面加载  
1222 - */  
1223 - onLoad: function(options) {  
1224 - this.ensureProjectList()  
1225 - this.setData({  
1226 - def_id: options.def_id,  
1227 - inforid: options.inforid,  
1228 - FamilyId: options.FamilyId,  
1229 - recognizee_name: options.name  
1230 - })  
1231 - if (options.inforid == undefined) {  
1232 - this.setData({  
1233 - inforid: 0  
1234 - })  
1235 - }  
1236 - if (options.FamilyId != '') {  
1237 - this.familyMember()  
1238 - }  
1239 - if (options.inforid != undefined) {  
1240 - this.getlistVerify()  
1241 - }  
1242 -  
1243 - if (wx.getStorageSync('storge_state') && options.inforid == undefined) {  
1244 - this.getStorage()  
1245 - }  
1246 - },  
1247 -  
1248 - /**  
1249 - * 生命周期函数--监听页面初次渲染完成  
1250 - */  
1251 - onReady: function() {  
1252 -  
1253 - },  
1254 -  
1255 - /**  
1256 - * 生命周期函数--监听页面显示  
1257 - */  
1258 - onShow: function() {  
1259 -  
1260 - },  
1261 -  
1262 - /**  
1263 - * 生命周期函数--监听页面隐藏  
1264 - */  
1265 - onHide: function() {  
1266 -  
1267 - },  
1268 -  
1269 - /**  
1270 - * 生命周期函数--监听页面卸载  
1271 - */  
1272 - onUnload: function() {  
1273 -  
1274 - },  
1275 -  
1276 - /**  
1277 - * 页面相关事件处理函数--监听用户下拉动作  
1278 - */  
1279 - onPullDownRefresh: function() {  
1280 -  
1281 - },  
1282 -  
1283 - /**  
1284 - * 页面上拉触底事件的处理函数  
1285 - */  
1286 - onReachBottom: function() {  
1287 -  
1288 - },  
1289 -  
1290 - /**  
1291 - * 用户点击右上角分享  
1292 - */  
1293 - onShareAppMessage: function() {  
1294 -  
1295 - }  
1296 -})  
  365 + //主险保障其
  366 + addRiskUnit(e) {
  367 + var risk_list = this.data.risk_list
  368 + var index = e.currentTarget.dataset.index
  369 + risk_list[index].num = e.detail.value
  370 + this.setData({
  371 + risk_list: risk_list
  372 + })
  373 + },
  374 +
  375 + //重组附加险整体数据结构
  376 + tempAddRisk() {
  377 + var risk_list = this.data.risk_list
  378 +
  379 + var sub_array = []
  380 + var temp_risk = this.data.risk_listitm;
  381 + var temp = this.data.risk_listitm;
  382 +
  383 + for (var i = 0; i < temp.length; i++) {
  384 + for (var j = 0; j < temp[i].mo.length; j++) {
  385 + for (var k = 0; k < temp[i].mo[j].title.length; k++) {
  386 + if (temp[i].name != '') {
  387 + // var temp = {}
  388 + // var subtemp = {}
  389 + if (temp[i].mo[j].choose_status) {
  390 + if (temp[i].mo[j].title[k].label_state) {
  391 + temp_risk[i].name = temp[i].name
  392 + temp_risk[i].num = temp[i].num
  393 + temp_risk[i].title = temp[i].title
  394 + temp_risk[i].mo[j].t_id = temp[i].mo[j].title[k].t_id
  395 + temp_risk[i].mo[j].id = temp[i].mo[j].id
  396 + temp_risk[i].mo[j].name = temp[i].mo[j].name
  397 + temp_risk[i].mo[j].num = temp[i].mo[j].num
  398 + temp_risk[i].mo[j].title = temp[i].mo[j].title[k].name
  399 + console.log(temp_risk)
  400 + }
  401 + }
  402 + }
  403 + }
  404 + }
  405 +
  406 + this.setData({
  407 + more: temp_risk
  408 + })
  409 + }
  410 +
  411 + },
  412 +
  413 + //选择受益人姓名
  414 + beneficiarySelect(e) {
  415 + if (this.data.inforid != 0) {
  416 + this.setData({
  417 + edit_state: false
  418 + })
  419 + }
  420 + var index = e.currentTarget.dataset.mindex
  421 + var beneficiary_list = Object.assign(this.data.beneficiary_list, {});
  422 + // 获取当前已选择的收益人
  423 + let tempBenefice = Object.assign(this.data.beneficiaryList, {})
  424 + // 当前选择的收益人
  425 + let nowPerson = beneficiary_list[index].name_array[e.detail.value];
  426 + // 判断受益人是否已经添加
  427 + const add = tempBenefice.every((tempBenefice) => {
  428 + return tempBenefice != nowPerson
  429 + })
  430 + if (add) {
  431 + beneficiary_list[index].beneficiary_name = nowPerson;
  432 + tempBenefice.push(nowPerson)
  433 + } else {
  434 + wx.showToast({
  435 + title: '请不要重复添加受益人',
  436 + icon: 'none'
  437 + })
  438 + }
  439 +
  440 + this.setData({
  441 + beneficiary_list: beneficiary_list,
  442 + beneficiaryList: tempBenefice
  443 + })
  444 +
  445 + },
  446 +
  447 + //添加收益比例
  448 + addUnit(e) {
  449 + var beneficiary_list = this.data.beneficiary_list;
  450 + beneficiary_list[beneficiary_list.length - 1].unit = e.detail.value;
  451 + this.setData({
  452 + beneficiary_list: beneficiary_list,
  453 + })
  454 + },
  455 +
  456 + //添加受益人
  457 + addPersons(e) {
  458 + var list = this.data.beneficiary_list;
  459 + var len = list.length
  460 + if (list[len - 1].beneficiary_name == undefined) {
  461 + wx.showToast({
  462 + title: '请选择受益人',
  463 + icon: 'none'
  464 + })
  465 + } else if (list[len - 1].unit == '') {
  466 + console.log('unit')
  467 + wx.showToast({
  468 + title: '请输入收益比',
  469 + icon: 'none'
  470 + })
  471 + } else {
  472 + list[len] = {
  473 + name_array: this.data.insure,
  474 + unit: ''
  475 + }
  476 + }
  477 + this.setData({
  478 + beneficiary_list: list
  479 + })
  480 + console.log(this.data.beneficiary_list)
  481 + },
  482 +
  483 + //重组添加受益人
  484 + tempBeneficiary() {
  485 + var beneficiary_list = this.data.beneficiary_list
  486 + var len = beneficiary_list.length;
  487 + var tempfavoree1 = [];
  488 + for (var i = 0; i < beneficiary_list.length; i++) {
  489 + var temp = {}
  490 + if (beneficiary_list[i].unit != '') {
  491 + temp.name = beneficiary_list[i].beneficiary_name
  492 + temp.unit = beneficiary_list[i].unit;
  493 + }
  494 + tempfavoree1.push(temp)
  495 + this.setData({
  496 + tempfavoree: tempfavoree1
  497 + })
  498 +
  499 + }
  500 + },
  501 +
  502 + //删除收益人
  503 + deletebenefict(e) {
  504 + let index = e.currentTarget.dataset.index;
  505 + let tempbenefict = Object.assign(this.data.beneficiary_list, {});
  506 + let beneficiaryList = Object.assign(this.data.beneficiaryList, {});
  507 + // 获取当前选项的受益人
  508 + let person = tempbenefict[index].beneficiary_name;
  509 + tempbenefict.splice(index, 1);
  510 + if (person) beneficiaryList.splice(beneficiaryList.indexOf(person), 1)
  511 +
  512 + this.setData({
  513 + beneficiaryList: beneficiaryList,
  514 + beneficiary_list: tempbenefict
  515 + })
  516 + },
  517 +
  518 + //添加附加险
  519 + addRisk() {
  520 + if (this.data.inforid != 0) {
  521 + this.setData({
  522 + edit_state: false
  523 + })
  524 + }
  525 + var risk_list = Object.assign(this.data.risk_list, {});
  526 + var len = risk_list.length
  527 + risk_list[len] = {
  528 + name: '',
  529 + mo: [],
  530 + project_time: '',
  531 + title: '',
  532 + num: ''
  533 + }
  534 + this.setData({
  535 + risk_list: risk_list
  536 + })
  537 + },
  538 +
  539 + //删除附加险
  540 + deleteRisk(e) {
  541 + let index = e.currentTarget.dataset.index;
  542 + let risk_list = Object.assign(this.data.risk_list, {});
  543 + risk_list.splice(index, 1);
  544 + this.setData({
  545 + risk_list: risk_list
  546 + })
  547 + },
  548 +
  549 + //上传图片
  550 + uploadImage() {
  551 + let that = this;
  552 + wx.chooseImage({
  553 + count: 6,
  554 + sizeType: ['original', 'compressed'],
  555 + success: function(res) {
  556 + let successUp = 0; //成功个数
  557 + let failUp = 0; //失败个数
  558 + let i = 0; //第几个
  559 + let tempFilePaths = res.tempFilePaths //总文件
  560 + let length = res.tempFilePaths.length //总共个数
  561 + wx.showNavigationBarLoading()
  562 + wx.showLoading({
  563 + title: '上传中',
  564 + })
  565 + that.uploadAllfile(tempFilePaths, successUp, failUp, i, length)
  566 + },
  567 + fail: function(res) {}
  568 + })
  569 + },
  570 +
  571 + //上传图片接口调取
  572 + uploadAllfile(filePaths, successUp, failUp, i, length) {
  573 + let that = this
  574 + let strtime = +new Date()
  575 + wx.uploadFile({
  576 + url: 'https://insurance.w.broteam.cn/pubilc/upload', //仅为示例,非真实的接口地址
  577 + filePath: filePaths[i],
  578 + name: 'picurl',
  579 + formData: {
  580 + 'strtime': strtime,
  581 + 'token': app.strTime(strtime)
  582 + },
  583 + success: function(res) {
  584 + wx.hideNavigationBarLoading()
  585 + wx.hideLoading()
  586 + if (res.statusCode == '200') {
  587 + let imgTemp = that.data.imgs;
  588 + let curImg = JSON.parse(res.data).data.picurl;
  589 + if (imgTemp.length < 6) {
  590 + imgTemp.push("http://" + curImg)
  591 + that.setData({
  592 + imgs: imgTemp
  593 + })
  594 + wx.showToast({
  595 + title: '上传成功',
  596 + icon: 'none',
  597 + duration: 2000,
  598 + })
  599 + } else {
  600 + wx.showToast({
  601 + title: '图片上限6张',
  602 + icon: 'none',
  603 + duration: 2000,
  604 + })
  605 + }
  606 + } else {
  607 + wx.showModal({
  608 + title: '提示',
  609 + content: res.msg,
  610 + showCancel: false
  611 + })
  612 + }
  613 + },
  614 + fail: function(res) {
  615 + wx.hideNavigationBarLoading()
  616 + wx.hideLoading()
  617 + },
  618 + complete: () => {
  619 + i++;
  620 + if (i == length) {
  621 + // console.log('总共' + successUp + '张上传成功,' + failUp + '张上传失败!');
  622 + } else { //递归调用uploadDIY函数
  623 + this.uploadAllfile(filePaths, successUp, failUp, i, length);
  624 + }
  625 + },
  626 + })
  627 + },
  628 +
  629 + //预览图片
  630 + viewImg(e) {
  631 + var imgs = this.data.imgs
  632 + var current = e.currentTarget.dataset.index
  633 + wx.previewImage({
  634 + //当前显示图片
  635 + current: imgs[current],
  636 + //所有图片
  637 + urls: imgs
  638 + })
  639 + },
  640 +
  641 + //删除图片
  642 + deleteImg(e) {
  643 + var imgs = this.data.imgs;
  644 + var index = e.currentTarget.dataset.index;
  645 + imgs.splice(index, 1);
  646 + this.setData({
  647 + imgs: imgs
  648 + });
  649 + },
  650 +
  651 + //保障期
  652 + warrantyTwo(e) {
  653 + if (this.data.inforid != 0) {
  654 + this.setData({
  655 + edit_state: false
  656 + })
  657 + }
  658 + var guarantee_name = e.detail.value
  659 + this.setData({
  660 + guarantee_name: e.detail.value
  661 + })
  662 + this.countImpletionTime2()
  663 + },
  664 +
  665 + //选择各项单位
  666 + selectUnit(e) {
  667 + var unit = e.currentTarget.dataset.unit
  668 + this.setData({
  669 + unit: unit
  670 + })
  671 + this.countImpletionTime2()
  672 + },
  673 +
  674 + //重组保障期数据格式
  675 + tempWarranty() {
  676 + var guarantee_name = this.data.guarantee_name
  677 + var unit = this.data.unit
  678 + var warranty_two = this.data.warranty_two
  679 + warranty_two.num = guarantee_name
  680 + warranty_two.title = unit
  681 + this.setData({
  682 + warranty_two: warranty_two
  683 + })
  684 + },
  685 +
  686 +
  687 + //计算缴费期满日,主线保障其
  688 + countImpletionTime2() {
  689 + var guarantee_name = parseInt(this.data.guarantee_name)
  690 + var unit = this.data.unit
  691 + var compact_time = this.data.compact_time
  692 + var year = parseInt(new Date(compact_time).getFullYear())
  693 + console.log(year)
  694 + var month = parseInt(new Date(compact_time).getMonth() + 1)
  695 + var day = parseInt(new Date(compact_time).getDate())
  696 + // var impletion_time = this.data.impletion_time
  697 + var warranty_one = this.data.warranty_one
  698 +
  699 + var tempbirth_time = ''
  700 + var birthday = '1995-04-20'
  701 + var birthday_year = parseInt(new Date(birthday).getFullYear())
  702 +
  703 + if (compact_time == '') {
  704 + wx.showToast({
  705 + title: '请选择合同生效日',
  706 + icon: 'none'
  707 + })
  708 + } else {
  709 + if (unit == '年') {
  710 + var temp_year = (year + guarantee_name)
  711 + var temp_day = day - 1
  712 + if (month < 10) month = "0" + month;
  713 + if (temp_day < 10) temp_day = "0" + temp_day;
  714 + // impletion_time = temp_year + '-' + month + '-' + temp_day
  715 + warranty_one = temp_year + '-' + month + '-' + temp_day
  716 + } else if (unit == '岁') {
  717 + var temp_year = (birthday_year + guarantee_name - 1)
  718 + var temp_year2 = (birthday_year + guarantee_name)
  719 + var temp_month = month
  720 + if (temp_month < 10) temp_month = "0" + temp_month;
  721 + if (month < 10) month = "0" + month;
  722 + if (day < 10) day = "0" + day;
  723 + // impletion_time = temp_year + '-' + temp_month + '-' + day
  724 + warranty_one = temp_year2 + '-' + month + '-' + day
  725 + } else if (unit == '终身') {
  726 + // impletion_time = '终身缴费'
  727 + warranty_one = '终身'
  728 + }
  729 + this.setData({
  730 + // impletion_time: impletion_time,
  731 + warranty_one: warranty_one
  732 + })
  733 + }
  734 + },
  735 +
  736 + //缴费时长
  737 + burningTime(e) {
  738 + if (this.data.inforid != 0) {
  739 + this.setData({
  740 + edit_state: false
  741 + })
  742 + }
  743 + var time_name = e.detail.value
  744 + this.setData({
  745 + time_name: time_name
  746 + })
  747 + this.countImpletionTime()
  748 + },
  749 +
  750 + selectUnit2(e) {
  751 + var unit = e.currentTarget.dataset.unit
  752 + this.setData({
  753 + unit2: unit
  754 + })
  755 + this.countImpletionTime()
  756 + },
  757 +
  758 + //重组缴费时长数据格式
  759 + tempburningTime() {
  760 + var time_name = this.data.time_name
  761 + var unit = this.data.unit2
  762 + var long_money = this.data.long_money
  763 + long_money.num = time_name
  764 + long_money.title = unit
  765 + this.setData({
  766 + long_money: long_money
  767 + })
  768 + },
  769 +
  770 +
  771 + //计算缴费期满日,主线保障其
  772 + countImpletionTime() {
  773 + var time_name = parseInt(this.data.time_name)
  774 + var unit = this.data.unit2
  775 + var compact_time = this.data.compact_time
  776 + var year = parseInt(new Date(compact_time).getFullYear())
  777 + var month = parseInt(new Date(compact_time).getMonth() + 1)
  778 + var day = parseInt(new Date(compact_time).getDate())
  779 + var impletion_time = this.data.impletion_time
  780 + // var warranty_one = this.data.warranty_one
  781 +
  782 + var tempbirth_time = ''
  783 + var birthday = '1995-04-20'
  784 + var birthday_year = parseInt(new Date(birthday).getFullYear())
  785 +
  786 + if (compact_time == '') {
  787 + wx.showToast({
  788 + title: '请选择合同生效日',
  789 + icon: 'none'
  790 + })
  791 + } else {
  792 + if (unit == '年') {
  793 + var temp_year = (year + time_name)
  794 + var temp_day = day - 1
  795 + if (month < 10) month = "0" + month;
  796 + if (temp_day < 10) temp_day = "0" + temp_day;
  797 + impletion_time = temp_year + '-' + month + '-' + temp_day
  798 + // warranty_one = temp_year + '-' + month + '-' + temp_day
  799 + } else if (unit == '岁') {
  800 + var temp_year = (birthday_year + time_name - 1)
  801 + var temp_year2 = (birthday_year + time_name)
  802 + var temp_month = month
  803 + if (temp_month < 10) temp_month = "0" + temp_month;
  804 + if (month < 10) month = "0" + month;
  805 + if (day < 10) day = "0" + day;
  806 + impletion_time = temp_year + '-' + temp_month + '-' + day
  807 + // warranty_one = temp_year2 + '-' + month + '-' + day
  808 + } else if (unit == '终身') {
  809 + impletion_time = '终身缴费'
  810 + // warranty_one = '终身'
  811 + }
  812 + this.setData({
  813 + impletion_time: impletion_time,
  814 + // warranty_one: warranty_one
  815 + })
  816 + }
  817 + },
  818 +
  819 + //缴费方式
  820 + selectUnit3(e) {
  821 + var unit = e.currentTarget.dataset.unit
  822 + this.setData({
  823 + unit3: unit,
  824 + type_money: unit
  825 + })
  826 + },
  827 +
  828 + //附加险保障其
  829 + selectUnit4(e) {
  830 + var unit = e.currentTarget.dataset.unit;
  831 + let index = e.currentTarget.dataset.index;
  832 + let risk_list = Object.assign(this.data.risk_list, {});
  833 + risk_list[index].title = unit
  834 + this.setData({
  835 + risk_list: risk_list
  836 + })
  837 + },
  838 +
  839 + //家庭成员
  840 + familyMember() {
  841 + var FamilyId = this.data.FamilyId
  842 + let url = 'counselor/familyname'
  843 + let params = {
  844 + FamilyId: FamilyId,
  845 + }
  846 + app.post(url, params).then((res) => {
  847 + // console.log(res)
  848 + var beneficiary_list = this.data.beneficiary_list
  849 + for (var i in beneficiary_list) {
  850 + beneficiary_list[i].name_array = res.data.data.list
  851 + }
  852 + // console.log(beneficiary_list)
  853 +
  854 + if (res.data.code == 200) {
  855 + this.setData({
  856 + insure: res.data.data.list,
  857 + recognizee: res.data.data.list,
  858 + beneficiary_list: beneficiary_list,
  859 + })
  860 + }
  861 + })
  862 + },
  863 +
  864 + //设置缓存
  865 + setStorge(e) {
  866 + this.tempBeneficiary()
  867 + this.tempWarranty()
  868 + this.tempburningTime()
  869 + this.tempMain()
  870 + this.tempAddRisk()
  871 + var favoree = JSON.stringify(this.data.tempfavoree)
  872 + var warranty_two = JSON.stringify(this.data.warranty_two)
  873 + var long_money = JSON.stringify(this.data.long_money)
  874 + var more = JSON.stringify(this.data.more)
  875 + var guarantee = JSON.stringify(this.data.guarantee)
  876 + var warn = ""; //弹框时提示的内容
  877 + var in_num = this.data.in_num
  878 + var firm = this.data.firm
  879 + var applicant = this.data.applicant_name
  880 + var recognizee = this.data.recognizee_name
  881 + var main_risks = this.data.main_risks
  882 + var year_money = this.data.year_money
  883 + var compact_time = this.data.compact_time
  884 + var impletion_time = this.data.impletion_time
  885 + var warranty_one = JSON.stringify(this.data.warranty_one)
  886 + var type_money = this.data.type_money
  887 + var bank = this.data.bank
  888 + var bank_num = this.data.bank_num
  889 + var picurl = JSON.stringify(this.data.imgs)
  890 + let url = 'counselor/inforsave'
  891 + let params = {
  892 + // InfoId: this.data.inforid,
  893 + def_id: this.data.def_id,
  894 + in_num: in_num,
  895 + firm: firm,
  896 + applicant: applicant,
  897 + recognizee: recognizee,
  898 + favoree: favoree,
  899 + main_risks: main_risks,
  900 + guarantee: guarantee,
  901 + year_money: year_money,
  902 + warranty_two: warranty_two,
  903 + compact_time: compact_time,
  904 + impletion_time: impletion_time,
  905 + warranty_one: warranty_one,
  906 + long_money: long_money,
  907 + type_money: type_money,
  908 + bank: bank,
  909 + bank_num: bank_num,
  910 + more: more,
  911 + picurl: picurl,
  912 + }
  913 + app.post(url, params).then((res) => {
  914 + if (res.data.code == 200) {
  915 + wx.navigateBack({
  916 + delta: 1,
  917 + })
  918 + this.setData({
  919 + storge_state: true
  920 + })
  921 + var storge_state = true
  922 + wx.setStorageSync('storge_state', storge_state)
  923 + }
  924 + })
  925 + },
  926 +
  927 + //获取缓存内容
  928 + getStorage() {
  929 + let url = 'counselor/inforCopy'
  930 + let params = {
  931 + def_id: this.data.def_id,
  932 + }
  933 + app.post(url, params).then((res) => {
  934 + console.log(res)
  935 + if (res.data.code == 200) {
  936 + var warranty_two = res.data.data.def.warranty_two
  937 + var unit = this.data.unit
  938 + unit = warranty_two.title
  939 + var long_money = res.data.data.def.long_money
  940 + var unit2 = this.data.unit2
  941 + unit2 = long_money.title
  942 + var type_money = res.data.data.def.type_money
  943 + var unit3 = this.data.unit3
  944 + unit3 = type_money
  945 + var beneficiary_list = res.data.data.def.favoree
  946 + for (var obj in beneficiary_list) {
  947 + beneficiary_list[obj].beneficiary_name = beneficiary_list[obj].name
  948 + beneficiary_list[obj].name_array = this.data.insure
  949 + }
  950 +
  951 + this.setData({
  952 + imgs: res.data.data.def.picurl,
  953 + type_money: res.data.data.def.type_money,
  954 + unit3: unit3,
  955 + year_money: res.data.data.def.year_money,
  956 + long_money: res.data.data.def.long_money,
  957 + unit2: unit2,
  958 + in_num: res.data.data.def.in_num,
  959 + firm: res.data.data.def.firm,
  960 + main_risks: res.data.data.def.main_risks,
  961 + main_array: res.data.data.def.guarantee,
  962 + applicant_name: res.data.data.def.applicant,
  963 + recognizee_name: res.data.data.def.recognizee,
  964 + warranty_one: res.data.data.def.warranty_one,
  965 + warranty_two: res.data.data.def.warranty_two,
  966 + unit: unit,
  967 + compact_time: res.data.data.def.compact_time,
  968 + impletion_time: res.data.data.def.impletion_time,
  969 + bank: res.data.data.def.bank,
  970 + bank_num: res.data.data.def.bank_num,
  971 + risk_list: res.data.data.def.more,
  972 + beneficiary_list: beneficiary_list,
  973 + edit_state: true,
  974 + })
  975 + }
  976 + })
  977 + },
  978 +
  979 + //完成保单添加
  980 + listVerify(e) {
  981 + if (this.data.inforid == 0 || this.data.inforid == undefined) {
  982 + this.tempBeneficiary()
  983 + this.tempWarranty()
  984 + this.tempburningTime()
  985 + this.tempMain()
  986 + this.tempAddRisk()
  987 + var favoree = JSON.stringify(this.data.tempfavoree)
  988 + var warranty_two = JSON.stringify(this.data.warranty_two)
  989 + var long_money = JSON.stringify(this.data.long_money)
  990 + var more = JSON.stringify(this.data.more)
  991 + var guarantee = JSON.stringify(this.data.guarantee)
  992 + } else if (this.data.edit_state) {
  993 + var favoree = JSON.stringify(this.data.beneficiary_list)
  994 + var warranty_two = JSON.stringify(this.data.warranty_two)
  995 + var long_money = JSON.stringify(this.data.long_money)
  996 + var more = JSON.stringify(this.data.risk_list)
  997 + var guarantee = JSON.stringify(this.data.main_array)
  998 + } else {
  999 + this.tempBeneficiary()
  1000 + this.tempWarranty()
  1001 + this.tempburningTime()
  1002 + this.tempMain()
  1003 + this.tempAddRisk()
  1004 + var favoree = JSON.stringify(this.data.tempfavoree)
  1005 + var warranty_two = JSON.stringify(this.data.warranty_two)
  1006 + var long_money = JSON.stringify(this.data.long_money)
  1007 + var more = JSON.stringify(this.data.more)
  1008 + var guarantee = JSON.stringify(this.data.guarantee)
  1009 + }
  1010 +
  1011 + var warn = ""; //弹框时提示的内容
  1012 + var flag = true; //判断信息输入是否完整判断弹窗
  1013 + var in_num = e.detail.value.policy_num
  1014 + var firm = e.detail.value.company;
  1015 + var applicant = this.data.applicant_name
  1016 + var recognizee = this.data.recognizee_name
  1017 + var main_risks = e.detail.value.main_risks
  1018 +
  1019 + var year_money = e.detail.value.year_money
  1020 + var compact_time = this.data.compact_time
  1021 + var impletion_time = this.data.impletion_time
  1022 + var warranty_one = JSON.stringify(this.data.warranty_one)
  1023 + var type_money = this.data.type_money
  1024 + var bank = e.detail.value.bank
  1025 + var bank_num = e.detail.value.bank_num
  1026 + var picurl = JSON.stringify(this.data.imgs)
  1027 +
  1028 + var continue1 = e.detail.target.dataset.type
  1029 + var complete = e.detail.target.dataset.type
  1030 +
  1031 + if (in_num == '') {
  1032 + warn = '请输入保单号!'
  1033 + } else if (firm == '') {
  1034 + warn = '请输入所属公司!'
  1035 + } else if (applicant == '') {
  1036 + warn = '请输入投保人!'
  1037 + } else if (recognizee == '') {
  1038 + warn = '请输入被保险人!'
  1039 + } else if (favoree == '') {
  1040 + warn = '请输入受益人!'
  1041 + } else if (main_risks == '') {
  1042 + warn = '请输入主险名称!'
  1043 + } else if (year_money == '') {
  1044 + warn = '请输入年交保费!'
  1045 + } else if (compact_time == '') {
  1046 + warn = '请输入合同生效日!'
  1047 + } else if (warranty_two.num == '') {
  1048 + warn = '请输入保障期!'
  1049 + } else if (long_money.num == '') {
  1050 + warn = '请输入缴费时长!'
  1051 + } else if (type_money == '') {
  1052 + warn = '请输入缴费方式!'
  1053 + } else if (bank == '') {
  1054 + warn = '请输入续费银行!'
  1055 + } else if (bank_num == '') {
  1056 + warn = '请输入续费账号!'
  1057 + } else if (!(/^[0-9]+.?[0-9]*/.test(bank_num))) {
  1058 + warn = '请输入正确续费账号!'
  1059 + } else if (impletion_time == '') {
  1060 + warn = '请输入缴费期满日!'
  1061 + } else if (warranty_one == '') {
  1062 + warn = '请输入主险保障期!'
  1063 + } else if (more == '') {
  1064 + warn = '请输入附加险!'
  1065 + } else if (picurl.length == 2) {
  1066 + warn = '请选择图片!'
  1067 + } else {
  1068 + flag = false
  1069 + // 添加、修改保单接口调取
  1070 + let url = 'counselor/inforuodate'
  1071 + let params = {
  1072 + InfoId: this.data.inforid,
  1073 + def_id: this.data.def_id,
  1074 + in_num: in_num,
  1075 + firm: firm,
  1076 + applicant: applicant,
  1077 + recognizee: recognizee,
  1078 + favoree: favoree,
  1079 + main_risks: main_risks,
  1080 + guarantee: guarantee,
  1081 + year_money: year_money,
  1082 + warranty_two: warranty_two,
  1083 + compact_time: compact_time,
  1084 + impletion_time: impletion_time,
  1085 + warranty_one: warranty_one,
  1086 + long_money: long_money,
  1087 + type_money: type_money,
  1088 + bank: bank,
  1089 + bank_num: bank_num,
  1090 + more: more,
  1091 + picurl: picurl,
  1092 + }
  1093 + app.post(url, params).then((res) => {
  1094 + if (res.data.code == 200) {
  1095 + if (continue1 == 'continue1') {
  1096 + wx.showToast({
  1097 + title: '添加成功',
  1098 + icon: 'none',
  1099 + duration: 2000,
  1100 + })
  1101 + this.setData({
  1102 + in_num: '',
  1103 + firm: '',
  1104 + applicant_name: '',
  1105 + recognizee_name: '',
  1106 + // beneficiary_list: [{
  1107 + // name_array: [],
  1108 + // unit: ''
  1109 + // }],
  1110 + main_risks: '',
  1111 + main_array: '',
  1112 + year_money: '',
  1113 + compact_time: '',
  1114 + warranty_two: '',
  1115 + long_money: '',
  1116 + bank: '',
  1117 + bank_num: '',
  1118 + impletion_time: '',
  1119 + warranty_one: '',
  1120 + // risk_list:'',
  1121 + imgs: '',
  1122 + unit: '',
  1123 + unit2: '',
  1124 + unit3: '',
  1125 + unit4: '',
  1126 + })
  1127 + } else if (complete == 'complete') {
  1128 + wx.showToast({
  1129 + title: '添加成功',
  1130 + icon: 'none',
  1131 + duration: 2000,
  1132 + })
  1133 + wx.navigateBack({
  1134 + delta: 1,
  1135 + })
  1136 + }
  1137 + }
  1138 + })
  1139 + }
  1140 +
  1141 + if (flag == true) {
  1142 + wx.showToast({
  1143 + title: warn,
  1144 + icon: 'none'
  1145 + })
  1146 + }
  1147 +
  1148 + },
  1149 +
  1150 +
  1151 +
  1152 + //获取编辑保单接口
  1153 + getlistVerify() {
  1154 + let url = 'counselor/infordef'
  1155 + let params = {
  1156 + InfoId: this.data.inforid,
  1157 + }
  1158 + app.post(url, params).then((res) => {
  1159 + if (res.data.code == 200) {
  1160 + var warranty_two = res.data.data.def.warranty_two
  1161 + var unit = this.data.unit
  1162 + unit = warranty_two.title
  1163 + var long_money = res.data.data.def.long_money
  1164 + var unit2 = this.data.unit2
  1165 + unit2 = long_money.title
  1166 + var type_money = res.data.data.def.type_money
  1167 + var unit3 = this.data.unit3
  1168 + unit3 = type_money
  1169 + var beneficiary_list = res.data.data.def.favoree
  1170 + for (var obj in beneficiary_list) {
  1171 + beneficiary_list[obj].beneficiary_name = beneficiary_list[obj].name
  1172 + beneficiary_list[obj].name_array = this.data.insure
  1173 + }
  1174 +
  1175 + var risk_list = res.data.data.def.more
  1176 + var projectlist = this.data.projectlist
  1177 +
  1178 + for (var i = 0; i < risk_list.length; i++) {
  1179 + for (var j = 0; j < projectlist.length; j++) {
  1180 + for (var k = 0; k < projectlist[j].title.length; k++) {
  1181 + if (risk_list[i].id == projectlist[j].id) {
  1182 + if (risk_list[i].title == projectlist[j].title[k].name) {
  1183 + var title = {}
  1184 + title.name = projectlist[j].title[k]
  1185 + }
  1186 + }
  1187 + }
  1188 + }
  1189 + }
  1190 +
  1191 + var warranty_two = res.data.data.def.warranty_two
  1192 + var guarantee_name = warranty_two.num
  1193 +
  1194 + var long_money = res.data.data.def.long_money
  1195 + var time_name = long_money.num
  1196 +
  1197 + this.setData({
  1198 + imgs: res.data.data.def.picurl,
  1199 + type_money: res.data.data.def.type_money,
  1200 + unit3: unit3,
  1201 + year_money: res.data.data.def.year_money,
  1202 + long_money: res.data.data.def.long_money,
  1203 + unit2: unit2,
  1204 + in_num: res.data.data.def.in_num,
  1205 + firm: res.data.data.def.firm,
  1206 + main_risks: res.data.data.def.main_risks,
  1207 + main_array: res.data.data.def.guarantee,
  1208 + applicant_name: res.data.data.def.applicant,
  1209 + recognizee_name: res.data.data.def.recognizee,
  1210 + warranty_one: res.data.data.def.warranty_one,
  1211 + warranty_two: res.data.data.def.warranty_two,
  1212 + unit: unit,
  1213 + compact_time: res.data.data.def.compact_time,
  1214 + impletion_time: res.data.data.def.impletion_time,
  1215 + bank: res.data.data.def.bank,
  1216 + bank_num: res.data.data.def.bank_num,
  1217 + risk_list: risk_list,
  1218 + beneficiary_list: beneficiary_list,
  1219 + edit_state: true,
  1220 + guarantee_name: guarantee_name,
  1221 + time_name: time_name,
  1222 + })
  1223 + }
  1224 + })
  1225 + },
  1226 +
  1227 + /**
  1228 + * 生命周期函数--监听页面加载
  1229 + */
  1230 + onLoad: function(options) {
  1231 + this.ensureProjectList()
  1232 + this.setData({
  1233 + def_id: options.def_id,
  1234 + inforid: options.inforid,
  1235 + FamilyId: options.FamilyId,
  1236 + recognizee_name: options.name
  1237 + })
  1238 + if (options.inforid == undefined) {
  1239 + this.setData({
  1240 + inforid: 0
  1241 + })
  1242 + }
  1243 + if (options.FamilyId != '') {
  1244 + this.familyMember()
  1245 + }
  1246 + if (options.inforid != undefined) {
  1247 + this.getlistVerify()
  1248 + }
  1249 +
  1250 + if (wx.getStorageSync('storge_state') && options.inforid == undefined) {
  1251 + this.getStorage()
  1252 + }
  1253 + },
  1254 +
  1255 + /**
  1256 + * 生命周期函数--监听页面初次渲染完成
  1257 + */
  1258 + onReady: function() {
  1259 +
  1260 + },
  1261 +
  1262 + /**
  1263 + * 生命周期函数--监听页面显示
  1264 + */
  1265 + onShow: function() {
  1266 +
  1267 + },
  1268 +
  1269 + /**
  1270 + * 生命周期函数--监听页面隐藏
  1271 + */
  1272 + onHide: function() {
  1273 +
  1274 + },
  1275 +
  1276 + /**
  1277 + * 生命周期函数--监听页面卸载
  1278 + */
  1279 + onUnload: function() {
  1280 +
  1281 + },
  1282 +
  1283 + /**
  1284 + * 页面相关事件处理函数--监听用户下拉动作
  1285 + */
  1286 + onPullDownRefresh: function() {
  1287 +
  1288 + },
  1289 +
  1290 + /**
  1291 + * 页面上拉触底事件的处理函数
  1292 + */
  1293 + onReachBottom: function() {
  1294 +
  1295 + },
  1296 +
  1297 + /**
  1298 + * 用户点击右上角分享
  1299 + */
  1300 + onShareAppMessage: function() {
  1301 +
  1302 + }
  1303 + })