yanlu

fix:早晚报评论数

1 import { AudioDataList } from './AudioDataList'; 1 import { AudioDataList } from './AudioDataList';
2 -import { OperDataList } from './OperDataList'; 2 +import { ContentDTO } from '../content/ContentDTO';
3 3
4 export interface CompList { 4 export interface CompList {
5 audioDataList: AudioDataList[]; 5 audioDataList: AudioDataList[];
@@ -36,7 +36,7 @@ export interface CompList { @@ -36,7 +36,7 @@ export interface CompList {
36 36
37 // openComment?: any; 37 // openComment?: any;
38 // openLikes?: any; 38 // openLikes?: any;
39 - operDataList: OperDataList[]; 39 + operDataList: ContentDTO[];
40 pageId: string; 40 pageId: string;
41 41
42 // position?: any; 42 // position?: any;
1 // import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean'; 1 // import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean';
2 -import { CompList, PageInfoBean } from 'wdBean'; 2 +import {
  3 + CompList,
  4 + PageInfoBean,
  5 + ContentDTO,
  6 + contentListParams,
  7 + InteractDataDTO
  8 +} from 'wdBean';
3 import { DateTimeUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index'; 9 import { DateTimeUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index';
4 import { PaperReaderSimpleDialog } from '../../dialog/PaperReaderDialog'; 10 import { PaperReaderSimpleDialog } from '../../dialog/PaperReaderDialog';
5 import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel'; 11 import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel';
@@ -13,6 +19,7 @@ import { image } from '@kit.ImageKit'; @@ -13,6 +19,7 @@ import { image } from '@kit.ImageKit';
13 import { getPicture, imageNet2PixelMap } from '../../utils/ImageUtils'; 19 import { getPicture, imageNet2PixelMap } from '../../utils/ImageUtils';
14 import { effectKit } from '@kit.ArkGraphics2D'; 20 import { effectKit } from '@kit.ArkGraphics2D';
15 import { window } from '@kit.ArkUI'; 21 import { window } from '@kit.ArkUI';
  22 +import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
16 23
17 const TAG = 'MorningEveningPaperComponent'; 24 const TAG = 'MorningEveningPaperComponent';
18 25
@@ -22,6 +29,7 @@ export struct MorningEveningPaperComponent { @@ -22,6 +29,7 @@ export struct MorningEveningPaperComponent {
22 @State pageInfoBean: PageInfoBean = {} as PageInfoBean 29 @State pageInfoBean: PageInfoBean = {} as PageInfoBean
23 // @State compInfoBean: CompInfoBean = {} as CompInfoBean 30 // @State compInfoBean: CompInfoBean = {} as CompInfoBean
24 @State compListItem: CompList = {} as CompList 31 @State compListItem: CompList = {} as CompList
  32 + @Provide commentList: InteractDataDTO[] = []
25 @State audioPlayUrl: string = "" 33 @State audioPlayUrl: string = ""
26 // @Consume dailyPaperTopicPageId: number 34 // @Consume dailyPaperTopicPageId: number
27 // @Provide compListItem: CompList = {} as CompList 35 // @Provide compListItem: CompList = {} as CompList
@@ -128,6 +136,10 @@ export struct MorningEveningPaperComponent { @@ -128,6 +136,10 @@ export struct MorningEveningPaperComponent {
128 // this.compInfoBean = compInfoBean 136 // this.compInfoBean = compInfoBean
129 if (compInfoBean?.compList[0]) { 137 if (compInfoBean?.compList[0]) {
130 this.compListItem = compInfoBean?.compList[0] 138 this.compListItem = compInfoBean?.compList[0]
  139 + Logger.debug(TAG, '获取评论数据' + `${this.compListItem.operDataList.length}`)
  140 + if (this.compListItem.operDataList && this.compListItem.operDataList.length > 0) {
  141 + this.getAllContentInteractData(this.compListItem.operDataList)
  142 + }
131 if (compInfoBean?.compList[0].audioDataList) { 143 if (compInfoBean?.compList[0].audioDataList) {
132 this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl 144 this.audioPlayUrl = compInfoBean?.compList[0].audioDataList[0].audioUrl
133 this.audioTitle = compInfoBean?.compList[0].audioDataList[0].title 145 this.audioTitle = compInfoBean?.compList[0].audioDataList[0].title
@@ -146,6 +158,29 @@ export struct MorningEveningPaperComponent { @@ -146,6 +158,29 @@ export struct MorningEveningPaperComponent {
146 158
147 } 159 }
148 160
  161 + // 批量查询内容当前用户点赞、收藏状态评论个数
  162 + private async getAllContentInteractData(list: ContentDTO[]) {
  163 + try {
  164 + // 获取列表数据
  165 + const params: contentListParams = {
  166 + contentList: []
  167 + }
  168 + list.forEach((item: ContentDTO) => {
  169 + params.contentList.push({
  170 + contentId: item.objectId,
  171 + contentType: Number(item.objectType ?? '1')
  172 + })
  173 + })
  174 + Logger.debug(TAG, '获取评论数据' + `${JSON.stringify(params)}`)
  175 +
  176 + this.commentList = await PeopleShipMainViewModel.getContentInteractInfo(params)
  177 + Logger.debug(TAG, '获取评论数据' + `${JSON.stringify(this.commentList)}`)
  178 +
  179 + } catch (exception) {
  180 +
  181 + }
  182 + }
  183 +
149 async setComponentBgColor(imageUrl: string) { 184 async setComponentBgColor(imageUrl: string) {
150 // 图片转换为PixelMap对象 185 // 图片转换为PixelMap对象
151 // const pixelMap: image.PixelMap = await image2PixelMap(item.icon); 186 // const pixelMap: image.PixelMap = await image2PixelMap(item.icon);
@@ -203,7 +238,9 @@ export struct MorningEveningPaperComponent { @@ -203,7 +238,9 @@ export struct MorningEveningPaperComponent {
203 } 238 }
204 239
205 ListItem() { 240 ListItem() {
206 - SingleColumn999Component({ compListItem: this.compListItem }) 241 + SingleColumn999Component({
  242 + compListItem: this.compListItem,
  243 + })
207 .margin({ 244 .margin({
208 top: this.pageInfoBean?.topicInfo?.frontLinkObject ? 10 : 44 245 top: this.pageInfoBean?.topicInfo?.frontLinkObject ? 10 : 44
209 }) 246 })
1 -import { CompList, ContentDTO } from 'wdBean'; 1 +import { it } from '@ohos/hypium';
  2 +import { CompList, ContentDTO, InteractDataDTO} from 'wdBean';
2 import { BreakpointConstants } from 'wdConstant'; 3 import { BreakpointConstants } from 'wdConstant';
3 import { Logger } from 'wdKit'; 4 import { Logger } from 'wdKit';
4 import { PaperSingleColumn999CardView } from '../page/CardView'; 5 import { PaperSingleColumn999CardView } from '../page/CardView';
@@ -13,6 +14,7 @@ const TAG = 'SingleColumn999Component'; @@ -13,6 +14,7 @@ const TAG = 'SingleColumn999Component';
13 export struct SingleColumn999Component { 14 export struct SingleColumn999Component {
14 // @Consume compListItem?: CompList 15 // @Consume compListItem?: CompList
15 @Prop compListItem?: CompList 16 @Prop compListItem?: CompList
  17 +
16 @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; 18 @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
17 19
18 // @State compDTO: CompDTO = { 20 // @State compDTO: CompDTO = {
@@ -122,8 +124,6 @@ export struct SingleColumn999Component { @@ -122,8 +124,6 @@ export struct SingleColumn999Component {
122 this.buildPaperItem(item, index) 124 this.buildPaperItem(item, index)
123 } 125 }
124 }, (item: ContentDTO, index: number) => JSON.stringify(item)) 126 }, (item: ContentDTO, index: number) => JSON.stringify(item))
125 - // }  
126 - // .divider({ strokeWidth: 1, color: '#EFEFEF' }) // 每行之间的分界线  
127 127
128 ListItem() { 128 ListItem() {
129 Text("已显示全部内容") 129 Text("已显示全部内容")
@@ -170,7 +170,7 @@ export struct SingleColumn999Component { @@ -170,7 +170,7 @@ export struct SingleColumn999Component {
170 buildPaperItem(item: ContentDTO, index: number) { 170 buildPaperItem(item: ContentDTO, index: number) {
171 PaperSingleColumn999CardView({ 171 PaperSingleColumn999CardView({
172 item: item, 172 item: item,
173 - index: index 173 + index: index,
174 }) 174 })
175 } 175 }
176 } 176 }
1 -import { Action, ContentDTO, Params } from 'wdBean'; 1 +import { Action, ContentDTO, Params, InteractDataDTO } from 'wdBean';
2 import { CommonConstants, ConfigConstants, ScreenType } from 'wdConstant'; 2 import { CommonConstants, ConfigConstants, ScreenType } from 'wdConstant';
3 import { Logger, ToastUtils, DateTimeUtils } from 'wdKit'; 3 import { Logger, ToastUtils, DateTimeUtils } from 'wdKit';
4 import { CompUtils } from '../../utils/CompUtils'; 4 import { CompUtils } from '../../utils/CompUtils';
@@ -389,6 +389,8 @@ export struct MasonryLayout01CardView { @@ -389,6 +389,8 @@ export struct MasonryLayout01CardView {
389 export struct PaperSingleColumn999CardView { 389 export struct PaperSingleColumn999CardView {
390 private item: ContentDTO = {} as ContentDTO; 390 private item: ContentDTO = {} as ContentDTO;
391 private index: number = -1; 391 private index: number = -1;
  392 + @State interactData: InteractDataDTO = {} as InteractDataDTO;
  393 + @Consume @Watch('onChangeCommentList') commentList: InteractDataDTO[]
392 394
393 getPublishTime(): string { 395 getPublishTime(): string {
394 const publishTimestamp = parseInt(this.item?.publishTime) 396 const publishTimestamp = parseInt(this.item?.publishTime)
@@ -471,7 +473,7 @@ export struct PaperSingleColumn999CardView { @@ -471,7 +473,7 @@ export struct PaperSingleColumn999CardView {
471 .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 473 .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
472 .margin({ left: 22, right: 22 }) 474 .margin({ left: 22, right: 22 })
473 } 475 }
474 - if (this.item?.visitorComment) { 476 + if (this.item) {
475 Row() { 477 Row() {
476 Row() { 478 Row() {
477 Text(this.item?.source) 479 Text(this.item?.source)
@@ -485,10 +487,17 @@ export struct PaperSingleColumn999CardView { @@ -485,10 +487,17 @@ export struct PaperSingleColumn999CardView {
485 Text(this.getPublishTime()) 487 Text(this.getPublishTime())
486 .fontSize(12) 488 .fontSize(12)
487 .fontColor(Color.Gray) 489 .fontColor(Color.Gray)
488 - Text(this.item?.visitorComment + "评") 490 + if (this.interactData && this.interactData.commentNum) {
  491 + Text(this.interactData.commentNum + "评")
489 .fontSize(12) 492 .fontSize(12)
490 .fontColor(Color.Gray) 493 .fontColor(Color.Gray)
491 .margin({ left: 6 }) 494 .margin({ left: 6 })
  495 + }else if (this.commentList && this.commentList.length) {
  496 + Text(this.interactData.commentNum + "评")
  497 + .fontSize(12)
  498 + .fontColor(Color.Gray)
  499 + .margin({ left: 6 })
  500 + }
492 } 501 }
493 .justifyContent(FlexAlign.Start) 502 .justifyContent(FlexAlign.Start)
494 503
@@ -514,4 +523,22 @@ export struct PaperSingleColumn999CardView { @@ -514,4 +523,22 @@ export struct PaperSingleColumn999CardView {
514 ProcessUtils.processPage(this.item) 523 ProcessUtils.processPage(this.item)
515 }) 524 })
516 } 525 }
  526 +
  527 + aboutToAppear(): void {
  528 + this.onChangeCommentList()
  529 + }
  530 +
  531 + onChangeCommentList() {
  532 + // 获取评论
  533 + if (this.commentList && this.commentList.length > 0 && this.item && this.item.objectId) {
  534 + const objc = this.commentList.find((interactModel: InteractDataDTO) => {
  535 + return this.item.objectId == interactModel.contentId
  536 + })
  537 + if (objc) {
  538 + this.interactData = objc
  539 + }
  540 + }
  541 + }
  542 +
  543 +
517 } 544 }
@@ -63,12 +63,10 @@ export struct PeopleShipMainComponent { @@ -63,12 +63,10 @@ export struct PeopleShipMainComponent {
63 this.LoadingLayout() 63 this.LoadingLayout()
64 } else if (this.viewType == ViewType.ERROR) { 64 } else if (this.viewType == ViewType.ERROR) {
65 ErrorComponent() 65 ErrorComponent()
66 - .onTouch((event: TouchEvent | undefined) => {  
67 - if (event) { 66 + .onTouch(() => {
68 if (this.viewType === ViewType.ERROR) { 67 if (this.viewType === ViewType.ERROR) {
69 this.getData() 68 this.getData()
70 } 69 }
71 - }  
72 }) 70 })
73 } else if (this.viewType == ViewType.EMPTY) { 71 } else if (this.viewType == ViewType.EMPTY) {
74 EmptyComponent() 72 EmptyComponent()
1 import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent' 1 import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
2 import { RmhRecommendDTO } from 'wdBean'; 2 import { RmhRecommendDTO } from 'wdBean';
3 -import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';  
4 3
5 @Component 4 @Component
6 export struct PeopleShipRecommendComponent { 5 export struct PeopleShipRecommendComponent {
@@ -103,8 +102,6 @@ export struct PeopleShipRecommendComponent { @@ -103,8 +102,6 @@ export struct PeopleShipRecommendComponent {
103 this.oneKeyFollow = true 102 this.oneKeyFollow = true
104 } 103 }
105 }) 104 })
106 - // 没有更多  
107 - PeopleShipNoMoreData()  
108 } 105 }
109 .width('100%') 106 .width('100%')
110 } 107 }