作者 朱振飞

保单修改

  1 +// pages/addListDetail/addListDetail.js
  2 +const app = getApp()
  3 +Page({
  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].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 + }
  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 + }
  246 + this.setData({
  247 + projectlist: projectlist,
  248 + })
  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
  261 + })
  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,
  272 + })
  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 + }
  345 + }
  346 + }
  347 + warranty_one1.push(temp)
  348 + this.setData({
  349 + guarantee: warranty_one1
  350 + })
  351 + }
  352 +
  353 + },
  354 +
  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 + },
  364 +
  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 + })