作者 朱振飞

修改逻辑

@@ -21,6 +21,8 @@ Page({ @@ -21,6 +21,8 @@ Page({
21 name: ['受益人1', '受益人2'], 21 name: ['受益人1', '受益人2'],
22 unit: '' 22 unit: ''
23 }], 23 }],
  24 + // 已选择的受益人
  25 + beneficiaryList:[],
24 beneficiaryindex: -1, 26 beneficiaryindex: -1,
25 beneficiary_name: '', 27 beneficiary_name: '',
26 imgs: [], 28 imgs: [],
@@ -35,7 +37,8 @@ Page({ @@ -35,7 +37,8 @@ Page({
35 risk_list:[{ 37 risk_list:[{
36 name:'', 38 name:'',
37 projectlist:[], 39 projectlist:[],
38 - project_time:'' 40 + project_time:'',
  41 + time: 1
39 }], 42 }],
40 main_array:[] 43 main_array:[]
41 44
@@ -252,22 +255,41 @@ Page({ @@ -252,22 +255,41 @@ Page({
252 beneficiarySelect(e) { 255 beneficiarySelect(e) {
253 // console.log(e) 256 // console.log(e)
254 var index = e.currentTarget.dataset.mindex 257 var index = e.currentTarget.dataset.mindex
255 - var beneficiary_list = this.data.beneficiary_list;  
256 - for (var i = 0; i < beneficiary_list.length; i++) {  
257 - for (var j = 0; j < beneficiary_list[i].name.length; j++) {  
258 - var beneficiary_name = beneficiary_list[i].name[e.detail.value]  
259 - beneficiary_list[index].beneficiary_name = beneficiary_name  
260 - // console.log(beneficiary_list)  
261 - } 258 + var beneficiary_list = Object.assign(this.data.beneficiary_list,{});
  259 + // 获取当前已选择的收益人
  260 + let tempBenefice = Object.assign(this.data.beneficiaryList,{})
  261 + // 当前选择的收益人
  262 + let nowPerson = beneficiary_list[index].name[e.detail.value];
  263 + // 判断受益人是否已经添加
  264 + const add = tempBenefice.every((tempBenefice)=>{
  265 + return tempBenefice != nowPerson
  266 + })
  267 + console.log()
  268 + if(add){
  269 + beneficiary_list[index].beneficiary_name = nowPerson;
  270 + tempBenefice.push(nowPerson)
  271 + }else{
  272 + wx.showToast({
  273 + title: '请不要重复添加受益人',
  274 + icon: 'none'
  275 + })
262 } 276 }
  277 + // for (var i = 0; i < beneficiary_list.length; i++) {
  278 + // for (var j = 0; j < beneficiary_list[i].name.length; j++) {
  279 + // var beneficiary_name =
  280 +
  281 + // beneficiary_list[index].beneficiary_name = beneficiary_list[i].name[e.detail.value]
  282 + // // console.log(beneficiary_list)
  283 + // }
  284 + // }
263 285
264 // let tempRangArry = this.data.rang_beneficiary; 286 // let tempRangArry = this.data.rang_beneficiary;
265 // tempRangArry[index] = beneficiary_list[index].name[e.detail.value] 287 // tempRangArry[index] = beneficiary_list[index].name[e.detail.value]
266 // console.log(tempRangArry) 288 // console.log(tempRangArry)
267 289
268 this.setData({ 290 this.setData({
269 - beneficiaryindex: e.detail.value,  
270 - beneficiary_list: beneficiary_list 291 + beneficiary_list: beneficiary_list,
  292 + beneficiaryList: tempBenefice
271 }) 293 })
272 }, 294 },
273 295
@@ -306,6 +328,21 @@ Page({ @@ -306,6 +328,21 @@ Page({
306 beneficiary_list: list 328 beneficiary_list: list
307 }) 329 })
308 }, 330 },
  331 + // 删除受益人
  332 + deletebenefict(e){
  333 + let index = e.currentTarget.dataset.index;
  334 + let tempbenefict = Object.assign(this.data.beneficiary_list, {});
  335 + let beneficiaryList = Object.assign(this.data.beneficiaryList,{});
  336 + // 获取当前选项的受益人
  337 + let person = tempbenefict[index].beneficiary_name;
  338 + tempbenefict.splice(index, 1);
  339 + if (person) beneficiaryList.splice(beneficiaryList.indexOf(person),1)
  340 +
  341 + this.setData({
  342 + beneficiaryList: beneficiaryList,
  343 + beneficiary_list: tempbenefict
  344 + })
  345 + },
309 346
310 //添加附加险 347 //添加附加险
311 addRisk(){ 348 addRisk(){
@@ -320,10 +357,15 @@ Page({ @@ -320,10 +357,15 @@ Page({
320 risk_list: risk_list 357 risk_list: risk_list
321 }) 358 })
322 }, 359 },
323 -  
324 -  
325 -  
326 - 360 + //删除附加险
  361 + deleteRisk(e) {
  362 + let index = e.currentTarget.dataset.index;
  363 + let risk_list = Object.assign(this.data.risk_list, {});
  364 + risk_list.splice(index, 1);
  365 + this.setData({
  366 + risk_list: risk_list
  367 + })
  368 + },
327 //上传图片 369 //上传图片
328 uploadImage() { 370 uploadImage() {
329 let that = this; 371 let that = this;
@@ -449,14 +491,15 @@ Page({ @@ -449,14 +491,15 @@ Page({
449 }, 491 },
450 492
451 selectUnit4(e) { 493 selectUnit4(e) {
452 - var unit = e.currentTarget.dataset.unit 494 + var unit = e.currentTarget.dataset.unit;
  495 + let index = e.currentTarget.dataset.index;
  496 + let risk_list = Object.assign(this.data.risk_list,{});
  497 + risk_list[index].time = unit
453 this.setData({ 498 this.setData({
454 - unit4: unit 499 + risk_list: risk_list
455 }) 500 })
456 }, 501 },
457 502
458 -  
459 -  
460 // 保单验证&&上传保单 503 // 保单验证&&上传保单
461 listVerify(e) { 504 listVerify(e) {
462 // this.insureItem() 505 // this.insureItem()
@@ -105,8 +105,9 @@ @@ -105,8 +105,9 @@
105 <input class='income_input' type='text' placeholder='受益比例%' name='beneficiary' value='{{item.unit}}' bindinput='addUnit'></input> 105 <input class='income_input' type='text' placeholder='受益比例%' name='beneficiary' value='{{item.unit}}' bindinput='addUnit'></input>
106 </view> 106 </view>
107 </view> 107 </view>
  108 + <view class='iconfont icon-guanbi shouyi' bindtap='deletebenefict' wx:if="{{its>0}}" data-index='{{its}}'></view>
108 </view> 109 </view>
109 - <view class='iconfont icon-wuuiconxiangjifangda add_person' data-mindex='{{its}}' data-sindex='{{index}}' bindtap='addPersons'> 110 + <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'>
110 <text>添加受益人</text> 111 <text>添加受益人</text>
111 </view> 112 </view>
112 </view> 113 </view>
@@ -281,7 +282,7 @@ @@ -281,7 +282,7 @@
281 <!-- wx:for='{{addlist}}' wx:key='' --> 282 <!-- wx:for='{{addlist}}' wx:key='' -->
282 <view class='risk_box'> 283 <view class='risk_box'>
283 <view class='risk_item' wx:for='{{risk_list}}' wx:key=''> 284 <view class='risk_item' wx:for='{{risk_list}}' wx:key=''>
284 - <view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' data-index='{{index}}'></view> 285 + <view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' wx:if="{{index>0}}" data-index='{{index}}'></view>
285 <view class='item_list'> 286 <view class='item_list'>
286 <view class='list_title project'>附加险名称</view> 287 <view class='list_title project'>附加险名称</view>
287 <view class='list_input'> 288 <view class='list_input'>
@@ -317,9 +318,9 @@ @@ -317,9 +318,9 @@
317 <input type='text' placeholder='请输入' name='beneficiary' value='{{listdetail.favoree}}'></input> 318 <input type='text' placeholder='请输入' name='beneficiary' value='{{listdetail.favoree}}'></input>
318 </view> 319 </view>
319 <view class='list_label_box'> 320 <view class='list_label_box'>
320 - <view class="list_label_item {{unit4==10?'list_label_active':''}}" bindtap='selectUnit4' data-unit='10'>年</view>  
321 - <view class="list_label_item {{unit4==11?'list_label_active':''}}" bindtap='selectUnit4' data-unit='11'>岁 </view>  
322 - <view class="list_label_item {{unit4==12?'list_label_active':''}}" bindtap='selectUnit4' data-unit='12'>终身</view> 321 + <view class="list_label_item {{item.time==10?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='10'>年</view>
  322 + <view class="list_label_item {{item.time==11?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='11'>岁 </view>
  323 + <view class="list_label_item {{item.time==12?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='12'>终身</view>
323 </view> 324 </view>
324 </view> 325 </view>
325 </view> 326 </view>
@@ -481,3 +481,9 @@ page { @@ -481,3 +481,9 @@ page {
481 color: #999; 481 color: #999;
482 margin-left: 15rpx; 482 margin-left: 15rpx;
483 } 483 }
  484 +.icon-guanbi.shouyi{
  485 + position: unset;
  486 + margin-left: 22rpx;
  487 + font-size: 22rpx;
  488 + align-self: flex-start;
  489 +}