王士厅
  1 +/**
  2 + * 点赞、已读、分享数量
  3 + */
  4 +export interface InteractDataDTO {
  5 + collectNum: number;
  6 + commentNum: number;
  7 + contentType: number;
  8 + likeNum: number;
  9 + readNum: number;
  10 + shareNum: number;
  11 + contentId: string;
  12 +}
1 import { Logger, ResourcesUtils } from 'wdKit'; 1 import { Logger, ResourcesUtils } from 'wdKit';
2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
3 -import { ContentDetailDTO } from 'wdBean'; 3 +import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
4 import HashMap from '@ohos.util.HashMap'; 4 import HashMap from '@ohos.util.HashMap';
5 5
6 const TAG = 'ContentDetailRequest'; 6 const TAG = 'ContentDetailRequest';
@@ -18,6 +18,15 @@ export interface recommentVideoListParame { @@ -18,6 +18,15 @@ export interface recommentVideoListParame {
18 refreshCnt: number; 18 refreshCnt: number;
19 } 19 }
20 20
  21 +interface contentListItem {
  22 + contentId: string;
  23 + contentType: number;
  24 +}
  25 +
  26 +export interface contentListParams {
  27 + contentList: contentListItem[];
  28 +}
  29 +
21 30
22 export class ContentDetailRequest { 31 export class ContentDetailRequest {
23 static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> { 32 static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
@@ -55,10 +64,10 @@ export class ContentDetailRequest { @@ -55,10 +64,10 @@ export class ContentDetailRequest {
55 * 64 *
56 * @returns 65 * @returns
57 */ 66 */
58 - static getContentInteract() { 67 + static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
59 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH 68 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
60 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 69 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
61 - return WDHttp.get(url, headers) 70 + return WDHttp.post0(url, params, headers)
62 } 71 }
63 72
64 /** 73 /**
1 import router from '@ohos.router'; 1 import router from '@ohos.router';
2 import mediaquery from '@ohos.mediaquery'; 2 import mediaquery from '@ohos.mediaquery';
3 import window from '@ohos.window'; 3 import window from '@ohos.window';
4 -import { Action, ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean'; 4 +import { Action, ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean';
5 import { Logger, SPHelper, WindowModel } from 'wdKit'; 5 import { Logger, SPHelper, WindowModel } from 'wdKit';
6 import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; 6 import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
7 import { devicePLSensorManager } from 'wdDetailPlayApi'; 7 import { devicePLSensorManager } from 'wdDetailPlayApi';
@@ -22,6 +22,7 @@ export struct DetailPlayShortVideoPage { @@ -22,6 +22,7 @@ export struct DetailPlayShortVideoPage {
22 private relId?: string = undefined 22 private relId?: string = undefined
23 private relType?: string = undefined 23 private relType?: string = undefined
24 private contentDetailData: ContentDetailDTO | undefined = undefined 24 private contentDetailData: ContentDetailDTO | undefined = undefined
  25 + @Provide interactData: InteractDataDTO | undefined = undefined
25 @Prop @Watch('currentIndexChange') currentIndex: number = 0 26 @Prop @Watch('currentIndexChange') currentIndex: number = 0
26 private index: number = 0 27 private index: number = 0
27 private playerController: WDPlayerController = new WDPlayerController(); 28 private playerController: WDPlayerController = new WDPlayerController();
1 -import { Action, ContentDetailDTO } from 'wdBean/Index'; 1 +import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index';
2 import { ContentDetailRequest } from 'wdDetailPlayApi/Index' 2 import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
3 import { ResponseDTO } from 'wdNetwork/Index'; 3 import { ResponseDTO } from 'wdNetwork/Index';
4 import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' 4 import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
5 import { Test } from './Test' 5 import { Test } from './Test'
6 import router from '@ohos.router'; 6 import router from '@ohos.router';
7 import window from '@ohos.window'; 7 import window from '@ohos.window';
  8 +import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
  9 +
8 10
9 @Entry 11 @Entry
10 @Component 12 @Component
@@ -16,6 +18,7 @@ export struct DetailVideoListPage { @@ -16,6 +18,7 @@ export struct DetailVideoListPage {
16 @State data: ContentDetailDTO[] = [] 18 @State data: ContentDetailDTO[] = []
17 @State testData: string[] = ['111', '222', '333'] 19 @State testData: string[] = ['111', '222', '333']
18 @State currentIndex: number = 0 20 @State currentIndex: number = 0
  21 + @State interactDataList: InteractDataDTO[] = []
19 22
20 async aboutToAppear(): Promise<void> { 23 async aboutToAppear(): Promise<void> {
21 console.error('=================',) 24 console.error('=================',)
@@ -47,11 +50,32 @@ export struct DetailVideoListPage { @@ -47,11 +50,32 @@ export struct DetailVideoListPage {
47 if (res.data) { 50 if (res.data) {
48 data = data.concat(res.data) 51 data = data.concat(res.data)
49 } 52 }
50 - // this.data = res.data || []  
51 console.log('res1===', JSON.stringify(res)) 53 console.log('res1===', JSON.stringify(res))
52 console.log('res==' + this.data) 54 console.log('res==' + this.data)
53 }) 55 })
54 56
  57 +
  58 + if (data.length > 0) {
  59 + const params: contentListParams = {
  60 + contentList: []
  61 + }
  62 + data.map(item => {
  63 + params.contentList.push({
  64 + contentId: item.newsId + '',
  65 + contentType: item.newsType
  66 + })
  67 + })
  68 + // 批量查询内容当前用户点赞、收藏状态
  69 + await ContentDetailRequest.getContentInteract(params).then(res => {
  70 + if (res.data) {
  71 + this.interactDataList = res.data || []
  72 + }
  73 + console.log('获取互动点赞等数据===', JSON.stringify(res))
  74 + })
  75 + // 查询各类型内容动态数据接口V2
  76 +
  77 + }
  78 +
55 this.data = data 79 this.data = data
56 console.error('aboutToAppear===', this.data.length) 80 console.error('aboutToAppear===', this.data.length)
57 81
@@ -67,7 +91,8 @@ export struct DetailVideoListPage { @@ -67,7 +91,8 @@ export struct DetailVideoListPage {
67 DetailPlayShortVideoPage({ 91 DetailPlayShortVideoPage({
68 contentDetailData: item, 92 contentDetailData: item,
69 currentIndex: this.currentIndex, 93 currentIndex: this.currentIndex,
70 - index: index 94 + index: index,
  95 + interactData: this.interactDataList[index]
71 }) 96 })
72 }.width('100%') 97 }.width('100%')
73 .height('100%') 98 .height('100%')
1 -import { RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; 1 +import { InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
2 import { ToastUtils } from 'wdKit'; 2 import { ToastUtils } from 'wdKit';
3 3
4 export interface OperationItem { 4 export interface OperationItem {
@@ -13,25 +13,27 @@ const FULL_PARENT: string = '100%'; @@ -13,25 +13,27 @@ const FULL_PARENT: string = '100%';
13 13
14 const TAG = 'OperationListView'; 14 const TAG = 'OperationListView';
15 15
  16 +@Preview
16 @Component 17 @Component
17 export struct OperationListView { 18 export struct OperationListView {
18 @Consume rmhInfo?: RmhInfoDTO 19 @Consume rmhInfo?: RmhInfoDTO
19 @Consume userInfo?: UserInfoDTO 20 @Consume userInfo?: UserInfoDTO
  21 + @Consume interactData: InteractDataDTO
20 @State operationList: OperationItem[] = [ 22 @State operationList: OperationItem[] = [
21 { 23 {
22 icon: $r('app.media.ic_like_uncheck'), 24 icon: $r('app.media.ic_like_uncheck'),
23 text: "赞", 25 text: "赞",
24 - num: 6622 26 + // num: 6622
25 }, 27 },
26 { 28 {
27 icon: $r('app.media.ic_collect_uncheck'), 29 icon: $r('app.media.ic_collect_uncheck'),
28 text: "收藏", 30 text: "收藏",
29 - num: 662, 31 + // num: 662,
30 }, 32 },
31 { 33 {
32 icon: $r('app.media.ic_comment'), 34 icon: $r('app.media.ic_comment'),
33 - text: "评论",  
34 - num: 500, 35 + text: "抢首评",
  36 + // num: 500,
35 }, 37 },
36 { 38 {
37 icon: $r('app.media.ic_share'), 39 icon: $r('app.media.ic_share'),
@@ -76,11 +78,12 @@ export struct OperationListView { @@ -76,11 +78,12 @@ export struct OperationListView {
76 buildUserComp() { 78 buildUserComp() {
77 Column() { 79 Column() {
78 Image(this.rmhInfo?.rmhHeadUrl || this.userInfo?.userHeadUrl) 80 Image(this.rmhInfo?.rmhHeadUrl || this.userInfo?.userHeadUrl)
79 - .width(48) 81 + .width('100%')
80 .borderRadius(24) 82 .borderRadius(24)
81 .aspectRatio(1) 83 .aspectRatio(1)
82 - // .margin(18)  
83 - } 84 + .border({ width: 1, color: Color.White, style: BorderStyle.Solid })
  85 + .margin({ bottom: 30 })
  86 + }.width(48)
84 } 87 }
85 88
86 /** 89 /**
@@ -92,20 +95,50 @@ export struct OperationListView { @@ -92,20 +95,50 @@ export struct OperationListView {
92 buildOperationItem(item: OperationItem, index: number) { 95 buildOperationItem(item: OperationItem, index: number) {
93 Column() { 96 Column() {
94 Image(item.icon) 97 Image(item.icon)
95 - .width('100%') 98 + .width(32)
96 .aspectRatio(1) 99 .aspectRatio(1)
97 // .borderRadius(6) 100 // .borderRadius(6)
98 - 101 + if (item.text === '赞') {
  102 + Text(this.interactData.likeNum ? (this.interactData.likeNum + '') : item.text)
  103 + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
  104 + .fontWeight(500)
  105 + .textAlign(TextAlign.Center)
  106 + .fontSize(13)
  107 + .fontColor('#FFFFFF')
  108 + .maxLines(1)
  109 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  110 + } else if (item.text === '收藏') {
  111 + Text(this.interactData.collectNum ? (this.interactData.collectNum + '') : item.text)
  112 + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
  113 + .fontWeight(500)
  114 + .textAlign(TextAlign.Center)
  115 + .fontSize(13)
  116 + .fontColor('#FFFFFF')
  117 + .maxLines(1)
  118 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  119 + } else if (item.text === '抢首评') {
  120 + Text(this.interactData.commentNum ? (this.interactData.commentNum + '') : item.text)
  121 + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
  122 + .fontWeight(500)
  123 + .textAlign(TextAlign.Center)
  124 + .fontSize(13)
  125 + .fontColor('#FFFFFF')
  126 + .maxLines(1)
  127 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  128 + } else {
99 Text(item.text) 129 Text(item.text)
100 .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) 130 .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
101 - .fontWeight(FontWeight.Normal) 131 + .fontWeight(500)
102 .textAlign(TextAlign.Center) 132 .textAlign(TextAlign.Center)
103 .fontSize(13) 133 .fontSize(13)
104 .fontColor('#FFFFFF') 134 .fontColor('#FFFFFF')
105 .maxLines(1) 135 .maxLines(1)
106 .textOverflow({ overflow: TextOverflow.Ellipsis }) 136 .textOverflow({ overflow: TextOverflow.Ellipsis })
107 } 137 }
108 - .margin(5) 138 +
  139 + }
  140 + .width(32)
  141 + .margin({ bottom: 20 })
109 // .backgroundColor(Color.Black) 142 // .backgroundColor(Color.Black)
110 .alignItems(HorizontalAlign.Center) 143 .alignItems(HorizontalAlign.Center)
111 .hoverEffect(HoverEffect.Scale) 144 .hoverEffect(HoverEffect.Scale)