作者 朱振飞

修改逻辑

... ... @@ -21,6 +21,8 @@ Page({
name: ['受益人1', '受益人2'],
unit: ''
}],
// 已选择的受益人
beneficiaryList:[],
beneficiaryindex: -1,
beneficiary_name: '',
imgs: [],
... ... @@ -35,7 +37,8 @@ Page({
risk_list:[{
name:'',
projectlist:[],
project_time:''
project_time:'',
time: 1
}],
main_array:[]
... ... @@ -252,22 +255,41 @@ Page({
beneficiarySelect(e) {
// console.log(e)
var index = e.currentTarget.dataset.mindex
var beneficiary_list = this.data.beneficiary_list;
for (var i = 0; i < beneficiary_list.length; i++) {
for (var j = 0; j < beneficiary_list[i].name.length; j++) {
var beneficiary_name = beneficiary_list[i].name[e.detail.value]
beneficiary_list[index].beneficiary_name = beneficiary_name
// console.log(beneficiary_list)
}
var beneficiary_list = Object.assign(this.data.beneficiary_list,{});
// 获取当前已选择的收益人
let tempBenefice = Object.assign(this.data.beneficiaryList,{})
// 当前选择的收益人
let nowPerson = beneficiary_list[index].name[e.detail.value];
// 判断受益人是否已经添加
const add = tempBenefice.every((tempBenefice)=>{
return tempBenefice != nowPerson
})
console.log()
if(add){
beneficiary_list[index].beneficiary_name = nowPerson;
tempBenefice.push(nowPerson)
}else{
wx.showToast({
title: '请不要重复添加受益人',
icon: 'none'
})
}
// for (var i = 0; i < beneficiary_list.length; i++) {
// for (var j = 0; j < beneficiary_list[i].name.length; j++) {
// var beneficiary_name =
// beneficiary_list[index].beneficiary_name = beneficiary_list[i].name[e.detail.value]
// // console.log(beneficiary_list)
// }
// }
// let tempRangArry = this.data.rang_beneficiary;
// tempRangArry[index] = beneficiary_list[index].name[e.detail.value]
// console.log(tempRangArry)
this.setData({
beneficiaryindex: e.detail.value,
beneficiary_list: beneficiary_list
beneficiary_list: beneficiary_list,
beneficiaryList: tempBenefice
})
},
... ... @@ -306,6 +328,21 @@ Page({
beneficiary_list: list
})
},
// 删除受益人
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;
tempbenefict.splice(index, 1);
if (person) beneficiaryList.splice(beneficiaryList.indexOf(person),1)
this.setData({
beneficiaryList: beneficiaryList,
beneficiary_list: tempbenefict
})
},
//添加附加险
addRisk(){
... ... @@ -320,10 +357,15 @@ Page({
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;
... ... @@ -449,14 +491,15 @@ Page({
},
selectUnit4(e) {
var unit = e.currentTarget.dataset.unit
var unit = e.currentTarget.dataset.unit;
let index = e.currentTarget.dataset.index;
let risk_list = Object.assign(this.data.risk_list,{});
risk_list[index].time = unit
this.setData({
unit4: unit
risk_list: risk_list
})
},
// 保单验证&&上传保单
listVerify(e) {
// this.insureItem()
... ...
... ... @@ -105,8 +105,9 @@
<input class='income_input' type='text' placeholder='受益比例%' name='beneficiary' value='{{item.unit}}' bindinput='addUnit'></input>
</view>
</view>
<view class='iconfont icon-guanbi shouyi' bindtap='deletebenefict' wx:if="{{its>0}}" data-index='{{its}}'></view>
</view>
<view class='iconfont icon-wuuiconxiangjifangda add_person' data-mindex='{{its}}' data-sindex='{{index}}' bindtap='addPersons'>
<view class='iconfont icon-wuuiconxiangjifangda add_person' wx:if="{{beneficiary_list.length<beneficiary_list[0].name.length}}" data-mindex='{{its}}' data-sindex='{{index}}' bindtap='addPersons'>
<text>添加受益人</text>
</view>
</view>
... ... @@ -281,7 +282,7 @@
<!-- wx:for='{{addlist}}' wx:key='' -->
<view class='risk_box'>
<view class='risk_item' wx:for='{{risk_list}}' wx:key=''>
<view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' data-index='{{index}}'></view>
<view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' wx:if="{{index>0}}" data-index='{{index}}'></view>
<view class='item_list'>
<view class='list_title project'>附加险名称</view>
<view class='list_input'>
... ... @@ -317,9 +318,9 @@
<input type='text' placeholder='请输入' name='beneficiary' value='{{listdetail.favoree}}'></input>
</view>
<view class='list_label_box'>
<view class="list_label_item {{unit4==10?'list_label_active':''}}" bindtap='selectUnit4' data-unit='10'>年</view>
<view class="list_label_item {{unit4==11?'list_label_active':''}}" bindtap='selectUnit4' data-unit='11'>岁 </view>
<view class="list_label_item {{unit4==12?'list_label_active':''}}" bindtap='selectUnit4' data-unit='12'>终身</view>
<view class="list_label_item {{item.time==10?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='10'>年</view>
<view class="list_label_item {{item.time==11?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='11'>岁 </view>
<view class="list_label_item {{item.time==12?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='12'>终身</view>
</view>
</view>
</view>
... ...
... ... @@ -481,3 +481,9 @@ page {
color: #999;
margin-left: 15rpx;
}
.icon-guanbi.shouyi{
position: unset;
margin-left: 22rpx;
font-size: 22rpx;
align-self: flex-start;
}
\ No newline at end of file
... ...