作者 刘晓艳

测试

const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
recognizee: ['被保人', '被保人2'],
recognizee_index: 0,
period_time: ['10年', '20年'],
period_index: -1,
compact_time: '',
impletion_time: '',
popup_state: false,
projectlist: [],
label_state: false,
insure: ['投保人', '投保人2'],
insureindex: -1,
beneficiary_list: [{
// name_array: ['受益人1', '受益人2'],
// beneficiary_name:'',
name: '',
unit: ''
}],
beneficiaryindex: -1,
tempfavoree: [], // 已选择的受益人
beneficiaryList: [],
name: '', //受益人的名字,
beneficiary_name: '',
imgs: [],
main_risk: [],
unit: '',
unit2: '',
unit3: '',
unit4: '',
applicant_name: '',
recognizee_name: '',
rang_beneficiary: [],
risk_list: [{
name: '',
mo: [],
// project_time: '',
title: '',
num: ''
}],
main_array: [],
warranty_one: '',
warranty_two: {},
guarantee_name: '',
long_money: {},
time_name: '',
type_money: '',
more: [],
guarantee: [],
InfoId: 0,
def_id: '',
// edit_state: false,
// edit_state2: false,
// risk_listitm: '',
storge_state: false,
warranty_info: '请输入',
warranty_state: false,
warranty_info1: '请输入',
warranty_state1: false,
edit_state3: false,
coverage: '',
focus: false,
sub_index: ''
},
//回到顶部
goTop: function(e) { // 一键回到顶部
if (wx.pageScrollTo) {
wx.pageScrollTo({
scrollTop: 0
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
cancleMask() {
// if (this.data.inforid != 0) {
// if (this.data.edit_state3) {
// this.setData({
// edit_state: false,
// edit_state2: false
// })
// } else {
// this.setData({
// edit_state: true,
// edit_state2: true
// })
// }
// } else {
// this.setData({
// edit_state: false,
// edit_state2: false
// })
// }
// console.log(this.data.edit_state)
this.setData({
popup_state: false,
})
},
//保单号
policyNum(e) {
this.setData({
in_num: e.detail.value,
})
},
//保单号
setFirm(e) {
this.setData({
firm: e.detail.value,
})
},
//投保人
insureSelect(e) {
var insure = this.data.insure
this.setData({
insureindex: e.detail.value,
applicant_name: insure[e.detail.value],
})
},
//选择被保险人
recognizeeSelect(e) {
var recognizee = this.data.recognizee
this.setData({
recognizeeindex: e.detail.value,
recognizee_name: recognizee[e.detail.value]
})
},
//主险名称
setRiskName(e) {
this.setData({
main_risks: e.detail.value,
})
},
//主险名称
setRiskMoney(e) {
this.setData({
coverage: e.detail.value,
})
},
//保费
yearMoney(e) {
this.setData({
year_money: e.detail.value,
})
},
//设置银行
setBank(e) {
this.setData({
bank: e.detail.value,
})
},
//设置账号
setBankNum(e) {
this.setData({
bank_num: e.detail.value,
})
},
//合同生效日
compactTime(e) {
this.setData({
compact_time: e.detail.value,
})
this.countImpletionTime()
this.countImpletionTime2()
},
//缴费期满日
impletionTime(e) {
this.setData({
impletion_time: e.detail.value,
})
},
//主险保障期
periodTime(e) {
this.setData({
period_index: e.detail.value,
})
},
//保障项目弹窗
ensureProject(e) {
let that = this;
let type = e.currentTarget.dataset.type;
let index = e.currentTarget.dataset.xulie;
// 复制保障项目模板
// let tempProjectlist = Object.assign({}, this.data.projectlist);
let tempProjectlist = JSON.parse(JSON.stringify(this.data.projectlist));
console.log(tempProjectlist)
var sub_index = that.data.sub_index
var edit_state3 = that.data.edit_state3
// 已经添加的附加险
let risk_list = Object.assign({},this.data.risk_list);
let tempRist = risk_list[index].mo;
this.setData({
type: type,
xielie: index
})
if (type == 'fujiaxian') {
this.setData({
focus: true
})
}
// 已经添加的主险
let tempMain_list = Object.assign({},this.data.main_array)
this.data.inforid != 0 && this.data.inforid != undefined
//编辑/缓存状态
<<<<<<< HEAD
if (that.data.temp_state) {
console.log('edit')
//edit_state3:代表是刚获取到信息是的结构,还是重新选择之后的数据结构
if (edit_state3) {
//获取到的信息结构
if (type == 'zhuxian') {
console.log('zx')
this.setData({
focus: false
})
if (tempMain_list.length > 0) {
for (let i in tempProjectlist) {
for (let j in tempMain_list) {
if (tempProjectlist[i].id == tempMain_list[j].id) {
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempMain_list[j].num
for (let g in tempProjectlist[i].title) {
if (tempProjectlist[i].title[g].t_id == tempMain_list[j].t_id) {
tempProjectlist[i].title[g].label_state = true
if (tempProjectlist[i].title[g].name == tempMain_list[j].title) {
tempProjectlist[i].title[g].current = parseInt(g)
sub_index = parseInt(g)
}
}
}
}
}
}
}
} else {
console.log('fjx')
if (tempRist.length) {
for (let i in tempProjectlist) {
for (let j in tempRist) {
if (tempProjectlist[i].id == tempRist[j].id) {
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempRist[j].num
for (let g in tempProjectlist[i].title) {
if (tempProjectlist[i].title[g].t_id == tempRist[j].t_id) {
tempProjectlist[i].title[g].label_state = true
if (tempProjectlist[i].title[g].name == tempRist[j].title) {
tempProjectlist[i].title[g].current = parseInt(g)
sub_index = parseInt(g)
}
}
}
}
}
}
}
}
} else {
console.log('已修改保障项目')
if (type == 'zhuxian') {
if (tempMain_list.length > 0) {
for (let i in tempProjectlist) {
for (let j in tempMain_list) {
if (tempProjectlist[i].id == tempMain_list[j].id) {
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempMain_list[j].num
for (let g in tempProjectlist[i].title) {
for (let k in tempMain_list[j].title) {
if (tempMain_list[j].title[k].label_state) {
if (tempProjectlist[i].title[g].t_id == tempMain_list[j].title[k].t_id) {
tempProjectlist[i].title[g].label_state = true
tempProjectlist[i].title[g].current = tempMain_list[j].title[k].current
sub_index = tempMain_list[j].title[k].current
}
}
}
}
}
}
}
}
} else {
if (tempRist.length) {
for (let i in tempProjectlist) {
for (let j in tempRist) {
if (tempProjectlist[i].id == tempRist[j].id) {
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempRist[j].num
for (let g in tempProjectlist[i].title) {
for (let k in tempRist[j].title) {
if (tempRist[j].title[k].label_state) {
if (tempProjectlist[i].title[g].t_id == tempRist[j].title[k].t_id) {
tempProjectlist[i].title[g].label_state = true
tempProjectlist[i].title[g].current = tempRist[j].title[k].current
sub_index = tempRist[j].title[k].current
}
}
}
}
}
}
}
}
}
}
} else {
console.log('add')
=======
// if (that.data.temp_state) {
// console.log('edit')
// //edit_state3:代表是刚获取到信息是的结构,还是重新选择之后的数据结构
// if (edit_state3) {
// //获取到的信息结构
// if (type == 'zhuxian') {
// this.setData({
// focus: false
// })
// if (tempMain_list.length > 0) {
// for (let i in tempProjectlist) {
// for (let j in tempMain_list) {
// if (tempProjectlist[i].id == tempMain_list[j].id) {
// tempProjectlist[i].choose_status = true
// tempProjectlist[i].num = tempMain_list[j].num
// for (let g in tempProjectlist[i].title) {
// if (tempProjectlist[i].title[g].t_id == tempMain_list[j].t_id) {
// tempProjectlist[i].title[g].label_state = true
// if (tempProjectlist[i].title[g].name == tempMain_list[j].title) {
// tempProjectlist[i].title[g].current = parseInt(g)
// sub_index = parseInt(g)
// }
// }
// }
// }
// }
// }
// }
// } else {
// console.log('fjx')
// if (tempRist.length) {
// for (let i in tempProjectlist) {
// for (let j in tempRist) {
// if (tempProjectlist[i].id == tempRist[j].id) {
// console.log(tempRist[j])
// console.log(tempProjectlist[i])
// tempProjectlist[i].choose_status = true
// tempProjectlist[i].num = tempRist[j].num
// for (let g in tempProjectlist[i].title) {
// if (tempProjectlist[i].title[g].t_id == tempRist[j].t_id) {
// tempProjectlist[i].title[g].label_state = true
// if (tempProjectlist[i].title[g].name == tempRist[j].title) {
// tempProjectlist[i].title[g].current = parseInt(g)
// sub_index = parseInt(g)
// }
// }
// }
// }
// }
// }
// }
// }
// } else {
// if (type == 'zhuxian') {
// if (tempMain_list.length > 0) {
// for (let i in tempProjectlist) {
// for (let j in tempMain_list) {
// if (tempProjectlist[i].id == tempMain_list[j].id) {
// tempProjectlist[i].choose_status = true
// tempProjectlist[i].num = tempMain_list[j].num
// for (let g in tempProjectlist[i].title) {
// for (let k in tempMain_list[j].title) {
// if (tempMain_list[j].title[k].label_state) {
// if (tempProjectlist[i].title[g].t_id == tempMain_list[j].title[k].t_id) {
// tempProjectlist[i].title[g].label_state = true
// tempProjectlist[i].title[g].current = tempMain_list[j].title[k].current
// sub_index = tempMain_list[j].title[k].current
// }
// }
// }
// }
// }
// }
// }
// }
// } else {
// if (tempRist.length) {
// for (let i in tempProjectlist) {
// for (let j in tempRist) {
// if (tempProjectlist[i].id == tempRist[j].id) {
// tempProjectlist[i].choose_status = true
// tempProjectlist[i].num = tempRist[j].num
// for (let g in tempProjectlist[i].title) {
// for (let k in tempRist[j].title) {
// if (tempRist[j].title[k].label_state) {
// if (tempProjectlist[i].title[g].t_id == tempRist[j].title[k].t_id) {
// tempProjectlist[i].title[g].label_state = true
// tempProjectlist[i].title[g].current = tempRist[j].title[k].current
// sub_index = tempRist[j].title[k].current
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// } else {
// console.log('add')
>>>>>>> 08e3891927bfc37dbaf7242cae1b43e3d3b308c5
if (type == 'zhuxian') {
if (tempMain_list.length > 0) {
for (let i in tempProjectlist) {
for (let j in tempMain_list) {
if (tempProjectlist[i].id == tempMain_list[j].id) {
console.log(tempProjectlist[i])
console.log(tempMain_list[j].id)
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempMain_list[j].num
for (let g in tempProjectlist[i].title) {
for (let k in tempMain_list[j].title) {
if (tempMain_list[j].title[k].label_state) {
if (tempProjectlist[i].title[g].t_id == tempMain_list[j].title[k].t_id) {
tempProjectlist[i].title[g].label_state = true
tempProjectlist[i].title[g].current = tempMain_list[j].title[k].current
sub_index = tempMain_list[j].title[k].current
}
}
}
}
}
}
}
}
} else {
if (tempRist.length) {
for (let i in tempProjectlist) {
for (let j in tempRist) {
if (tempProjectlist[i].id == tempRist[j].id) {
tempProjectlist[i].choose_status = true
tempProjectlist[i].num = tempRist[j].num
console.log(tempProjectlist[i])
console.log(tempRist[j])
for (let g in tempProjectlist[i].title) {
// for (let k in tempRist[j].title) {
// if (tempRist[j].title[k].label_state) {
if (tempProjectlist[i].title[g].t_id == tempRist[j].t_id) {
tempProjectlist[i].title[g].label_state = true
// tempProjectlist[i].title[g].current = tempRist[j].title[k].current
// sub_index = tempRist[j].title[k].current
}
// }
// }
}
}
}
}
}
}
// }
wx.setNavigationBarTitle({
title: '选择保障项目',
})
console.log(tempProjectlist)
this.setData({
popup_state: true,
addType: type,
xulie: index,
showProjectlist: tempProjectlist,
sub_index: sub_index
})
},
// 调取保障项目接口
ensureProjectList() {
var main_risk = this.data.main_risk
let url = 'counselor/sageguard'
let params = {}
app.post(url, params).then((res) => {
if (res.data.code == 200) {
var projectlist = res.data.data.def;
for (var i = 0; i < projectlist.length; i++) {
projectlist[i].choose_status = false
for (var j = 0; j < projectlist[i].title.length; j++) {
projectlist[i].title[j].label_state = false
}
// projectlist[i].title[0].current = 0
// projectlist[i].title[0].label_state = true
}
this.setData({
projectlist: res.data.data.def,
showProjectlist: res.data.data.def
})
}
})
},
//保障项目单位
getUnit(e) {
var main_risk = this.data.main_risk
var index = e.currentTarget.dataset.index;
var sindex = e.currentTarget.dataset.sindex;
var projectlist = JSON.parse(JSON.stringify(this.data.showProjectlist));
var title = projectlist[index].title
for (var i = 0; i < title.length; i++) {
title[i].current = ''
if (title[i].current == '') {
title[i].label_state = false
}
}
projectlist[index].title[sindex].current = sindex
if (projectlist[index].title[sindex].current == sindex) {
projectlist[index].title[sindex].label_state = true
}
this.setData({
showProjectlist: projectlist,
sub_index: sindex
})
},
//保障项目金额
popupNum(e) {
var index = e.currentTarget.dataset.index;
var projectlist = JSON.parse(JSON.stringify(this.data.showProjectlist))
if (projectlist[index].choose_status) {
projectlist[index].num = e.detail.value
}
this.setData({
showProjectlist: projectlist
})
},
//选择保障项目
popupState(e) {
var index = e.currentTarget.dataset.index;
var projectlist = JSON.parse(JSON.stringify(this.data.showProjectlist))
projectlist[index].choose_status = !projectlist[index].choose_status;
this.setData({
showProjectlist: projectlist,
})
if (this.data.inforid != 0) {
edit_state: false;
edit_state2: false
}
},
//确认选择的推荐方案
confirmCase() {
// if (this.data.type == 'fujiaxian') {
// this.setData({
// edit_state2: false
// })
// } else {
// this.setData({
// edit_state: false
// })
// }
this.setData({
edit_state3:false
})
let index = this.data.xulie;
let type = this.data.addType;
var that = this
var main_array = []
var projectlist = Object.assign({}, this.data.projectlist)
for (var i = 0; i < projectlist.length; i++) {
if (projectlist[i].choose_status) {
main_array.push(projectlist[i])
}
}
if (main_array != '') {
wx.showToast({
title: '添加成功',
icon: 'none'
})
if (type == 'fujiaxian') {
let tempRist = that.data.risk_list;
console.log(tempRist)
tempRist[index]['mo'] = main_array;
that.setData({
risk_list: tempRist,
})
} else {
that.setData({
main_array: main_array,
})
}
}
setTimeout(function() {
that.ensureProjectList()
that.setData({
popup_state: false
})
wx.setNavigationBarTitle({
title: '添加保单',
})
}, 800)
},
//重组主险的保障项目
tempMain() {
var main_array = this.data.main_array
var warranty_one1 = []
for (var i = 0; i < main_array.length; i++) {
var temp = {}
for (var j = 0; j < main_array[i].title.length; j++) {
if (main_array[i].choose_status) {
if (main_array[i].title[j].label_state) {
temp.id = main_array[i].id
temp.name = main_array[i].name
temp.num = main_array[i].num
temp.title = main_array[i].title[j].name
temp.t_id = main_array[i].title[j].t_id
}
}
}
warranty_one1.push(temp)
this.setData({
guarantee: warranty_one1
})
}
},
//主险名称
addRiskName(e) {
var risk_list = this.data.risk_list
var index = e.currentTarget.dataset.index
risk_list[index].name = e.detail.value
this.setData({
risk_list: risk_list
})
},
//主险保障其
addRiskUnit(e) {
var risk_list = this.data.risk_list
var index = e.currentTarget.dataset.index
risk_list[index].num = e.detail.value
this.setData({
risk_list: risk_list
})
},
//重组附加险整体数据结构
tempAddRisk() {
var risk_list = this.data.risk_list
var sub_array = []
var temp_risk = this.data.risk_list;
var temp = this.data.risk_list;
for (var i = 0; i < temp.length; i++) {
for (var j = 0; j < temp[i].mo.length; j++) {
for (var k = 0; k < temp[i].mo[j].title.length; k++) {
if (temp[i].name != '') {
if (temp[i].mo[j].choose_status) {
if (temp[i].mo[j].title[k].label_state) {
temp_risk[i].name = temp[i].name
temp_risk[i].num = temp[i].num
temp_risk[i].title = temp[i].title
temp_risk[i].mo[j].t_id = temp[i].mo[j].title[k].t_id
temp_risk[i].mo[j].id = temp[i].mo[j].id
temp_risk[i].mo[j].name = temp[i].mo[j].name
temp_risk[i].mo[j].num = temp[i].mo[j].num
temp_risk[i].mo[j].title = temp[i].mo[j].title[k].name
}
}
}
}
}
console.log(temp_risk)
this.setData({
more: temp_risk
})
}
},
//选择受益人姓名
beneficiarySelect(e) {
if (this.data.inforid != 0) {
// this.setData({
// edit_state: true,
// edit_state2: true
// })
}
var index = e.currentTarget.dataset.mindex
var beneficiary_list = Object.assign({}, this.data.projectlist)
// 获取当前已选择的收益人
let tempBenefice = Object.assign({}, this.data.projectlist)
// 当前选择的收益人
// let nowPerson = beneficiary_list[index].name_array[e.detail.value];
// let nowPerson = beneficiary_list[index].beneficiary_name
let nowPerson = beneficiary_list[index].name
// 判断受益人是否已经添加
const add = tempBenefice.every((tempBenefice) => {
return tempBenefice != nowPerson
})
if (add) {
// beneficiary_list[index].beneficiary_name = nowPerson;
beneficiary_list[index].name = nowPerson;
tempBenefice.push(nowPerson)
console.log(tempBenefice)
} else {
wx.showToast({
title: '请不要重复添加受益人',
icon: 'none'
})
}
this.setData({
beneficiary_list: beneficiary_list,
beneficiaryList: tempBenefice
})
},
//添加收益比例
addUnit(e) {
var beneficiary_list = this.data.beneficiary_list;
beneficiary_list[beneficiary_list.length - 1].unit = e.detail.value;
if (beneficiary_list[beneficiary_list.length - 1].unit > 100) {
wx.showToast({
title: '请重新输入收益比例',
icon: 'none'
})
beneficiary_list[beneficiary_list.length - 1].unit = 0
}
this.setData({
beneficiary_list: beneficiary_list,
})
},
//添加收益比例
addUnit2(e) {
var beneficiary_list = this.data.beneficiary_list;
var index = e.currentTarget.dataset.index
beneficiary_list[index].unit = e.detail.value;
if (beneficiary_list[index].unit > 100) {
wx.showToast({
title: '请重新输入收益比例',
icon: 'none'
})
beneficiary_list[index].unit = 0
}
this.setData({
beneficiary_list: beneficiary_list,
})
},
//添加受益人名字
addPeople(e) {
var beneficiary_list = this.data.beneficiary_list;
var index = e.currentTarget.dataset.index
// beneficiary_list[beneficiary_list.length - 1].beneficiary_name = e.detail.value;
beneficiary_list[index].name = e.detail.value;
this.setData({
beneficiary_list: beneficiary_list,
})
},
//添加受益人
addPersons(e) {
var list = this.data.beneficiary_list;
var len = list.length
// if (list[len - 1].beneficiary_name == undefined) {
if (list[len - 1].name == undefined) {
wx.showToast({
title: '请输入受益人',
icon: 'none'
})
} else if (list[len - 1].unit == '') {
wx.showToast({
title: '请输入收益比',
icon: 'none'
})
} else {
list[len] = {
// name_array: this.data.insure,
// beneficiary_name:'',
name: '',
unit: ''
}
}
this.setData({
beneficiary_list: list
})
},
//添加受益人
addPersons2(e) {
var list = this.data.beneficiary_list;
var len = list.length
if (list[len - 1].name == undefined) {
wx.showToast({
title: '请输入受益人',
icon: 'none'
})
} else if (list[len - 1].unit == '') {
console.log('unit')
wx.showToast({
title: '请输入收益比',
icon: 'none'
})
} else {
list[len] = {
// name_array: this.data.insure,
name: '',
unit: ''
}
}
this.setData({
beneficiary_list: list
})
console.log(this.data.beneficiary_list)
},
//重组添加受益人
tempBeneficiary() {
var beneficiary_list = this.data.beneficiary_list
var len = beneficiary_list.length;
var tempfavoree1 = [];
for (var i = 0; i < beneficiary_list.length; i++) {
var temp = {}
if (beneficiary_list[i].unit != '') {
temp.name = beneficiary_list[i].name
temp.unit = beneficiary_list[i].unit;
}
tempfavoree1.push(temp)
this.setData({
tempfavoree: tempfavoree1
})
}
},
//删除收益人
deletebenefict(e) {
let index = e.currentTarget.dataset.index;
let tempbenefict = Object.assign({},this.data.beneficiary_list);
let beneficiaryList = Object.assign({},this.data.beneficiaryList);
// 获取当前选项的受益人
// let person = tempbenefict[index].beneficiary_name;
let person = tempbenefict[index].name;
tempbenefict.splice(index, 1);
if (person) beneficiaryList.splice(beneficiaryList.indexOf(person), 1)
this.setData({
beneficiaryList: beneficiaryList,
beneficiary_list: tempbenefict
})
},
//添加附加险
addRisk() {
if (this.data.inforid != 0) {
// this.setData({
// edit_state: false,
// edit_state2: false
// })
}
var risk_list = Object.assign({},this.data.risk_list);
var len = risk_list.length
risk_list[len] = {
name: '',
mo: [],
// project_time: '',
title: '',
num: ''
}
this.setData({
risk_list: risk_list
})
},
//删除附加险
deleteRisk(e) {
let index = e.currentTarget.dataset.index;
let risk_list = Object.assign({},this.data.risk_list);
risk_list.splice(index, 1);
this.setData({
risk_list: risk_list
})
},
//上传图片
uploadImage() {
let that = this;
wx.chooseImage({
count: 6,
sizeType: ['original', 'compressed'],
success: function(res) {
let successUp = 0; //成功个数
let failUp = 0; //失败个数
let i = 0; //第几个
let tempFilePaths = res.tempFilePaths //总文件
let length = res.tempFilePaths.length //总共个数
wx.showNavigationBarLoading()
wx.showLoading({
title: '上传中',
})
that.uploadAllfile(tempFilePaths, successUp, failUp, i, length)
},
fail: function(res) {}
})
},
//上传图片接口调取
uploadAllfile(filePaths, successUp, failUp, i, length) {
let that = this
let strtime = +new Date()
wx.uploadFile({
url: 'https://insurance.w.broteam.cn/pubilc/upload', //仅为示例,非真实的接口地址
filePath: filePaths[i],
name: 'picurl',
formData: {
'strtime': strtime,
'token': app.strTime(strtime)
},
success: function(res) {
wx.hideNavigationBarLoading()
wx.hideLoading()
if (res.statusCode == '200') {
let imgTemp = that.data.imgs;
let curImg = JSON.parse(res.data).data.picurl;
if (imgTemp.length < 6) {
imgTemp.push("http://" + curImg)
that.setData({
imgs: imgTemp
})
wx.showToast({
title: '上传成功',
icon: 'none',
duration: 2000,
})
} else {
wx.showToast({
title: '图片上限6张',
icon: 'none',
duration: 2000,
})
}
} else {
wx.showModal({
title: '提示',
content: res.msg,
showCancel: false
})
}
},
fail: function(res) {
wx.hideNavigationBarLoading()
wx.hideLoading()
},
complete: () => {
i++;
if (i == length) {
} else { //递归调用uploadDIY函数
this.uploadAllfile(filePaths, successUp, failUp, i, length);
}
},
})
},
//预览图片
viewImg(e) {
var imgs = this.data.imgs
var current = e.currentTarget.dataset.index
wx.previewImage({
//当前显示图片
current: imgs[current],
//所有图片
urls: imgs
})
},
//删除图片
deleteImg(e) {
var imgs = this.data.imgs;
var index = e.currentTarget.dataset.index;
imgs.splice(index, 1);
this.setData({
imgs: imgs
});
},
//保障期
warrantyTwo(e) {
if (this.data.inforid != 0) {
// this.setData({
// edit_state: false,
// edit_state2: false
// })
}
var guarantee_name = e.detail.value
var warranty_two = this.data.warranty_two
var impletion_time = this.data.impletion_time
warranty_two.num = guarantee_name
this.setData({
guarantee_name: e.detail.value,
warranty_two: warranty_two
})
this.countImpletionTime2()
},
//选择各项单位
selectUnit(e) {
var unit = e.currentTarget.dataset.unit
this.setData({
unit: unit,
})
var warranty_two = this.data.warranty_two
if (unit == '终身') {
warranty_two.num = ''
this.setData({
warranty_info: '',
warranty_state: true
})
} else {
this.setData({
warranty_state: false
})
}
this.setData({
warranty_two: warranty_two
})
this.countImpletionTime2()
},
//重组保障期数据格式
tempWarranty() {
var guarantee_name = this.data.guarantee_name
var unit = this.data.unit
var warranty_two = this.data.warranty_two
warranty_two.num = guarantee_name
warranty_two.title = unit
this.setData({
warranty_two: warranty_two
})
},
//计算缴费期满日,主线保障其
countImpletionTime2() {
var guarantee_name = parseInt(this.data.guarantee_name)
var unit = this.data.unit
var compact_time = this.data.compact_time
var year = parseInt(new Date(compact_time).getFullYear())
var month = parseInt(new Date(compact_time).getMonth() + 1)
var day = parseInt(new Date(compact_time).getDate())
var warranty_one = this.data.warranty_one
var tempbirth_time = ''
var birthday = ''
var birthday_year = parseInt(new Date(birthday).getFullYear())
if (compact_time == '') {
wx.showToast({
title: '请选择合同生效日',
icon: 'none'
})
} else {
if (unit == '年') {
var temp_year = (year + guarantee_name)
var temp_day = day - 1
if (month < 10) month = "0" + month;
if (temp_day < 10) temp_day = "0" + temp_day;
warranty_one = temp_year + '-' + month + '-' + temp_day
} else if (unit == '岁') {
var temp_year = (birthday_year + guarantee_name - 1)
var temp_year2 = (birthday_year + guarantee_name)
var temp_month = month
if (temp_month < 10) temp_month = "0" + temp_month;
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
warranty_one = temp_year2 + '-' + month + '-' + day
} else if (unit == '终身') {
warranty_one = '终身'
}
this.setData({
warranty_one: warranty_one
})
}
},
//缴费时长
burningTime(e) {
if (this.data.inforid != 0) {
// this.setData({
// edit_state: false,
// edit_state2: false,
// })
}
var time_name = e.detail.value
var long_money = this.data.long_money
long_money.num = time_name
this.setData({
time_name: time_name,
long_money: long_money
})
this.countImpletionTime()
},
selectUnit2(e) {
var unit = e.currentTarget.dataset.unit
this.setData({
unit2: unit
})
var long_money = this.data.long_money
if (unit == '终身') {
long_money.num = ''
this.setData({
warranty_info1: '',
warranty_state1: true
})
} else {
this.setData({
warranty_state1: false
})
}
this.setData({
long_money: long_money
})
this.countImpletionTime()
},
//重组缴费时长数据格式
tempburningTime() {
var time_name = this.data.time_name
var unit = this.data.unit2
var long_money = this.data.long_money
long_money.num = time_name
long_money.title = unit
this.setData({
long_money: long_money
})
},
//计算缴费期满日,主线保障其
countImpletionTime() {
var time_name = parseInt(this.data.time_name)
var unit = this.data.unit2
var compact_time = this.data.compact_time
var year = parseInt(new Date(compact_time).getFullYear())
var month = parseInt(new Date(compact_time).getMonth() + 1)
var day = parseInt(new Date(compact_time).getDate())
var impletion_time = this.data.impletion_time
var tempbirth_time = ''
var birthday = ''
var birthday_year = parseInt(new Date(birthday).getFullYear())
if (compact_time == '') {
wx.showToast({
title: '请选择合同生效日',
icon: 'none'
})
} else {
if (unit == '年') {
var temp_year = (year + time_name)
var temp_day = day - 1
if (month < 10) month = "0" + month;
if (temp_day < 10) temp_day = "0" + temp_day;
impletion_time = temp_year + '-' + month + '-' + temp_day
} else if (unit == '岁') {
var temp_year = (birthday_year + time_name - 1)
var temp_year2 = (birthday_year + time_name)
var temp_month = month
if (temp_month < 10) temp_month = "0" + temp_month;
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
impletion_time = temp_year + '-' + temp_month + '-' + day
} else if (unit == '终身') {
impletion_time = '终身缴费'
}
this.setData({
impletion_time: impletion_time,
})
}
},
//缴费方式
selectUnit3(e) {
var unit = e.currentTarget.dataset.unit
this.setData({
unit3: unit,
type_money: unit
})
},
//附加险保障其
selectUnit4(e) {
var unit = e.currentTarget.dataset.unit;
let index = e.currentTarget.dataset.index;
let risk_list = Object.assign({},this.data.risk_list);
risk_list[index].title = unit
if (risk_list[index].title == '终身') {
risk_list[index].num = ''
this.setData({
risk_state: true
})
} else {
this.setData({
risk_state: false
})
}
this.setData({
risk_list: risk_list
})
},
//家庭成员
familyMember(id) {
var FamilyId = this.data.FamilyId
let url = 'counselor/familyname'
let params = {
FamilyId: FamilyId || id,
}
app.post(url, params).then((res) => {
// 受益人数组
// var beneficiary_list = this.data.beneficiary_list
// for (var i in beneficiary_list) {
// beneficiary_list[i].name_array = res.data.data.list
// }
if (res.data.code == 200) {
this.setData({
insure: res.data.data.list,
recognizee: res.data.data.list,
// beneficiary_list: beneficiary_list,
})
}
})
},
//设置缓存
setStorge(e) {
this.tempBeneficiary()
this.tempWarranty()
this.tempburningTime()
this.tempMain()
this.tempAddRisk()
var favoree = JSON.stringify(this.data.tempfavoree)
var warranty_two = JSON.stringify(this.data.warranty_two)
var long_money = JSON.stringify(this.data.long_money)
var more = JSON.stringify(this.data.more)
var guarantee = JSON.stringify(this.data.guarantee)
var warn = ""; //弹框时提示的内容
var in_num = this.data.in_num
var firm = this.data.firm
var applicant = this.data.applicant_name
var recognizee = this.data.recognizee_name
var main_risks = this.data.main_risks
var coverage = this.data.coverage
var year_money = this.data.year_money
var compact_time = this.data.compact_time
var impletion_time = this.data.impletion_time
var warranty_one = JSON.stringify(this.data.warranty_one)
var type_money = this.data.type_money
var bank = this.data.bank
var bank_num = this.data.bank_num
var picurl = JSON.stringify(this.data.imgs)
let url = 'counselor/inforsave'
let params = {
// InfoId: this.data.inforid,
def_id: this.data.def_id,
in_num: in_num,
firm: firm,
applicant: applicant,
recognizee: recognizee,
favoree: favoree,
main_risks: main_risks,
coverage: coverage,
guarantee: guarantee,
year_money: year_money,
warranty_two: warranty_two,
compact_time: compact_time,
impletion_time: impletion_time,
warranty_one: warranty_one,
long_money: long_money,
type_money: type_money,
bank: bank,
bank_num: bank_num,
more: more,
picurl: picurl,
}
app.post(url, params).then((res) => {
if (res.data.code == 200) {
wx.navigateBack({
delta: 1,
})
this.setData({
storge_state: true
})
var storge_state = true
wx.setStorageSync('storge_state', storge_state)
}
})
},
//获取缓存内容
getStorage() {
let url = 'counselor/inforCopy'
let params = {
def_id: this.data.def_id,
}
app.post(url, params).then((res) => {
console.log(res)
if (res.data.code == 200) {
var warranty_two = res.data.data.def.warranty_two
var unit = this.data.unit
unit = warranty_two.title
var long_money = res.data.data.def.long_money
var unit2 = this.data.unit2
unit2 = long_money.title
var type_money = res.data.data.def.type_money
var unit3 = this.data.unit3
unit3 = type_money
var beneficiary_list = res.data.data.def.favoree
for (var obj in beneficiary_list) {
if (beneficiary_list[obj] != '') {
beneficiary_list[obj].name = beneficiary_list[obj].name
beneficiary_list[obj].unit = beneficiary_list[obj].unit
// beneficiary_list[obj].name_array = this.data.insure
} else {
beneficiary_list[0].name = ''
beneficiary_list[0].unit = ''
// beneficiary_list[obj].name_array = this.data.insure
}
}
this.setData({
imgs: res.data.data.def.picurl,
type_money: res.data.data.def.type_money,
unit3: unit3,
year_money: res.data.data.def.year_money,
long_money: res.data.data.def.long_money,
unit2: unit2,
in_num: res.data.data.def.in_num,
firm: res.data.data.def.firm,
main_risks: res.data.data.def.main_risks,
coverage: res.data.data.def.coverage,
main_array: res.data.data.def.guarantee,
applicant_name: res.data.data.def.applicant,
recognizee_name: res.data.data.def.recognizee,
warranty_one: res.data.data.def.warranty_one,
warranty_two: res.data.data.def.warranty_two,
unit: unit,
compact_time: res.data.data.def.compact_time,
impletion_time: res.data.data.def.impletion_time,
bank: res.data.data.def.bank,
bank_num: res.data.data.def.bank_num,
risk_list: res.data.data.def.more,
beneficiary_list: beneficiary_list,
// edit_state: true,
// edit_state2: true,
// edit_state3: true,
temp_state: true
})
}
})
},
//完成保单添加
listVerify(e) {
if (this.data.inforid == 0 || this.data.inforid == undefined) {
this.tempBeneficiary()
this.tempWarranty()
this.tempburningTime()
this.tempMain()
this.tempAddRisk()
if (this.data.tempfavoree.length == 1) {
var favoree = JSON.stringify(this.data.beneficiary_list)
} else {
var favoree = JSON.stringify(this.data.tempfavoree)
}
var warranty_two = JSON.stringify(this.data.warranty_two)
var long_money = JSON.stringify(this.data.long_money)
var more = JSON.stringify(this.data.more)
var guarantee = JSON.stringify(this.data.guarantee)
} else if (this.data.edit_state || this.data.edit_state2 || wx.getStorageSync('storge_state')) {
var favoree = JSON.stringify(this.data.beneficiary_list)
var warranty_two = JSON.stringify(this.data.warranty_two)
var long_money = JSON.stringify(this.data.long_money)
var more = JSON.stringify(this.data.risk_list)
var guarantee = JSON.stringify(this.data.main_array)
} else {
this.tempBeneficiary()
this.tempWarranty()
this.tempburningTime()
this.tempMain()
this.tempAddRisk()
if (this.data.tempfavoree.length == 1) {
var favoree = JSON.stringify(this.data.beneficiary_list)
} else {
var favoree = JSON.stringify(this.data.tempfavoree)
}
var warranty_two = JSON.stringify(this.data.warranty_two)
var long_money = JSON.stringify(this.data.long_money)
var more = JSON.stringify(this.data.more)
var guarantee = JSON.stringify(this.data.guarantee)
}
var warn = ""; //弹框时提示的内容
var flag = true; //判断信息输入是否完整判断弹窗
var in_num = e.detail.value.policy_num
var firm = e.detail.value.company;
var applicant = this.data.applicant_name
var recognizee = this.data.recognizee_name
var main_risks = e.detail.value.main_risks
var coverage = e.detail.value.coverage
var year_money = e.detail.value.year_money
var compact_time = this.data.compact_time
var impletion_time = this.data.impletion_time
var warranty_one = JSON.stringify(this.data.warranty_one)
var type_money = this.data.type_money
var bank = e.detail.value.bank
var bank_num = e.detail.value.bank_num
var picurl = JSON.stringify(this.data.imgs)
var continue1 = e.detail.target.dataset.type
var complete = e.detail.target.dataset.type
// else if(firm == '') {
// warn = '请输入所属公司!'
// } else if (applicant == '') {
// warn = '请输入投保人!'
// } else if (recognizee == '') {
// warn = '请输入被保险人!'
// } else if (favoree == '') {
// warn = '请输入受益人!'
// } else if (bank_num == '') {
// warn = '请输入续费账号!'
// } else if (!(/^[0-9]+.?[0-9]*/.test(bank_num))) {
// warn = '请输入正确续费账号!'
// } else if (impletion_time == '') {
// warn = '请输入缴费期满日!'
// } else if (warranty_one == '') {
// warn = '请输入主险保障期!'
// } else if (more == '') {
// warn = '请输入附加险!'
// } else if (picurl.length == 2) {
// warn = '请选择图片!'
// } else if (compact_time == '') {
// warn = '请输入合同生效日!'
// } else if (warranty_two.num == '') {
// warn = '请输入保障期!'
// } else if (long_money.num == '') {
// warn = '请输入缴费时长!'
// } else if (type_money == '') {
// warn = '请输入缴费方式!'
// } else if (bank == '') {
// warn = '请输入续费银行!'
// }
if (in_num == '') {
warn = '请输入保单号!'
} else if (main_risks == '') {
warn = '请输入主险名称!'
} else if (coverage == '') {
warn = '请输入主险基本保额!'
} else if (year_money == '') {
warn = '请输入保费!'
} else {
flag = false
// 添加、修改保单接口调取
let url = 'counselor/inforuodate'
let params = {
InfoId: this.data.inforid,
def_id: this.data.def_id,
in_num: in_num,
firm: firm,
applicant: applicant,
recognizee: recognizee,
favoree: favoree,
main_risks: main_risks,
coverage: coverage,
guarantee: guarantee,
year_money: year_money,
warranty_two: warranty_two,
compact_time: compact_time,
impletion_time: impletion_time,
warranty_one: warranty_one,
long_money: long_money,
type_money: type_money,
bank: bank,
bank_num: bank_num,
more: more,
picurl: picurl,
}
app.post(url, params).then((res) => {
if (res.data.code == 200) {
if (continue1 == 'continue1') {
this.goTop()
wx.showToast({
title: '添加成功',
icon: 'none',
duration: 2000,
})
this.setData({
inforid: 0,
in_num: '',
firm: '',
applicant_name: '',
// recognizee_name: '',
beneficiary_list: [{
// name_array: [],
name: '',
unit: ''
}],
coverage: '',
main_risks: '',
main_array: '',
year_money: '',
compact_time: '',
warranty_two: '',
long_money: '',
bank: '',
bank_num: '',
impletion_time: '',
warranty_one: '',
risk_list: [{
name: '',
mo: [],
// project_time: '',
title: '',
num: ''
}],
imgs: '',
unit: '',
unit2: '',
unit3: '',
unit4: '',
})
} else if (complete == 'complete') {
wx.showToast({
title: '添加成功',
icon: 'none',
duration: 2000,
})
wx.navigateBack({
delta: 1,
})
}
}
})
}
if (flag == true) {
wx.showToast({
title: warn,
icon: 'none'
})
}
},
//获取编辑保单接口
getlistVerify(id) {
let url = 'counselor/infordef'
let params = {
InfoId: this.data.inforid || id,
}
app.post(url, params).then((res) => {
console.log(res)
if (res.data.code == 200) {
var warranty_two = res.data.data.def.warranty_two
var unit = this.data.unit
unit = warranty_two.title
var long_money = res.data.data.def.long_money
var unit2 = this.data.unit2
unit2 = long_money.title
var type_money = res.data.data.def.type_money
var unit3 = this.data.unit3
unit3 = type_money
var beneficiary_list = res.data.data.def.favoree
for (var obj in beneficiary_list) {
if (beneficiary_list[obj] != '') {
beneficiary_list[obj].name = beneficiary_list[obj].name
beneficiary_list[obj].unit = beneficiary_list[obj].unit
// beneficiary_list[obj].name_array = this.data.insure
}
}
var risk_list = res.data.data.def.more
var projectlist = Object.assign({},this.data.projectlist)
for (var i = 0; i < risk_list.length; i++) {
for (var j = 0; j < projectlist.length; j++) {
for (var k = 0; k < projectlist[j].title.length; k++) {
if (risk_list[i].id == projectlist[j].id) {
if (risk_list[i].title == projectlist[j].title[k].name) {
var title = {}
title.name = projectlist[j].title[k]
}
}
}
}
}
var warranty_two = res.data.data.def.warranty_two
var guarantee_name = warranty_two.num
var long_money = res.data.data.def.long_money
var time_name = long_money.num
this.setData({
imgs: res.data.data.def.picurl,
type_money: res.data.data.def.type_money,
unit3: unit3,
year_money: res.data.data.def.year_money,
long_money: res.data.data.def.long_money,
unit2: unit2,
in_num: res.data.data.def.in_num,
firm: res.data.data.def.firm,
main_risks: res.data.data.def.main_risks,
coverage: res.data.data.def.coverage,
main_array: res.data.data.def.guarantee,
applicant_name: res.data.data.def.applicant,
recognizee_name: res.data.data.def.recognizee,
warranty_one: res.data.data.def.warranty_one,
warranty_two: res.data.data.def.warranty_two,
unit: unit,
compact_time: res.data.data.def.compact_time,
impletion_time: res.data.data.def.impletion_time,
bank: res.data.data.def.bank,
bank_num: res.data.data.def.bank_num,
risk_list: risk_list,
beneficiary_list: beneficiary_list,
// edit_state: true,
// edit_state2: true,
// edit_state3: true,
temp_state: true,
guarantee_name: guarantee_name,
time_name: time_name,
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.ensureProjectList()
let that = this;
options.inforid ? (that.getlistVerify(options.inforid), that.setData({
inforid: options.inforid,
// edit_state: true,
// edit_state2: true,
}), wx.setNavigationBarTitle({
title: '编辑保单',
})) : ""
options.def_id ? that.setData({
def_id: options.def_id,
}) : ""
options.name ? (that.setData({
recognizee_name: options.name
})) : '';
options.FamilyId ? (that.familyMember(options.FamilyId), that.setData({
FamilyId: options.FamilyId
})) : '';
if (wx.getStorageSync('storge_state') && options.inforid == undefined) {
this.getStorage()
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file