yanlu

fix:预约状态修改问题

1 import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent' 1 import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
2 import { RmhRecommendDTO } from 'wdBean'; 2 import { RmhRecommendDTO } from 'wdBean';
3 -import { faceDetector } from '@kit.CoreVisionKit';  
4 3
5 @Component 4 @Component
6 export struct PeopleShipRecommendComponent { 5 export struct PeopleShipRecommendComponent {
@@ -28,7 +28,7 @@ const TAG: string = 'ReserveMorePage'; @@ -28,7 +28,7 @@ const TAG: string = 'ReserveMorePage';
28 @Component 28 @Component
29 struct ReserveMorePage { 29 struct ReserveMorePage {
30 @State data: LazyDataSource<ContentDTO> = new LazyDataSource(); 30 @State data: LazyDataSource<ContentDTO> = new LazyDataSource();
31 - @State reserveList: ReserveItemBean[] = [] 31 + private reserveList: ReserveItemBean[] = []
32 topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number; 32 topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
33 type: number = 2; 33 type: number = 2;
34 pageSize: number = 20; 34 pageSize: number = 20;
@@ -312,8 +312,15 @@ struct ReserveMorePage { @@ -312,8 +312,15 @@ struct ReserveMorePage {
312 Logger.debug(TAG,'是否关注元数据2:' +` ${JSON.stringify(element.subscribe)}`) 312 Logger.debug(TAG,'是否关注元数据2:' +` ${JSON.stringify(element.subscribe)}`)
313 element.subscribe = !element.subscribe 313 element.subscribe = !element.subscribe
314 Logger.debug(TAG,'是否关注元数据3:' +` ${JSON.stringify(element.subscribe)}`) 314 Logger.debug(TAG,'是否关注元数据3:' +` ${JSON.stringify(element.subscribe)}`)
315 - this.data.reloadData()  
316 this.isShow = true 315 this.isShow = true
  316 + if (element.subscribe) {
  317 + this.reservedIds.push(element.liveId.toString())
  318 + }else {
  319 + const num = this.reservedIds.indexOf(element.liveId.toString())
  320 + if (num >= 0 && num < this.reservedIds.length) {
  321 + this.reservedIds.splice(num, 1)
  322 + }
  323 + }
317 } 324 }
318 } 325 }
319 }) 326 })
@@ -349,6 +356,7 @@ struct ReserveMorePage { @@ -349,6 +356,7 @@ struct ReserveMorePage {
349 if (this.currentPage == 1) { 356 if (this.currentPage == 1) {
350 this.data.clear() 357 this.data.clear()
351 this.reserveList = [] 358 this.reserveList = []
  359 + this.reservedIds = []
352 } 360 }
353 this.data.push(...liveReviewDTO.list) 361 this.data.push(...liveReviewDTO.list)
354 //批量查询关注状态 362 //批量查询关注状态
@@ -396,7 +404,12 @@ struct ReserveMorePage { @@ -396,7 +404,12 @@ struct ReserveMorePage {
396 Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`) 404 Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`)
397 if (result && result.length > 0) { 405 if (result && result.length > 0) {
398 this.reserveList.push(...result) 406 this.reserveList.push(...result)
399 - this.data.reloadData() 407 + // this.reserveStatus = res;
  408 + result.map((item: ReserveItemBean) => {
  409 + if (item.subscribe) {
  410 + this.reservedIds.push(item.liveId.toString())
  411 + }
  412 + })
400 } 413 }
401 }).catch(() =>{ 414 }).catch(() =>{
402 // this.data.push(...list) 415 // this.data.push(...list)
@@ -409,11 +422,7 @@ struct ReserveMorePage { @@ -409,11 +422,7 @@ struct ReserveMorePage {
409 422
410 // 判断是否预约 423 // 判断是否预约
411 isReserved(item: ContentDTO) { 424 isReserved(item: ContentDTO) {
412 - const objc = this.getAttentionItem(item)  
413 - if (objc) {  
414 - return objc.subscribe  
415 - }  
416 - return false 425 + return this.reservedIds.includes(item.objectId)
417 } 426 }
418 427
419 getAttentionItem(item: ContentDTO) { 428 getAttentionItem(item: ContentDTO) {
@@ -460,9 +469,17 @@ struct ReserveMorePage { @@ -460,9 +469,17 @@ struct ReserveMorePage {
460 Logger.debug(TAG,'是否关注元数据:' +` ${JSON.stringify(element.subscribe)}`) 469 Logger.debug(TAG,'是否关注元数据:' +` ${JSON.stringify(element.subscribe)}`)
461 element.subscribe = !element.subscribe 470 element.subscribe = !element.subscribe
462 Logger.debug(TAG,'是否关注元数据1:' +` ${JSON.stringify(element.subscribe)}`) 471 Logger.debug(TAG,'是否关注元数据1:' +` ${JSON.stringify(element.subscribe)}`)
463 - this.data.reloadData() 472 + if (element.subscribe) {
  473 + this.reservedIds.push(element.liveId.toString())
  474 + }else {
  475 + const num = this.reservedIds.indexOf(element.liveId.toString())
  476 + if (num >= 0 && num < this.reservedIds.length) {
  477 + this.reservedIds.splice(num, 1)
  478 + }
  479 + }
464 } 480 }
465 }) 481 })
  482 +
466 } 483 }
467 this.isLoadingAttention = false 484 this.isLoadingAttention = false
468 this.liveId = '' 485 this.liveId = ''