Showing
10 changed files
with
138 additions
and
116 deletions
| @@ -51,12 +51,12 @@ export struct OperRowListView { | @@ -51,12 +51,12 @@ export struct OperRowListView { | ||
| 51 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 | 51 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 |
| 52 | @ObjectLink publishCommentModel: publishCommentModel | 52 | @ObjectLink publishCommentModel: publishCommentModel |
| 53 | @State styleType: number = 1 | 53 | @State styleType: number = 1 |
| 54 | - // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 55 | @State interactData: InteractDataDTO = {} as InteractDataDTO | 54 | @State interactData: InteractDataDTO = {} as InteractDataDTO |
| 56 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 55 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 57 | @State likeBean: Record<string, string> = {} | 56 | @State likeBean: Record<string, string> = {} |
| 58 | @State audioUrl: string = '' | 57 | @State audioUrl: string = '' |
| 59 | @State bgColor: ResourceColor = Color.White | 58 | @State bgColor: ResourceColor = Color.White |
| 59 | + @State showCommentIcon: boolean = true | ||
| 60 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 60 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 61 | needLike: boolean = true | 61 | needLike: boolean = true |
| 62 | 62 | ||
| @@ -65,6 +65,7 @@ export struct OperRowListView { | @@ -65,6 +65,7 @@ export struct OperRowListView { | ||
| 65 | console.info(TAG, '3333----', this.needLike) | 65 | console.info(TAG, '3333----', this.needLike) |
| 66 | this.handleStyle() | 66 | this.handleStyle() |
| 67 | } | 67 | } |
| 68 | + | ||
| 68 | async onDetailUpdated() { | 69 | async onDetailUpdated() { |
| 69 | console.info(TAG, '111111----', this.styleType) | 70 | console.info(TAG, '111111----', this.styleType) |
| 70 | this.handleStyle() | 71 | this.handleStyle() |
| @@ -166,12 +167,15 @@ export struct OperRowListView { | @@ -166,12 +167,15 @@ export struct OperRowListView { | ||
| 166 | } | 167 | } |
| 167 | .flexShrink(1) | 168 | .flexShrink(1) |
| 168 | 169 | ||
| 169 | - Column() { | ||
| 170 | - if (this.publishCommentModel?.targetId) { | ||
| 171 | - CommentIconComponent({ publishCommentModel: this.publishCommentModel, styleType: this.styleType }) | 170 | + if (this.showCommentIcon) { |
| 171 | + Column() { | ||
| 172 | + if (this.publishCommentModel?.targetId) { | ||
| 173 | + CommentIconComponent({ publishCommentModel: this.publishCommentModel, styleType: this.styleType }) | ||
| 174 | + } | ||
| 172 | } | 175 | } |
| 176 | + .width(46) | ||
| 173 | } | 177 | } |
| 174 | - .width(46) | 178 | + |
| 175 | } | 179 | } |
| 176 | 180 | ||
| 177 | /** | 181 | /** |
| @@ -264,6 +268,8 @@ export struct OperRowListView { | @@ -264,6 +268,8 @@ export struct OperRowListView { | ||
| 264 | this.bgColor = Color.White | 268 | this.bgColor = Color.White |
| 265 | } else if (this.styleType == 2) { | 269 | } else if (this.styleType == 2) { |
| 266 | this.bgColor = Color.Black | 270 | this.bgColor = Color.Black |
| 271 | + } else if (this.styleType == 3) { | ||
| 272 | + this.bgColor = Color.Transparent | ||
| 267 | } | 273 | } |
| 268 | } | 274 | } |
| 269 | 275 |
| @@ -13,21 +13,21 @@ const TAG = 'DetailPlayLiveCommon' | @@ -13,21 +13,21 @@ const TAG = 'DetailPlayLiveCommon' | ||
| 13 | @Component | 13 | @Component |
| 14 | export struct DetailPlayLiveCommon { | 14 | export struct DetailPlayLiveCommon { |
| 15 | private liveViewModel: LiveViewModel = new LiveViewModel() | 15 | private liveViewModel: LiveViewModel = new LiveViewModel() |
| 16 | - @State liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | ||
| 17 | - @State liveState: string = '' | ||
| 18 | - @State liveStyle: number = -1 | ||
| 19 | - @State relId: string = '' | ||
| 20 | - @State contentId: string = '' | ||
| 21 | - @State relType: string = '' | 16 | + @Provide relId: string = '' |
| 17 | + @Provide contentId: string = '' | ||
| 18 | + @Provide relType: string = '' | ||
| 19 | + @Provide liveState: string = '' | ||
| 20 | + @Provide liveStyle: number = -1 | ||
| 21 | + @Provide playUrl: string = '' | ||
| 22 | + @Provide imgUrl: string = '' | ||
| 22 | @Provide pageShow: number = -1 | 23 | @Provide pageShow: number = -1 |
| 23 | @Provide pageHide: number = -1 | 24 | @Provide pageHide: number = -1 |
| 24 | @Provide pageBackPress: number = -1 | 25 | @Provide pageBackPress: number = -1 |
| 26 | + @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | ||
| 25 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 27 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 26 | @Provide publishCommentModel: publishCommentModel = new publishCommentModel() | 28 | @Provide publishCommentModel: publishCommentModel = new publishCommentModel() |
| 27 | 29 | ||
| 28 | async aboutToAppear(): Promise<void> { | 30 | async aboutToAppear(): Promise<void> { |
| 29 | - Logger.debug(TAG, 'aboutToAppear') | ||
| 30 | - //https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340 | ||
| 31 | const par: Action = router.getParams() as Action; | 31 | const par: Action = router.getParams() as Action; |
| 32 | const params = par?.params; | 32 | const params = par?.params; |
| 33 | this.relId = params?.extra?.relId || ''; | 33 | this.relId = params?.extra?.relId || ''; |
| @@ -43,7 +43,7 @@ export struct DetailPlayLiveCommon { | @@ -43,7 +43,7 @@ export struct DetailPlayLiveCommon { | ||
| 43 | if (this.liveState === 'wait' || this.liveStyle === 0) { | 43 | if (this.liveState === 'wait' || this.liveStyle === 0) { |
| 44 | DetailPlayLivePage({ contentId: this.contentId, relId: this.relId, relType: this.relType }) | 44 | DetailPlayLivePage({ contentId: this.contentId, relId: this.relId, relType: this.relType }) |
| 45 | } else if (this.liveStyle === 1) { | 45 | } else if (this.liveStyle === 1) { |
| 46 | - DetailPlayVLivePage({ contentId: this.contentId, relId: this.relId, relType: this.relType }) | 46 | + DetailPlayVLivePage() |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | .height('100%') | 49 | .height('100%') |
| @@ -70,6 +70,7 @@ export struct DetailPlayLiveCommon { | @@ -70,6 +70,7 @@ export struct DetailPlayLiveCommon { | ||
| 70 | this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) | 70 | this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId) |
| 71 | this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) | 71 | this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle) |
| 72 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) | 72 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType) |
| 73 | + this.publishCommentModel.commentContent = '' | ||
| 73 | // } | 74 | // } |
| 74 | } | 75 | } |
| 75 | }) | 76 | }) |
| @@ -86,6 +87,15 @@ export struct DetailPlayLiveCommon { | @@ -86,6 +87,15 @@ export struct DetailPlayLiveCommon { | ||
| 86 | this.liveDetailsBean = data[0] | 87 | this.liveDetailsBean = data[0] |
| 87 | this.liveState = this.liveDetailsBean.liveInfo?.liveState | 88 | this.liveState = this.liveDetailsBean.liveInfo?.liveState |
| 88 | this.liveStyle = this.liveDetailsBean.liveInfo.liveStyle | 89 | this.liveStyle = this.liveDetailsBean.liveInfo.liveStyle |
| 90 | + | ||
| 91 | + if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { | ||
| 92 | + this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + if (this.liveDetailsBean.liveInfo.liveState == 'end') { | ||
| 96 | + this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | ||
| 97 | + } | ||
| 98 | + | ||
| 89 | console.log(TAG, 'getLiveDetails:', JSON.stringify((this.liveDetailsBean))) | 99 | console.log(TAG, 'getLiveDetails:', JSON.stringify((this.liveDetailsBean))) |
| 90 | } | 100 | } |
| 91 | }, | 101 | }, |
| @@ -24,7 +24,6 @@ export struct DetailPlayLivePage { | @@ -24,7 +24,6 @@ export struct DetailPlayLivePage { | ||
| 24 | @State relId: string = '' | 24 | @State relId: string = '' |
| 25 | @State contentId: string = '' | 25 | @State contentId: string = '' |
| 26 | @State relType: string = '' | 26 | @State relType: string = '' |
| 27 | - @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | ||
| 28 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean | 27 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean |
| 29 | @State tabs: string[] = [] | 28 | @State tabs: string[] = [] |
| 30 | @State changeToTab: number = -1 | 29 | @State changeToTab: number = -1 |
| @@ -35,6 +34,7 @@ export struct DetailPlayLivePage { | @@ -35,6 +34,7 @@ export struct DetailPlayLivePage { | ||
| 35 | @Consume @Watch('onBackPressCus') pageBackPress: number | 34 | @Consume @Watch('onBackPressCus') pageBackPress: number |
| 36 | @Consume contentDetailData: ContentDetailDTO | 35 | @Consume contentDetailData: ContentDetailDTO |
| 37 | @Consume publishCommentModel: publishCommentModel | 36 | @Consume publishCommentModel: publishCommentModel |
| 37 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 38 | 38 | ||
| 39 | aboutToAppear(): void { | 39 | aboutToAppear(): void { |
| 40 | Logger.info(TAG, `wyj-aboutToAppear`) | 40 | Logger.info(TAG, `wyj-aboutToAppear`) |
| @@ -66,6 +66,7 @@ export struct DetailPlayLivePage { | @@ -66,6 +66,7 @@ export struct DetailPlayLivePage { | ||
| 66 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 66 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 67 | contentDetailData: this.contentDetailData, | 67 | contentDetailData: this.contentDetailData, |
| 68 | publishCommentModel: this.publishCommentModel, | 68 | publishCommentModel: this.publishCommentModel, |
| 69 | + showCommentIcon: false, | ||
| 69 | onCommentFocus: () => { | 70 | onCommentFocus: () => { |
| 70 | // 切换到大家聊 | 71 | // 切换到大家聊 |
| 71 | this.changeToTab = Math.random() | 72 | this.changeToTab = Math.random() |
| @@ -113,28 +114,20 @@ export struct DetailPlayLivePage { | @@ -113,28 +114,20 @@ export struct DetailPlayLivePage { | ||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | getLiveDetails() { | 116 | getLiveDetails() { |
| 116 | - this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType) | ||
| 117 | - .then( | ||
| 118 | - (data) => { | ||
| 119 | - if (data.length > 0) { | ||
| 120 | - if (data[0].liveInfo?.liveState == 'wait') { | ||
| 121 | - //直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】 | ||
| 122 | - if (data[0].liveInfo?.liveStyle == 1) { | ||
| 123 | - this.tabs = ['简介', '大家聊'] | ||
| 124 | - } else if (data[0].liveInfo?.liveStyle == 2) { | ||
| 125 | - this.tabs = ['简介', '直播间',] | ||
| 126 | - } else { | ||
| 127 | - this.tabs = ['简介', '直播间', '大家聊'] | ||
| 128 | - } | ||
| 129 | - } else { | ||
| 130 | - this.tabs = ['直播间', '大家聊'] | ||
| 131 | - } | ||
| 132 | - this.liveDetailsBean = data[0] | ||
| 133 | - } | ||
| 134 | - }, | ||
| 135 | - () => { | ||
| 136 | - | ||
| 137 | - }) | 117 | + const data = this.liveDetailsBean |
| 118 | + if (data.liveInfo?.liveState == 'wait') { | ||
| 119 | + //直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】 | ||
| 120 | + if (data.liveInfo?.liveStyle == 1) { | ||
| 121 | + this.tabs = ['简介', '大家聊'] | ||
| 122 | + } else if (data.liveInfo?.liveStyle == 2) { | ||
| 123 | + this.tabs = ['简介', '直播间',] | ||
| 124 | + } else { | ||
| 125 | + this.tabs = ['简介', '直播间', '大家聊'] | ||
| 126 | + } | ||
| 127 | + } else { | ||
| 128 | + this.tabs = ['直播间', '大家聊'] | ||
| 129 | + } | ||
| 130 | + | ||
| 138 | } | 131 | } |
| 139 | 132 | ||
| 140 | getLiveRoomData() { | 133 | getLiveRoomData() { |
| @@ -20,30 +20,21 @@ export struct DetailPlayVLivePage { | @@ -20,30 +20,21 @@ export struct DetailPlayVLivePage { | ||
| 20 | private swiperController: SwiperController = new SwiperController() | 20 | private swiperController: SwiperController = new SwiperController() |
| 21 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 21 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 22 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 22 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 23 | - @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | ||
| 24 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean | 23 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean |
| 25 | @Provide isShowControl: boolean = false | 24 | @Provide isShowControl: boolean = false |
| 26 | - @Provide liveState: string = '' | ||
| 27 | - @Provide playUrl: string = '' | ||
| 28 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL //横竖屏,默认竖屏 | 25 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL //横竖屏,默认竖屏 |
| 26 | + @Consume liveState: string | ||
| 27 | + @Consume liveStyle: number | ||
| 28 | + @Consume playUrl: string | ||
| 29 | + @Consume imgUrl: string | ||
| 29 | @Consume @Watch('openFullScreen') pageShow: number | 30 | @Consume @Watch('openFullScreen') pageShow: number |
| 30 | @Consume @Watch('closeFullScreen') pageHide: number | 31 | @Consume @Watch('closeFullScreen') pageHide: number |
| 31 | - @State relId: string = '' | ||
| 32 | - @State contentId: string = '' | ||
| 33 | - @State relType: string = '' | 32 | + @Consume contentId: string |
| 33 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 34 | @State swiperIndex: number = 1 | 34 | @State swiperIndex: number = 1 |
| 35 | - @State imgUrl: string = '' | ||
| 36 | 35 | ||
| 37 | aboutToAppear(): void { | 36 | aboutToAppear(): void { |
| 38 | - console.log(TAG, 'aboutToAppear') | ||
| 39 | this.openFullScreen() | 37 | this.openFullScreen() |
| 40 | - //https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340 | ||
| 41 | - let par: Action = router.getParams() as Action; | ||
| 42 | - let params = par?.params; | ||
| 43 | - this.relId = params?.extra?.relId || ''; | ||
| 44 | - this.relType = params?.extra?.relType || ''; | ||
| 45 | - this.contentId = params?.contentID || ''; | ||
| 46 | - this.getLiveDetails() | ||
| 47 | this.getLiveRoomData() | 38 | this.getLiveRoomData() |
| 48 | } | 39 | } |
| 49 | 40 | ||
| @@ -66,6 +57,7 @@ export struct DetailPlayVLivePage { | @@ -66,6 +57,7 @@ export struct DetailPlayVLivePage { | ||
| 66 | build() { | 57 | build() { |
| 67 | 58 | ||
| 68 | Stack() { | 59 | Stack() { |
| 60 | + // 直播背景图,模糊处理 | ||
| 69 | Image(this.imgUrl) | 61 | Image(this.imgUrl) |
| 70 | .height('100%') | 62 | .height('100%') |
| 71 | .width('100%') | 63 | .width('100%') |
| @@ -87,12 +79,13 @@ export struct DetailPlayVLivePage { | @@ -87,12 +79,13 @@ export struct DetailPlayVLivePage { | ||
| 87 | playerController: this.playerController | 79 | playerController: this.playerController |
| 88 | }) | 80 | }) |
| 89 | } | 81 | } |
| 82 | + | ||
| 90 | PlayerInfoComponent({ | 83 | PlayerInfoComponent({ |
| 91 | playerController: this.playerController, | 84 | playerController: this.playerController, |
| 92 | swiperController: this.swiperController, | 85 | swiperController: this.swiperController, |
| 93 | swiperIndex: $swiperIndex | 86 | swiperIndex: $swiperIndex |
| 94 | }) | 87 | }) |
| 95 | - | 88 | + // 清屏按钮 |
| 96 | Image($r('app.media.icon_live_more')) | 89 | Image($r('app.media.icon_live_more')) |
| 97 | .width(40) | 90 | .width(40) |
| 98 | .aspectRatio(1) | 91 | .aspectRatio(1) |
| @@ -103,37 +96,12 @@ export struct DetailPlayVLivePage { | @@ -103,37 +96,12 @@ export struct DetailPlayVLivePage { | ||
| 103 | this.swiperController.showNext() | 96 | this.swiperController.showNext() |
| 104 | }) | 97 | }) |
| 105 | } | 98 | } |
| 106 | - | ||
| 107 | - | ||
| 108 | } | 99 | } |
| 109 | .height('100%') | 100 | .height('100%') |
| 110 | .width('100%') | 101 | .width('100%') |
| 111 | 102 | ||
| 112 | } | 103 | } |
| 113 | 104 | ||
| 114 | - getLiveDetails() { | ||
| 115 | - this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType) | ||
| 116 | - .then( | ||
| 117 | - (data) => { | ||
| 118 | - if (data.length > 0) { | ||
| 119 | - this.liveDetailsBean = data[0] | ||
| 120 | - this.liveState = | ||
| 121 | - this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 | ||
| 122 | - if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) { | ||
| 123 | - this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - if (this.liveDetailsBean.liveInfo.liveState == 'end') { | ||
| 127 | - this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | ||
| 128 | - } | ||
| 129 | - console.log(TAG, 'getLiveDetails', JSON.stringify((this.liveDetailsBean))) | ||
| 130 | - } | ||
| 131 | - }, | ||
| 132 | - (message: string) => { | ||
| 133 | - console.error(TAG, 'getLiveDetails catch', message) | ||
| 134 | - }) | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | getLiveRoomData() { | 105 | getLiveRoomData() { |
| 138 | this.liveViewModel.getLiveRoomData(this.contentId) | 106 | this.liveViewModel.getLiveRoomData(this.contentId) |
| 139 | .then( | 107 | .then( |
| @@ -7,9 +7,10 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | @@ -7,9 +7,10 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | ||
| 7 | import { ViewType } from 'wdConstant/Index' | 7 | import { ViewType } from 'wdConstant/Index' |
| 8 | import { LiveViewModel } from '../../viewModel/LiveViewModel' | 8 | import { LiveViewModel } from '../../viewModel/LiveViewModel' |
| 9 | import { TabChatItemComponent } from './TabChatItemComponent' | 9 | import { TabChatItemComponent } from './TabChatItemComponent' |
| 10 | -import { Logger } from 'wdKit'; | 10 | +import { EmitterEventId, EmitterUtils, Logger } from 'wdKit'; |
| 11 | +import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel' | ||
| 11 | 12 | ||
| 12 | -const TAG: string = 'TabChatComponent'; | 13 | +const TAG: string = 'TabChatComponent'; |
| 13 | 14 | ||
| 14 | @Component | 15 | @Component |
| 15 | export struct TabChatComponent { | 16 | export struct TabChatComponent { |
| @@ -17,9 +18,28 @@ export struct TabChatComponent { | @@ -17,9 +18,28 @@ export struct TabChatComponent { | ||
| 17 | liveViewModel: LiveViewModel = new LiveViewModel() | 18 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 18 | @State liveChatList: Array<LiveRoomItemBean> = [] | 19 | @State liveChatList: Array<LiveRoomItemBean> = [] |
| 19 | @Consume liveDetailsBean: LiveDetailsBean | 20 | @Consume liveDetailsBean: LiveDetailsBean |
| 21 | + @Consume publishCommentModel: publishCommentModel | ||
| 20 | 22 | ||
| 21 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 22 | this.getLiveChatList() | 24 | this.getLiveChatList() |
| 25 | + | ||
| 26 | + //注册通知 | ||
| 27 | + EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, async (targetId?: string) => { | ||
| 28 | + if (targetId) { | ||
| 29 | + if (targetId == this.publishCommentModel.targetId) { | ||
| 30 | + const info = { | ||
| 31 | + senderUserAvatarUrl: this.publishCommentModel.lastCommentModel.fromUserHeader, | ||
| 32 | + senderUserName: this.publishCommentModel.lastCommentModel.fromUserName, | ||
| 33 | + text: this.publishCommentModel.lastCommentModel.commentContent, | ||
| 34 | + } as LiveRoomItemBean | ||
| 35 | + | ||
| 36 | + this.liveChatList.push(info) | ||
| 37 | + this.pageModel.viewType = ViewType.LOADED; | ||
| 38 | + // this.scroller.scrollEdge(Edge.Bottom) | ||
| 39 | + console.log(TAG, '发布评论:', JSON.stringify(this.publishCommentModel.lastCommentModel)) | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + }) | ||
| 23 | } | 43 | } |
| 24 | 44 | ||
| 25 | build() { | 45 | build() { |
| @@ -3,14 +3,14 @@ import { LiveCommentComponent } from 'wdComponent/Index' | @@ -3,14 +3,14 @@ import { LiveCommentComponent } from 'wdComponent/Index' | ||
| 3 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel' | 3 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel' |
| 4 | import { OperRowListView } from 'wdComponent/src/main/ets/components/view/OperRowListView' | 4 | import { OperRowListView } from 'wdComponent/src/main/ets/components/view/OperRowListView' |
| 5 | import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | 5 | import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' |
| 6 | -import { DisplayDirection, ViewType } from 'wdConstant/Index' | 6 | +import { DisplayDirection, SpConstants, ViewType } from 'wdConstant/Index' |
| 7 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | 7 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' |
| 8 | import { ResponseDTO } from 'wdNetwork/Index' | 8 | import { ResponseDTO } from 'wdNetwork/Index' |
| 9 | import { LiveViewModel } from '../../viewModel/LiveViewModel' | 9 | import { LiveViewModel } from '../../viewModel/LiveViewModel' |
| 10 | import { ChartItemCompereComponent } from './ChartItemCompereComponent' | 10 | import { ChartItemCompereComponent } from './ChartItemCompereComponent' |
| 11 | import { ChatItemComponent } from './ChartItemComponent' | 11 | import { ChatItemComponent } from './ChartItemComponent' |
| 12 | import { router } from '@kit.ArkUI' | 12 | import { router } from '@kit.ArkUI' |
| 13 | -import { WindowModel } from 'wdKit/Index' | 13 | +import { EmitterEventId, EmitterUtils, SPHelper, WindowModel } from 'wdKit/Index' |
| 14 | 14 | ||
| 15 | const TAG = "PlayerCommentComponent" | 15 | const TAG = "PlayerCommentComponent" |
| 16 | 16 | ||
| @@ -24,24 +24,37 @@ export struct PlayerCommentComponent { | @@ -24,24 +24,37 @@ export struct PlayerCommentComponent { | ||
| 24 | @State liveChatList: Array<LiveRoomItemBean> = [] | 24 | @State liveChatList: Array<LiveRoomItemBean> = [] |
| 25 | @Consume contentDetailData: ContentDetailDTO | 25 | @Consume contentDetailData: ContentDetailDTO |
| 26 | @Consume publishCommentModel: publishCommentModel | 26 | @Consume publishCommentModel: publishCommentModel |
| 27 | - @State contentId: string = '' | ||
| 28 | - @State relId: string = '' | ||
| 29 | - @State relType: string = '' | ||
| 30 | scroller: Scroller = new Scroller() | 27 | scroller: Scroller = new Scroller() |
| 31 | 28 | ||
| 32 | async aboutToAppear(): Promise<void> { | 29 | async aboutToAppear(): Promise<void> { |
| 33 | 30 | ||
| 34 | - const action: Action = router.getParams() as Action | ||
| 35 | - if (action) { | ||
| 36 | - this.contentId = action.params?.contentID || '' | ||
| 37 | - if (action.params && action.params.extra) { | ||
| 38 | - this.relId = action.params.extra.relId || '' | ||
| 39 | - this.relType = action.params.extra.relType || '' | 31 | + this.getLiveChatList() |
| 32 | + //注册通知 | ||
| 33 | + EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, async (targetId?: string) => { | ||
| 34 | + if (targetId) { | ||
| 35 | + if (targetId == this.publishCommentModel.targetId) { | ||
| 36 | + const info = { | ||
| 37 | + senderUserName: this.publishCommentModel.lastCommentModel.fromUserName, | ||
| 38 | + text: this.publishCommentModel.lastCommentModel.commentContent, | ||
| 39 | + } as LiveRoomItemBean | ||
| 40 | + | ||
| 41 | + this.liveChatList.push(info) | ||
| 42 | + this.scroller.scrollEdge(Edge.Bottom) | ||
| 43 | + console.log(TAG, '发布评论:', JSON.stringify(this.publishCommentModel.lastCommentModel)) | ||
| 44 | + } | ||
| 40 | } | 45 | } |
| 46 | + }) | ||
| 41 | 47 | ||
| 42 | - } | ||
| 43 | - this.getLiveChatList() | 48 | + } |
| 44 | 49 | ||
| 50 | + generateRandomString() { | ||
| 51 | + let result = ''; | ||
| 52 | + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | ||
| 53 | + const charactersLength = characters.length; | ||
| 54 | + for (let i = 0; i < 6; i++) { | ||
| 55 | + result += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
| 56 | + } | ||
| 57 | + return result; | ||
| 45 | } | 58 | } |
| 46 | 59 | ||
| 47 | liveDetailsBeanChange() { | 60 | liveDetailsBeanChange() { |
| @@ -99,11 +112,13 @@ export struct PlayerCommentComponent { | @@ -99,11 +112,13 @@ export struct PlayerCommentComponent { | ||
| 99 | .scrollBar(BarState.Off) | 112 | .scrollBar(BarState.Off) |
| 100 | .margin({ bottom: 20 }) | 113 | .margin({ bottom: 20 }) |
| 101 | 114 | ||
| 115 | + // 收藏、分享、点赞是否需要根据字段显隐 | ||
| 102 | OperRowListView({ | 116 | OperRowListView({ |
| 103 | - bgColor: Color.Transparent, | 117 | + styleType: 3, |
| 104 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 118 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 105 | contentDetailData: this.contentDetailData, | 119 | contentDetailData: this.contentDetailData, |
| 106 | publishCommentModel: this.publishCommentModel, | 120 | publishCommentModel: this.publishCommentModel, |
| 121 | + showCommentIcon: false, | ||
| 107 | onBack: () => { | 122 | onBack: () => { |
| 108 | WindowModel.shared.setWindowLayoutFullScreen(false) | 123 | WindowModel.shared.setWindowLayoutFullScreen(false) |
| 109 | WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) | 124 | WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) |
| @@ -36,6 +36,7 @@ export struct DetailPlayShortVideoPage { | @@ -36,6 +36,7 @@ export struct DetailPlayShortVideoPage { | ||
| 36 | @Consume @Watch('pageShowChange') pageShow: number | 36 | @Consume @Watch('pageShowChange') pageShow: number |
| 37 | @Consume topSafeHeight: number | 37 | @Consume topSafeHeight: number |
| 38 | @State imageVisible: boolean = true | 38 | @State imageVisible: boolean = true |
| 39 | + @Consume windowWidth: number | ||
| 39 | 40 | ||
| 40 | /** | 41 | /** |
| 41 | * 页面显示重查用户关注、点赞等信息 | 42 | * 页面显示重查用户关注、点赞等信息 |
| @@ -71,7 +72,7 @@ export struct DetailPlayShortVideoPage { | @@ -71,7 +72,7 @@ export struct DetailPlayShortVideoPage { | ||
| 71 | currentIndexChange() { | 72 | currentIndexChange() { |
| 72 | if (this.currentIndex != this.index) { | 73 | if (this.currentIndex != this.index) { |
| 73 | this.playerController.pause() | 74 | this.playerController.pause() |
| 74 | - if (this.index < this.currentIndex - 3 && this.playerController.getPlayer()) { | 75 | + if (this.index <= this.currentIndex - 2 && this.playerController.getPlayer()) { |
| 75 | this.playerController.release() | 76 | this.playerController.release() |
| 76 | } | 77 | } |
| 77 | 78 | ||
| @@ -171,24 +172,26 @@ export struct DetailPlayShortVideoPage { | @@ -171,24 +172,26 @@ export struct DetailPlayShortVideoPage { | ||
| 171 | .width('100%') | 172 | .width('100%') |
| 172 | } | 173 | } |
| 173 | 174 | ||
| 175 | + /** | ||
| 176 | + * 视频首帧图,用于快速显示 | ||
| 177 | + * 竖屏封面顶部仍然有点偏移,待处理 | ||
| 178 | + */ | ||
| 174 | @Builder | 179 | @Builder |
| 175 | playerCoverBuilder() { | 180 | playerCoverBuilder() { |
| 176 | - Image(this.contentDetailData?.videoInfo?.[0]?.firstFrameImageUri) | 181 | + Image(this.contentDetailData?.firstFrameImageUri) |
| 177 | .width('100%') | 182 | .width('100%') |
| 178 | - .height('auto') | ||
| 179 | - .margin({ | ||
| 180 | - top: this.topSafeHeight + 'px' | ||
| 181 | - }) | ||
| 182 | .padding({ | 183 | .padding({ |
| 183 | bottom: this.videoLandScape === 1 ? 115 : 0, | 184 | bottom: this.videoLandScape === 1 ? 115 : 0, |
| 184 | - }) | ||
| 185 | - .align(this.videoLandScape === 0 ? Alignment.Top : Alignment.Center) | 185 | + })// .align(this.videoLandScape === 0 ? Alignment.Top : Alignment.Center) |
| 186 | + .fitOriginalSize(true) | ||
| 187 | + .autoResize(true) | ||
| 188 | + .position({ x: 0, y: this.videoLandScape === 0 ? 0 : '50%' }) | ||
| 189 | + .markAnchor({ y: this.videoLandScape === 0 ? 0 : '50%' }) | ||
| 186 | // .visibility(this.imageVisible ? Visibility.Visible : Visibility.None) | 190 | // .visibility(this.imageVisible ? Visibility.Visible : Visibility.None) |
| 187 | } | 191 | } |
| 188 | 192 | ||
| 189 | @Builder | 193 | @Builder |
| 190 | playerViewBuilder() { | 194 | playerViewBuilder() { |
| 191 | - // 播放窗口 | ||
| 192 | WDPlayerRenderView({ | 195 | WDPlayerRenderView({ |
| 193 | playerController: this.playerController, | 196 | playerController: this.playerController, |
| 194 | onLoad: async () => { | 197 | onLoad: async () => { |
| @@ -243,7 +243,7 @@ export struct VideoChannelDetail { | @@ -243,7 +243,7 @@ export struct VideoChannelDetail { | ||
| 243 | }, (item: ContentDetailDTO) => item.newsId + '') | 243 | }, (item: ContentDetailDTO) => item.newsId + '') |
| 244 | } | 244 | } |
| 245 | .visibility(this.isMouted ? Visibility.Visible : Visibility.None) | 245 | .visibility(this.isMouted ? Visibility.Visible : Visibility.None) |
| 246 | - .cachedCount(-1) | 246 | + // .cachedCount(1) |
| 247 | .indicator(false) | 247 | .indicator(false) |
| 248 | .vertical(true) | 248 | .vertical(true) |
| 249 | .loop(false) | 249 | .loop(false) |
| 1 | import router from '@ohos.router'; | 1 | import router from '@ohos.router'; |
| 2 | +import { ContentDetailDTO } from 'wdBean/Index'; | ||
| 2 | 3 | ||
| 3 | @Component | 4 | @Component |
| 4 | export struct PlayerCommentView { | 5 | export struct PlayerCommentView { |
| 5 | @Consume showComment?: boolean | 6 | @Consume showComment?: boolean |
| 6 | @Consume isOpenDetail?: boolean | 7 | @Consume isOpenDetail?: boolean |
| 8 | + @Consume contentDetailData: ContentDetailDTO | ||
| 7 | @State comment: string = ''; | 9 | @State comment: string = ''; |
| 8 | 10 | ||
| 9 | build() { | 11 | build() { |
| @@ -16,17 +18,20 @@ export struct PlayerCommentView { | @@ -16,17 +18,20 @@ export struct PlayerCommentView { | ||
| 16 | router.back(); | 18 | router.back(); |
| 17 | }) | 19 | }) |
| 18 | 20 | ||
| 19 | - TextInput({ placeholder: '说两句...', text: this.comment }) | ||
| 20 | - .placeholderColor('#999999') | ||
| 21 | - .placeholderFont({ size: 14 }) | ||
| 22 | - .fontColor(Color.White) | ||
| 23 | - .fontSize(14) | ||
| 24 | - .maxLines(1) | ||
| 25 | - .layoutWeight(1) | ||
| 26 | - .backgroundColor('#1a1a1a') | ||
| 27 | - .borderRadius(2) | ||
| 28 | - .height(30) | ||
| 29 | - .margin({ left: 12 }) | 21 | + if (this.contentDetailData.openComment === 1) { |
| 22 | + TextInput({ placeholder: '说两句...', text: this.comment }) | ||
| 23 | + .placeholderColor('#999999') | ||
| 24 | + .placeholderFont({ size: 14 }) | ||
| 25 | + .fontColor(Color.White) | ||
| 26 | + .fontSize(14) | ||
| 27 | + .maxLines(1) | ||
| 28 | + .layoutWeight(1) | ||
| 29 | + .backgroundColor('#1a1a1a') | ||
| 30 | + .borderRadius(2) | ||
| 31 | + .height(30) | ||
| 32 | + .margin({ left: 12 }) | ||
| 33 | + } | ||
| 34 | + | ||
| 30 | } | 35 | } |
| 31 | .backgroundColor(Color.Black) | 36 | .backgroundColor(Color.Black) |
| 32 | .alignItems(VerticalAlign.Center) | 37 | .alignItems(VerticalAlign.Center) |
| @@ -167,7 +167,9 @@ export struct PlayerRightView { | @@ -167,7 +167,9 @@ export struct PlayerRightView { | ||
| 167 | this.userBuilderView() | 167 | this.userBuilderView() |
| 168 | this.likeBuilderView() | 168 | this.likeBuilderView() |
| 169 | this.collectBuilderView() | 169 | this.collectBuilderView() |
| 170 | - this.commentBuilderView() | 170 | + if (this.contentDetailData.openComment === 1) { |
| 171 | + this.commentBuilderView() | ||
| 172 | + } | ||
| 171 | this.shareBuilderView() | 173 | this.shareBuilderView() |
| 172 | 174 | ||
| 173 | } | 175 | } |
-
Please register or login to post a comment