作者 朱振飞

保险新增修改接口

@@ -32,12 +32,12 @@ Page({ @@ -32,12 +32,12 @@ Page({
32 applicant_name: '', 32 applicant_name: '',
33 recognizee_name: '', 33 recognizee_name: '',
34 rang_beneficiary: [], 34 rang_beneficiary: [],
35 -  
36 risk_list:[{ 35 risk_list:[{
37 name:'', 36 name:'',
38 - projectlist:[{}], 37 + projectlist:[],
39 project_time:'' 38 project_time:''
40 }], 39 }],
  40 + main_array:[]
41 41
42 }, 42 },
43 43
@@ -81,12 +81,47 @@ Page({ @@ -81,12 +81,47 @@ Page({
81 }, 81 },
82 82
83 //保障项目弹窗 83 //保障项目弹窗
84 - ensureProject() { 84 + ensureProject(e) {
  85 + let that = this;
  86 + let type = e.currentTarget.dataset.type;
  87 + let index = e.currentTarget.dataset.xulie;
  88 + let tempProjectlist = Object.assign(this.data.projectlist, {}) ;
  89 + // 已经添加的附加险
  90 + let rist_list = Object.assign(this.data.risk_list,{});
  91 + let tempRist = rist_list[index].projectlist;
  92 + // 已经添加的主险
  93 + let tempMain_list = Object.assign(this.data.main_array, {})
  94 + if(type=='zhuxian'){
  95 + if (tempMain_list.length>0) {
  96 + for (let i in tempProjectlist) {
  97 + for (let j in tempMain_list) {
  98 + if (tempProjectlist[i].id == tempMain_list[j].id) {
  99 + tempProjectlist[i] = tempMain_list[j]
  100 + }
  101 + }
  102 + }
  103 + }
  104 + }else{
  105 + if (tempRist.length){
  106 + for (let i in tempProjectlist) {
  107 + for (let j in tempRist){
  108 + if (tempProjectlist[i].id == tempRist[j].id) {
  109 + tempProjectlist[i] = tempRist[j]
  110 + }
  111 + }
  112 + }
  113 + }
  114 +
  115 + }
85 wx.setNavigationBarTitle({ 116 wx.setNavigationBarTitle({
86 title: '选择保障项目', 117 title: '选择保障项目',
87 }) 118 })
88 this.setData({ 119 this.setData({
89 - popup_state: true 120 + popup_state: true,
  121 + addType: type,
  122 + xulie: index,
  123 + projectlist: tempProjectlist
  124 +
90 }) 125 })
91 }, 126 },
92 127
@@ -135,12 +170,12 @@ Page({ @@ -135,12 +170,12 @@ Page({
135 170
136 //保障项目金额 171 //保障项目金额
137 popupNum(e) { 172 popupNum(e) {
138 - var main_risk = this.data.main_risk 173 + // var main_risk = this.data.main_risk
139 var index = e.currentTarget.dataset.index; 174 var index = e.currentTarget.dataset.index;
140 var projectlist = this.data.projectlist; 175 var projectlist = this.data.projectlist;
141 if (projectlist[index].choose_status) { 176 if (projectlist[index].choose_status) {
142 projectlist[index].num = e.detail.value 177 projectlist[index].num = e.detail.value
143 - main_risk[index].num = projectlist[index].num 178 + // main_risk[index].num = projectlist[index].num
144 } 179 }
145 console.log(main_risk) 180 console.log(main_risk)
146 this.setData({ 181 this.setData({
@@ -152,58 +187,60 @@ Page({ @@ -152,58 +187,60 @@ Page({
152 popupState(e) { 187 popupState(e) {
153 var index = e.currentTarget.dataset.index; 188 var index = e.currentTarget.dataset.index;
154 var projectlist = this.data.projectlist; 189 var projectlist = this.data.projectlist;
155 - var checkstate = projectlist[index].choose_status;  
156 - var selectitem = [];  
157 - var length = this.data.projectlist.length  
158 - var main_risk = this.data.main_risk  
159 - var popup_state = this.data.popup_state  
160 - if (checkstate == false) {  
161 - projectlist[index].choose_status = true  
162 - } else {  
163 - projectlist[index].choose_status = false  
164 - } 190 + projectlist[index].choose_status = !projectlist[index].choose_status;
  191 + console.log(projectlist)
165 this.setData({ 192 this.setData({
166 projectlist: projectlist 193 projectlist: projectlist
167 - }) 194 + })
168 }, 195 },
169 196
170 //确认选择的推荐方案 197 //确认选择的推荐方案
171 confirmCase() { 198 confirmCase() {
  199 + let index = this.data.xulie;
  200 + let type = this.data.addType;
172 var that = this 201 var that = this
173 var main_array = [] 202 var main_array = []
174 - let dindex = wx.getStorageSync('dindex')  
175 - var projectlist = this.data.projectlist 203 + var projectlist = Object.assign(this.data.projectlist,{})
176 for (var i = 0; i < projectlist.length; i++) { 204 for (var i = 0; i < projectlist.length; i++) {
177 - for (var j = 0; j < projectlist[i].title.length; j++) {  
178 if (projectlist[i].choose_status) { 205 if (projectlist[i].choose_status) {
179 - if (projectlist[i].title[j].label_state) {  
180 - main_array.push(projectlist[i])  
181 - } 206 + main_array.push(projectlist[i])
182 } 207 }
183 - console.log(main_array)  
184 - }  
185 } 208 }
  209 +
186 if (main_array != '') { 210 if (main_array != '') {
187 wx.showToast({ 211 wx.showToast({
188 title: '添加成功', 212 title: '添加成功',
189 icon: 'none' 213 icon: 'none'
190 }) 214 })
191 - var temp = main_array  
192 - for (var i = 0; i < main_array.length; i++) {  
193 - for (var j = 0; j < main_array[i].title.length; j++) {  
194 - if (main_array[i].title[j].label_state) {  
195 - main_array[i].title = main_array[i].title[j].name  
196 - }  
197 - console.log(main_array)  
198 - } 215 + if(type=='fujiaxian'){
  216 + let tempRist = that.data.risk_list;
  217 + tempRist[index]['projectlist'] = main_array;
  218 + that.setData({
  219 + risk_list: tempRist,
  220 + })
  221 + }else{
  222 + that.setData({
  223 + main_array: main_array,
  224 + })
199 } 225 }
200 - that.setData({  
201 - main_array: main_array  
202 - }) 226 +
  227 + // var temp = main_array
  228 + // for (var i = 0; i < main_array.length; i++) {
  229 + // for (var j = 0; j < main_array[i].title.length; j++) {
  230 + // if (main_array[i].title[j].label_state) {
  231 + // main_array[i].title = main_array[i].title[j].name
  232 + // }
  233 + // console.log(main_array)
  234 + // }
  235 + // }
  236 + // that.setData({
  237 + // main_array: main_array
  238 + // })
203 } 239 }
204 setTimeout(function() { 240 setTimeout(function() {
  241 + that.ensureProjectList()
205 that.setData({ 242 that.setData({
206 - popup_state: false, 243 + popup_state: false
207 }) 244 })
208 wx.setNavigationBarTitle({ 245 wx.setNavigationBarTitle({
209 title: '添加保单', 246 title: '添加保单',
@@ -272,11 +309,11 @@ Page({ @@ -272,11 +309,11 @@ Page({
272 309
273 //添加附加险 310 //添加附加险
274 addRisk(){ 311 addRisk(){
275 - var risk_list=this.data.risk_list 312 + var risk_list = Object.assign(this.data.risk_list,{});
276 var len=risk_list.length 313 var len=risk_list.length
277 risk_list[len] = { 314 risk_list[len] = {
278 name: '', 315 name: '',
279 - projectlist: [{}], 316 + projectlist: [],
280 project_time: '' 317 project_time: ''
281 } 318 }
282 this.setData({ 319 this.setData({
@@ -130,14 +130,13 @@ @@ -130,14 +130,13 @@
130 </view> 130 </view>
131 <view class='protec_item_box'> 131 <view class='protec_item_box'>
132 <view> 132 <view>
133 - <view class='protec_item' wx:for='{{main_array}}' wx:key='' if='{{item.choose_status}}'> 133 + <view class='protec_item' wx:for='{{main_array}}' wx:key=''>
134 <view>{{item.name}}</view> 134 <view>{{item.name}}</view>
135 - <view class='protec_num'>{{item.num}}{{item.title}}  
136 - </view> 135 + <view class='protec_num'>{{item.num}}<block wx:for='{{item.title}}' wx:for-item='danwei' wx:key=''><text wx:if="{{danwei.label_state}}">{{danwei.name}}</text></block></view>
137 </view> 136 </view>
138 </view> 137 </view>
139 <view class='protec_bottom_box'> 138 <view class='protec_bottom_box'>
140 - <view class='add_risk_btn protec_btn' bindtap='ensureProject'> 139 + <view class='add_risk_btn protec_btn' bindtap='ensureProject' data-type='zhuxian' data-xulie='0'>
141 <text class='iconfont icon-shezhi'></text> 140 <text class='iconfont icon-shezhi'></text>
142 <text>管理保障项目</text> 141 <text>管理保障项目</text>
143 </view> 142 </view>
@@ -291,21 +290,21 @@ @@ -291,21 +290,21 @@
291 </view> 290 </view>
292 <view class='protec_item_box'> 291 <view class='protec_item_box'>
293 <view> 292 <view>
294 - <view class='protec_item'>  
295 - <view>轻症重大疾病</view>  
296 - <view class='protec_num'>50万</view> 293 + <view class='protec_item' wx:for='{{item.projectlist}}' wx:for-item='project' wx:key=''>
  294 + <view>{{project.name}}</view>
  295 + <view class='protec_num'>{{project.num}}<block wx:for='{{project.title}}' wx:for-item='danwei' wx:key=''><text wx:if="{{danwei.label_state}}">{{danwei.name}}</text></block></view>
297 </view> 296 </view>
298 - <view class='protec_item'> 297 + <!-- <view class='protec_item'>
299 <view>轻症重大疾病</view> 298 <view>轻症重大疾病</view>
300 <view class='protec_num'>50万</view> 299 <view class='protec_num'>50万</view>
301 </view> 300 </view>
302 <view class='protec_item'> 301 <view class='protec_item'>
303 <view>轻症重大疾病</view> 302 <view>轻症重大疾病</view>
304 <view class='protec_num'>50万</view> 303 <view class='protec_num'>50万</view>
305 - </view> 304 + </view> -->
306 </view> 305 </view>
307 <view class='protec_bottom_box'> 306 <view class='protec_bottom_box'>
308 - <view class='add_risk_btn protec_btn' bindtap='ensureProject'> 307 + <view class='add_risk_btn protec_btn' bindtap='ensureProject' data-type='fujiaxian' data-xulie='{{index}}'>
309 <text class='iconfont icon-shezhi'></text> 308 <text class='iconfont icon-shezhi'></text>
310 <text>管理保障项目</text> 309 <text>管理保障项目</text>
311 </view> 310 </view>
@@ -36,13 +36,18 @@ @@ -36,13 +36,18 @@
36 "list": [] 36 "list": []
37 }, 37 },
38 "miniprogram": { 38 "miniprogram": {
39 - "current": -1, 39 + "current": 1,
40 "list": [ 40 "list": [
41 { 41 {
42 "id": -1, 42 "id": -1,
43 "name": "list", 43 "name": "list",
44 "pathName": "pages/index/addListDetail/addListDetail", 44 "pathName": "pages/index/addListDetail/addListDetail",
45 "query": "" 45 "query": ""
  46 + },
  47 + {
  48 + "id": -1,
  49 + "name": "保单添加",
  50 + "pathName": "pages/index/addListDetail/addListDetail"
46 } 51 }
47 ] 52 ]
48 } 53 }