Commit 8e0263694d1bd08974b46d33d3c319540ac22fec
1 parent
bbaeed7fdc
Exists in
dev_wjl
and in
1 other branch
修改膳食页面
Showing 2 changed files with 82 additions and 72 deletions
littleApp_child/pages/diet/measuret.js
View file @
8e02636
| ... | ... | @@ -257,90 +257,100 @@ |
| 257 | 257 | // } |
| 258 | 258 | }, |
| 259 | 259 | foodClick1(e) { |
| 260 | - let Names = this.data.foodListNames; | |
| 261 | - let items = this.data.foodList; | |
| 260 | + const Names = this.data.foodListNames1; | |
| 261 | + const items = this.data.foodList1; | |
| 262 | 262 | const values = e.detail.value; |
| 263 | 263 | console.log('哈哈哈',values); |
| 264 | - const yf=this.getLeadingNumbers1(values[0]) | |
| 265 | - console.log('yf',yf); | |
| 266 | - if(yf=='11'||yf=='21'){ | |
| 267 | - Names = this.data.foodListNames1; | |
| 268 | - items = this.data.foodList1; | |
| 269 | - }else if(yf=='12'||yf=='22'){ | |
| 270 | - Names = this.data.foodListNames2; | |
| 271 | - items = this.data.foodList2; | |
| 272 | - }else if(yf=='13'||yf=='23'){ | |
| 273 | - Names = this.data.foodListNames3; | |
| 274 | - items = this.data.foodList3; | |
| 275 | - }else if(yf=='14'||yf=='24'){ | |
| 276 | - Names = this.data.foodListNames4; | |
| 277 | - items = this.data.foodList4; | |
| 264 | + for (let i = 0, lenI = items.length; i < lenI; ++i) { | |
| 265 | + items[i].add = 0; | |
| 266 | + items[i].love = 0; | |
| 267 | + | |
| 268 | + for (let j = 0, lenJ = values.length; j < lenJ; ++j) { | |
| 269 | + if (Names[i]+'1' === values[j]) { | |
| 270 | + items[i].add = 1; | |
| 271 | + }else if (Names[i]+'2' === values[j]) { | |
| 272 | + items[i].love = 1; | |
| 273 | + } | |
| 274 | + } | |
| 275 | + if(items[i].add === 0){ | |
| 276 | + items[i].love = 0; | |
| 277 | + } | |
| 278 | 278 | } |
| 279 | + this.setData({ | |
| 280 | + foodList1:items | |
| 281 | + }) | |
| 282 | + }, | |
| 283 | + foodClick2(e) { | |
| 284 | + const Names = this.data.foodListNames2; | |
| 285 | + const items = this.data.foodList2; | |
| 286 | + const values = e.detail.value; | |
| 287 | + console.log('哈哈哈',values); | |
| 279 | 288 | for (let i = 0, lenI = items.length; i < lenI; ++i) { |
| 280 | 289 | items[i].add = 0; |
| 281 | 290 | items[i].love = 0; |
| 282 | 291 | |
| 283 | 292 | for (let j = 0, lenJ = values.length; j < lenJ; ++j) { |
| 284 | - if(yf=='11'||yf=='21'){ | |
| 285 | - if (Names[i]+'11' === values[j]) { | |
| 286 | - items[i].add = 1; | |
| 287 | - }else if (Names[i]+'21' === values[j]) { | |
| 288 | - items[i].love = 1; | |
| 289 | - } | |
| 290 | - }else if(yf=='12'||yf=='22'){ | |
| 291 | - if (Names[i]+'12' === values[j]) { | |
| 292 | - items[i].add = 1; | |
| 293 | - }else if (Names[i]+'22' === values[j]) { | |
| 294 | - items[i].love = 1; | |
| 295 | - } | |
| 296 | - }else if(yf=='13'||yf=='23'){ | |
| 297 | - if (Names[i]+'13' === values[j]) { | |
| 298 | - items[i].add = 1; | |
| 299 | - }else if (Names[i]+'23' === values[j]) { | |
| 300 | - items[i].love = 1; | |
| 301 | - } | |
| 302 | - }else if(yf=='14'||yf=='24'){ | |
| 303 | - if (Names[i]+'14' === values[j]) { | |
| 304 | - items[i].add = 1; | |
| 305 | - }else if (Names[i]+'24' === values[j]) { | |
| 306 | - items[i].love = 1; | |
| 307 | - } | |
| 293 | + if (Names[i]+'1' === values[j]) { | |
| 294 | + items[i].add = 1; | |
| 295 | + }else if (Names[i]+'2' === values[j]) { | |
| 296 | + items[i].love = 1; | |
| 308 | 297 | } |
| 309 | 298 | } |
| 310 | - // if (Names[i]+yf === values[j]) { | |
| 311 | - // items[i].add = 1; | |
| 312 | - // }else if (Names[i]+yf === values[j]) { | |
| 313 | - // items[i].love = 1; | |
| 314 | - // } | |
| 315 | 299 | if(items[i].add === 0){ |
| 316 | 300 | items[i].love = 0; |
| 317 | 301 | } |
| 318 | 302 | } |
| 319 | - if(yf=='11'||yf=='21'){ | |
| 320 | - this.setData({ | |
| 321 | - foodList1:items | |
| 322 | - }) | |
| 323 | - console.log('list1',this.data.foodList1); | |
| 324 | - }else if(yf=='12'||yf=='22'){ | |
| 325 | 303 | this.setData({ |
| 326 | 304 | foodList2:items |
| 327 | 305 | }) |
| 328 | - console.log('list2',this.data.foodList2); | |
| 329 | - }else if(yf=='13'||yf=='23'){ | |
| 306 | + }, | |
| 307 | + foodClick3(e) { | |
| 308 | + const Names = this.data.foodListNames3; | |
| 309 | + const items = this.data.foodList3; | |
| 310 | + const values = e.detail.value; | |
| 311 | + console.log('哈哈哈',values); | |
| 312 | + for (let i = 0, lenI = items.length; i < lenI; ++i) { | |
| 313 | + items[i].add = 0; | |
| 314 | + items[i].love = 0; | |
| 315 | + | |
| 316 | + for (let j = 0, lenJ = values.length; j < lenJ; ++j) { | |
| 317 | + if (Names[i]+'1' === values[j]) { | |
| 318 | + items[i].add = 1; | |
| 319 | + }else if (Names[i]+'2' === values[j]) { | |
| 320 | + items[i].love = 1; | |
| 321 | + } | |
| 322 | + } | |
| 323 | + if(items[i].add === 0){ | |
| 324 | + items[i].love = 0; | |
| 325 | + } | |
| 326 | + } | |
| 330 | 327 | this.setData({ |
| 331 | 328 | foodList3:items |
| 332 | 329 | }) |
| 333 | - console.log('list3',this.data.foodList3); | |
| 334 | - }else if(yf=='14'||yf=='24'){ | |
| 330 | + }, | |
| 331 | + foodClick4(e) { | |
| 332 | + const Names = this.data.foodListNames4; | |
| 333 | + const items = this.data.foodList4; | |
| 334 | + const values = e.detail.value; | |
| 335 | + console.log('哈哈哈',values); | |
| 336 | + for (let i = 0, lenI = items.length; i < lenI; ++i) { | |
| 337 | + items[i].add = 0; | |
| 338 | + items[i].love = 0; | |
| 339 | + | |
| 340 | + for (let j = 0, lenJ = values.length; j < lenJ; ++j) { | |
| 341 | + if (Names[i]+'1' === values[j]) { | |
| 342 | + items[i].add = 1; | |
| 343 | + }else if (Names[i]+'2' === values[j]) { | |
| 344 | + items[i].love = 1; | |
| 345 | + } | |
| 346 | + } | |
| 347 | + if(items[i].add === 0){ | |
| 348 | + items[i].love = 0; | |
| 349 | + } | |
| 350 | + } | |
| 335 | 351 | this.setData({ |
| 336 | 352 | foodList4:items |
| 337 | 353 | }) |
| 338 | - console.log('list4',this.data.foodList4); | |
| 339 | - } | |
| 340 | - console.log('list'); | |
| 341 | - // if(this.foodList[i].add == 0){ | |
| 342 | - // this.foodList[i].love = 0; | |
| 343 | - // } | |
| 344 | 354 | }, |
| 345 | 355 | saveFoodlist(){ |
| 346 | 356 | var that = this; |
littleApp_child/pages/diet/measuret.wxml
View file @
8e02636
| ... | ... | @@ -30,39 +30,39 @@ |
| 30 | 30 | <checkbox-group bindchange="foodClick1"> |
| 31 | 31 | <view class="section section_gap" wx:for="{{foodList1}}" wx:for-index="$index" wx:for-item="item"> |
| 32 | 32 | <view class="body-view"> |
| 33 | - <checkbox type="checkbox" value="{{foodListNames1[$index]}}11" checked="{{item.add}}" color="#68bcfa" /> | |
| 34 | - <checkbox type="checkbox" value="{{foodListNames1[$index]}}21" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 33 | + <checkbox type="checkbox" value="{{foodListNames1[$index]}}1" checked="{{item.add}}" color="#68bcfa" /> | |
| 34 | + <checkbox type="checkbox" value="{{foodListNames1[$index]}}2" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 35 | 35 | </view> |
| 36 | 36 | <view class="section__title">{{foodListNames1[$index]}}</view> |
| 37 | 37 | </view> |
| 38 | 38 | </checkbox-group> |
| 39 | 39 | <view style="font-size: 26rpx;">七月龄膳食调查</view> |
| 40 | - <checkbox-group bindchange="foodClick1"> | |
| 40 | + <checkbox-group bindchange="foodClick2"> | |
| 41 | 41 | <view class="section section_gap" wx:for="{{foodList2}}" wx:for-index="$index" wx:for-item="item"> |
| 42 | 42 | <view class="body-view"> |
| 43 | - <checkbox type="checkbox" value="{{foodListNames2[$index]}}12" checked="{{item.add}}" color="#68bcfa" /> | |
| 44 | - <checkbox type="checkbox" value="{{foodListNames2[$index]}}22" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 43 | + <checkbox type="checkbox" value="{{foodListNames2[$index]}}1" checked="{{item.add}}" color="#68bcfa" /> | |
| 44 | + <checkbox type="checkbox" value="{{foodListNames2[$index]}}2" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 45 | 45 | </view> |
| 46 | 46 | <view class="section__title">{{foodListNames2[$index]}}</view> |
| 47 | 47 | </view> |
| 48 | 48 | </checkbox-group> |
| 49 | 49 | <view style="font-size: 26rpx;">八月龄膳食调查</view> |
| 50 | - <checkbox-group bindchange="foodClick1"> | |
| 50 | + <checkbox-group bindchange="foodClick3"> | |
| 51 | 51 | <view class="section section_gap" wx:for="{{foodList3}}" wx:for-index="$index" wx:for-item="item"> |
| 52 | 52 | <view class="body-view"> |
| 53 | - <checkbox type="checkbox" value="{{foodListNames3[$index]}}13" checked="{{item.add}}" color="#68bcfa" /> | |
| 54 | - <checkbox type="checkbox" value="{{foodListNames3[$index]}}23" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 53 | + <checkbox type="checkbox" value="{{foodListNames3[$index]}}1" checked="{{item.add}}" color="#68bcfa" /> | |
| 54 | + <checkbox type="checkbox" value="{{foodListNames3[$index]}}2" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 55 | 55 | </view> |
| 56 | 56 | <view class="section__title">{{foodListNames3[$index]}}</view> |
| 57 | 57 | </view> |
| 58 | 58 | </checkbox-group> |
| 59 | 59 | <view style="color: #fff;">1</view> |
| 60 | 60 | <view style="font-size: 26rpx;">九月龄膳食调查</view> |
| 61 | - <checkbox-group bindchange="foodClick1"> | |
| 61 | + <checkbox-group bindchange="foodClick4"> | |
| 62 | 62 | <view class="section section_gap" wx:for="{{foodList4}}" wx:for-index="$index" wx:for-item="item"> |
| 63 | 63 | <view class="body-view"> |
| 64 | - <checkbox type="checkbox" value="{{foodListNames4[$index]}}14" checked="{{item.add}}" color="#68bcfa" /> | |
| 65 | - <checkbox type="checkbox" value="{{foodListNames4[$index]}}24" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 64 | + <checkbox type="checkbox" value="{{foodListNames4[$index]}}1" checked="{{item.add}}" color="#68bcfa" /> | |
| 65 | + <checkbox type="checkbox" value="{{foodListNames4[$index]}}2" disabled = "{{item.add == 0}}" checked="{{item.love}}" color="#ed7d31" /> | |
| 66 | 66 | </view> |
| 67 | 67 | <view class="section__title">{{foodListNames4[$index]}}</view> |
| 68 | 68 | </view> |