wangliang_wd

feat:增加直播间主持人发言弹出提示

1 import { ContentDetailDTO, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index'; 1 import { ContentDetailDTO, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index';
2 import { LiveViewModel } from '../viewModel/LiveViewModel'; 2 import { LiveViewModel } from '../viewModel/LiveViewModel';
3 -import { CustomToast, Logger, WindowModel } from 'wdKit/Index'; 3 +import { CustomToast, DisplayUtils, Logger, WindowModel } from 'wdKit/Index';
4 import { PlayerComponent } from '../widgets/vertical/PlayerComponent'; 4 import { PlayerComponent } from '../widgets/vertical/PlayerComponent';
5 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent'; 5 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent';
6 import { WDAliPlayerController } from 'wdPlayer/Index'; 6 import { WDAliPlayerController } from 'wdPlayer/Index';
@@ -14,6 +14,7 @@ import { StringUtils } from 'wdKit'; @@ -14,6 +14,7 @@ import { StringUtils } from 'wdKit';
14 import { LiveDetailChatRoomController } from '../im/LiveDetailChatRoomController'; 14 import { LiveDetailChatRoomController } from '../im/LiveDetailChatRoomController';
15 import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'; 15 import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean';
16 import { JSON } from '@kit.ArkTS'; 16 import { JSON } from '@kit.ArkTS';
  17 +import { ChartItemCompereComponent } from '../widgets/vertical/ChartItemCompereComponent';
17 18
18 const storage = LocalStorage.getShared(); 19 const storage = LocalStorage.getShared();
19 const TAG = 'DetailPlayVLivePage' 20 const TAG = 'DetailPlayVLivePage'
@@ -45,6 +46,9 @@ export struct DetailPlayVLivePage { @@ -45,6 +46,9 @@ export struct DetailPlayVLivePage {
45 @State showClearButton: boolean = false 46 @State showClearButton: boolean = false
46 @Consume liveDetailPageLogic: LiveDetailPageLogic 47 @Consume liveDetailPageLogic: LiveDetailPageLogic
47 @Provide lastInputedComment: LiveRoomItemBean = {} as LiveRoomItemBean // 上次输入的消息 48 @Provide lastInputedComment: LiveRoomItemBean = {} as LiveRoomItemBean // 上次输入的消息
  49 + @Provide hostInputedComment: LiveRoomItemBean = {} as LiveRoomItemBean // 是否是主持人发言
  50 +
  51 + @State hostCommentLeft: number = 0
48 //播放错误 52 //播放错误
49 @State isPlayerError: boolean = false 53 @State isPlayerError: boolean = false
50 @State isCanplay: boolean = false 54 @State isCanplay: boolean = false
@@ -54,6 +58,8 @@ export struct DetailPlayVLivePage { @@ -54,6 +58,8 @@ export struct DetailPlayVLivePage {
54 /// null 直播流画面类型未知,0 横屏流,1 竖屏流,后台选择画面时,以选择的为准 58 /// null 直播流画面类型未知,0 横屏流,1 竖屏流,后台选择画面时,以选择的为准
55 @Provide isVerticalStream: boolean | null = this.liveDetailPageLogic.dealLiveStreamType() 59 @Provide isVerticalStream: boolean | null = this.liveDetailPageLogic.dealLiveStreamType()
56 60
  61 + @State isDisplayHost: boolean = false
  62 +
57 dialogToast: CustomDialogController = new CustomDialogController({ 63 dialogToast: CustomDialogController = new CustomDialogController({
58 builder: CustomToast({ 64 builder: CustomToast({
59 bgColor: 0xB3000000, 65 bgColor: 0xB3000000,
@@ -107,7 +113,24 @@ export struct DetailPlayVLivePage { @@ -107,7 +113,24 @@ export struct DetailPlayVLivePage {
107 if (this.liveViewModel.filterMySelfCommentNoPreDisplay(liveRoomItemBean, preDisplay)) { 113 if (this.liveViewModel.filterMySelfCommentNoPreDisplay(liveRoomItemBean, preDisplay)) {
108 return 114 return
109 } 115 }
  116 + if (liveRoomItemBean.role === 'host') {
  117 + this.isDisplayHost = true
  118 + this.hostCommentLeft = - DisplayUtils.getDeviceWidth()
  119 + this.hostInputedComment = liveRoomItemBean
  120 + animateTo({
  121 + duration: 400,
  122 + onFinish: () => {
  123 + let t = setTimeout(()=>{
  124 + this.isDisplayHost = false
110 this.lastInputedComment = liveRoomItemBean 125 this.lastInputedComment = liveRoomItemBean
  126 + clearTimeout(t)
  127 + },2000)
  128 + }
  129 + }, () => {
  130 + this.hostCommentLeft = 0;
  131 + })
  132 +
  133 + }
111 } 134 }
112 this.chatRoomController.onLiveMessage = (liveRoomItemBean: LiveRoomItemBean) => { 135 this.chatRoomController.onLiveMessage = (liveRoomItemBean: LiveRoomItemBean) => {
113 switch (liveRoomItemBean.optionType) { 136 switch (liveRoomItemBean.optionType) {
@@ -262,8 +285,14 @@ export struct DetailPlayVLivePage { @@ -262,8 +285,14 @@ export struct DetailPlayVLivePage {
262 TrackingButton.click('clearScreen', TrackConstants.PageName.Live_Detail, 285 TrackingButton.click('clearScreen', TrackConstants.PageName.Live_Detail,
263 TrackConstants.PageName.Live_Detail) 286 TrackConstants.PageName.Live_Detail)
264 }) 287 })
  288 + }
265 289
  290 + Stack(){
  291 + ChartItemCompereComponent().width('100%').margin({left:this.hostCommentLeft})
266 } 292 }
  293 + .visibility(this.isDisplayHost?Visibility.Visible:Visibility.Hidden)
  294 + .height('100%')
  295 + .width('100%')
267 } 296 }
268 .height('100%') 297 .height('100%')
269 .width('100%') 298 .width('100%')
1 -import { ContentDetailDTO } from 'wdBean/Index' 1 +import { ContentDetailDTO, LiveRoomItemBean } from 'wdBean/Index'
  2 +import { DisplayUtils } from 'wdKit'
2 3
3 @Component 4 @Component
4 export struct ChartItemCompereComponent { 5 export struct ChartItemCompereComponent {
5 - // @Consume liveDetailsBean: LiveDetailsBean  
6 - @Consume contentDetailData: ContentDetailDTO 6 + @Consume hostInputedComment: LiveRoomItemBean
7 aboutToAppear(): void { 7 aboutToAppear(): void {
8 } 8 }
9 9
@@ -11,13 +11,14 @@ export struct ChartItemCompereComponent { @@ -11,13 +11,14 @@ export struct ChartItemCompereComponent {
11 ListItem() { 11 ListItem() {
12 Column() { 12 Column() {
13 Row() { 13 Row() {
14 - Image($r('app.media.default_head')) 14 + Image(this.hostInputedComment.senderUserAvatarUrl)
  15 + .alt($r('app.media.default_head'))
15 .borderRadius(10) 16 .borderRadius(10)
16 .width(20) 17 .width(20)
17 .height(20) 18 .height(20)
18 .margin({ right: 8 }) 19 .margin({ right: 8 })
19 20
20 - Text('人民日报') 21 + Text(this.hostInputedComment.senderUserName)
21 .fontSize(14) 22 .fontSize(14)
22 .fontColor('#FFFFFFFF') 23 .fontColor('#FFFFFFFF')
23 .margin({ right: 8 }) 24 .margin({ right: 8 })
@@ -32,7 +33,7 @@ export struct ChartItemCompereComponent { @@ -32,7 +33,7 @@ export struct ChartItemCompereComponent {
32 .margin({ bottom: 8 }) 33 .margin({ bottom: 8 })
33 .justifyContent(FlexAlign.Start) 34 .justifyContent(FlexAlign.Start)
34 35
35 - Text(this.contentDetailData.newIntroduction).lineHeight(22).fontColor('#FFFFFFFF').fontSize(14) 36 + Text(this.hostInputedComment.text).lineHeight(22).fontColor('#FFFFFFFF').fontSize(14)
36 } 37 }
37 .backgroundColor('#4D000000') 38 .backgroundColor('#4D000000')
38 .borderRadius(3) 39 .borderRadius(3)
@@ -42,7 +43,8 @@ export struct ChartItemCompereComponent { @@ -42,7 +43,8 @@ export struct ChartItemCompereComponent {
42 left: 8, 43 left: 8,
43 right: 8 44 right: 8
44 }) 45 })
45 - .margin({ left: 16, bottom: 4 }) 46 + .width(DisplayUtils.getDeviceWidth() - 32)
  47 + .margin({ left: 16, bottom: 4, right:16 })
46 .alignItems(HorizontalAlign.Start) 48 .alignItems(HorizontalAlign.Start)
47 } 49 }
48 50