liyubing

feat: 修改沉浸式页面 聊天室接口

@@ -207,6 +207,11 @@ export class HttpUrlUtils { @@ -207,6 +207,11 @@ export class HttpUrlUtils {
207 * 直播详情-大家聊列表 207 * 直播详情-大家聊列表
208 */ 208 */
209 static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list"; 209 static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list";
  210 +
  211 + /**
  212 + * C端评论列表 竖屏直播间
  213 + */
  214 + static readonly LIVE_COMMENTS_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/comments/list";
210 /** 215 /**
211 * 直播详情-直播数据 216 * 直播详情-直播数据
212 */ 217 */
@@ -655,6 +660,16 @@ export class HttpUrlUtils { @@ -655,6 +660,16 @@ export class HttpUrlUtils {
655 let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_CHAT_LIST_PATH 660 let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_CHAT_LIST_PATH
656 return url 661 return url
657 } 662 }
  663 +
  664 + /**
  665 + * 竖屏直播间 聊天信息接口
  666 + * @returns
  667 + */
  668 + static getLiveCommentListUrl() {
  669 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_COMMENTS_LIST_PATH
  670 + return url
  671 + }
  672 +
658 // 直播详情-直播数据 673 // 直播详情-直播数据
659 static getLiveRoomDataUrl() { 674 static getLiveRoomDataUrl() {
660 let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_DATA_PATH 675 let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_DATA_PATH
@@ -4,7 +4,7 @@ import router from '@ohos.router'; @@ -4,7 +4,7 @@ import router from '@ohos.router';
4 4
5 import { DetailPlayLivePage } from './DetailPlayLivePage'; 5 import { DetailPlayLivePage } from './DetailPlayLivePage';
6 import { DetailPlayVLivePage } from './DetailPlayVLivePage'; 6 import { DetailPlayVLivePage } from './DetailPlayVLivePage';
7 -import { Logger } from 'wdKit/Index'; 7 +import { Logger, ToastUtils } from 'wdKit/Index';
8 import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; 8 import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel';
9 9
10 const TAG = 'DetailPlayLiveCommon' 10 const TAG = 'DetailPlayLiveCommon'
@@ -71,7 +71,6 @@ export struct DetailPlayLiveCommon { @@ -71,7 +71,6 @@ export struct DetailPlayLiveCommon {
71 .then(async (data: Array<ContentDetailDTO>) => { 71 .then(async (data: Array<ContentDetailDTO>) => {
72 console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data)) 72 console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data))
73 if (data) { 73 if (data) {
74 -  
75 let detailData = data[0] 74 let detailData = data[0]
76 //人民号类型单独获取直播地址 75 //人民号类型单独获取直播地址
77 if (detailData.rmhPlatform === 1) { 76 if (detailData.rmhPlatform === 1) {
@@ -117,26 +116,18 @@ export struct DetailPlayLiveCommon { @@ -117,26 +116,18 @@ export struct DetailPlayLiveCommon {
117 } 116 }
118 117
119 118
  119 + } else {
  120 + ToastUtils.shortToast('内容不存在')
  121 + router.back()
120 } 122 }
  123 + },()=>{
  124 + ToastUtils.shortToast('内容不存在')
  125 + router.back()
  126 +
121 }) 127 })
122 } 128 }
123 129
124 - // /**  
125 - // *  
126 - // * @returns true : 沉浸式;false : 非沉浸式  
127 - // */  
128 - // isImmersionLive(): boolean {  
129 - //  
130 - // let flag = false  
131 - //  
132 - // if (this.liveState === 'wait' || this.liveLandscape === 'news') {  
133 - // flag = false  
134 - // } else if (this.liveLandscape === 'general') {  
135 - // flag = true  
136 - // }  
137 - //  
138 - // return flag  
139 - // } 130 +
140 131
141 onPageShow() { 132 onPageShow() {
142 this.pageShow = Math.random() 133 this.pageShow = Math.random()
@@ -93,10 +93,11 @@ export struct DetailPlayVLivePage { @@ -93,10 +93,11 @@ export struct DetailPlayVLivePage {
93 .aspectRatio(1) 93 .aspectRatio(1)
94 .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden) 94 .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden)
95 .position({ x: '100%', y: '100%' }) 95 .position({ x: '100%', y: '100%' })
96 - .markAnchor({ x: 56, y: 56 }) 96 + .markAnchor({ x: 56, y: this.bottomSafeHeight })
97 .onClick(() => { 97 .onClick(() => {
98 this.swiperController.showNext() 98 this.swiperController.showNext()
99 }) 99 })
  100 +
100 } 101 }
101 } 102 }
102 .height('100%') 103 .height('100%')
@@ -127,6 +127,42 @@ export class LiveModel { @@ -127,6 +127,42 @@ export class LiveModel {
127 }) 127 })
128 } 128 }
129 129
  130 +
  131 + /**
  132 + * C端评论列表 竖屏直播间
  133 + * @param pageNum
  134 + * @param mLiveId
  135 + * @param liveId
  136 + * @param pageSize
  137 + * @returns
  138 + */
  139 + getLiveCommentList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  140 + let params: Record<string, string> = {};
  141 + params['pageNum'] = pageNum + ''
  142 + params['mLiveId'] = mLiveId
  143 + params['liveId'] = liveId
  144 + params['pageSize'] = pageSize + ''
  145 + return new Promise<LiveRoomBean>((success, fail) => {
  146 + HttpRequest.post<ResponseDTO<LiveRoomBean>>(
  147 + HttpUrlUtils.getLiveCommentListUrl(),
  148 + params,
  149 + ).then((data: ResponseDTO<LiveRoomBean>) => {
  150 + if (!data || !data.data) {
  151 + fail("数据为空")
  152 + return
  153 + }
  154 + if (data.code != 0) {
  155 + fail(data.message)
  156 + return
  157 + }
  158 + success(data.data)
  159 + }, (error: Error) => {
  160 + fail(error.message)
  161 + Logger.debug(TAG + ":error ", error.toString())
  162 + })
  163 + })
  164 + }
  165 +
130 /** 166 /**
131 * 获取直播数据 167 * 获取直播数据
132 * @param liveId 168 * @param liveId
@@ -79,6 +79,17 @@ export class LiveViewModel { @@ -79,6 +79,17 @@ export class LiveViewModel {
79 }) 79 })
80 } 80 }
81 81
  82 + //C端评论列表 竖屏直播间
  83 + getLiveCommentList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  84 + return new Promise<LiveRoomBean>((success, fail) => {
  85 + this.liveModel.getLiveCommentList(pageNum, mLiveId, liveId, pageSize).then((data) => {
  86 + success(data)
  87 + }).catch((message: string) => {
  88 + fail(message)
  89 + })
  90 + })
  91 + }
  92 +
82 //直播详情直播间数据 93 //直播详情直播间数据
83 getLiveRoomData(liveId: string) { 94 getLiveRoomData(liveId: string) {
84 return new Promise<LiveRoomDataBean>((success, fail) => { 95 return new Promise<LiveRoomDataBean>((success, fail) => {
@@ -95,12 +95,12 @@ export struct TopPlayComponent { @@ -95,12 +95,12 @@ export struct TopPlayComponent {
95 } 95 }
96 } 96 }
97 97
98 -  
99 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' && 98 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' &&
100 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri) 99 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)
101 100
102 - Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)  
103 - if (!this.isWait && this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) { 101 + // Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)
  102 + if (!this.isWait) {
  103 + if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) {
104 let playUrl = '' 104 let playUrl = ''
105 if (this.contentDetailData.liveInfo.liveState == 'running') { 105 if (this.contentDetailData.liveInfo.liveState == 'running') {
106 playUrl = this.contentDetailData.liveInfo.vlive[0].liveUrl 106 playUrl = this.contentDetailData.liveInfo.vlive[0].liveUrl
@@ -118,6 +118,10 @@ export struct TopPlayComponent { @@ -118,6 +118,10 @@ export struct TopPlayComponent {
118 this.tryToPlay() 118 this.tryToPlay()
119 } 119 }
120 } 120 }
  121 + } else {
  122 + this.isWait = true
  123 + this.isLoading = true
  124 + }
121 } 125 }
122 126
123 // 文字直播 running 状态 127 // 文字直播 running 状态
@@ -13,7 +13,9 @@ import { router } from '@kit.ArkUI' @@ -13,7 +13,9 @@ import { router } from '@kit.ArkUI'
13 import { EmitterEventId, EmitterUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index' 13 import { EmitterEventId, EmitterUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index'
14 14
15 const TAG = "PlayerCommentComponent" 15 const TAG = "PlayerCommentComponent"
16 - 16 +/**
  17 + * 沉浸式直播--- 聊天区域
  18 + */
17 @Component 19 @Component
18 export struct PlayerCommentComponent { 20 export struct PlayerCommentComponent {
19 liveViewModel: LiveViewModel = new LiveViewModel() 21 liveViewModel: LiveViewModel = new LiveViewModel()
@@ -46,7 +48,7 @@ export struct PlayerCommentComponent { @@ -46,7 +48,7 @@ export struct PlayerCommentComponent {
46 48
47 getLiveChatList() { 49 getLiveChatList() {
48 this.pageModel.currentPage = 1 50 this.pageModel.currentPage = 1
49 - this.liveViewModel.getLiveChatList( 51 + this.liveViewModel.getLiveCommentList(
50 1, 52 1,
51 this.contentDetailData?.liveInfo?.mlive?.mliveId, 53 this.contentDetailData?.liveInfo?.mlive?.mliveId,
52 this.contentDetailData?.newsId+'', 54 this.contentDetailData?.newsId+'',
@@ -6,7 +6,8 @@ const TAG = 'PlayerComponent' @@ -6,7 +6,8 @@ const TAG = 'PlayerComponent'
6 6
7 @Component 7 @Component
8 export struct PlayerComponent { 8 export struct PlayerComponent {
9 - @Prop playerController: WDAliPlayerController; 9 +
  10 + private playerController?: WDAliPlayerController
10 @Consume @Watch('updateData') contentDetailData: ContentDetailDTO 11 @Consume @Watch('updateData') contentDetailData: ContentDetailDTO
11 @Consume @Watch('pageShowChange') pageShow: number 12 @Consume @Watch('pageShowChange') pageShow: number
12 @Consume @Watch('pageHideChange') pageHide: number 13 @Consume @Watch('pageHideChange') pageHide: number
@@ -3,10 +3,12 @@ import { ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Inde @@ -3,10 +3,12 @@ import { ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Inde
3 import { LiveFollowComponent, LottieView } from 'wdComponent/Index' 3 import { LiveFollowComponent, LottieView } from 'wdComponent/Index'
4 import { NumberFormatterUtils } from 'wdKit/Index' 4 import { NumberFormatterUtils } from 'wdKit/Index'
5 5
  6 +/**
  7 + * 沉浸式直播--- 头部标题
  8 + */
6 @Preview 9 @Preview
7 @Component 10 @Component
8 export struct PlayerTitleComponent { 11 export struct PlayerTitleComponent {
9 -// @Consume liveDetailsBean: LiveDetailsBean  
10 @Consume liveRoomDataBean: LiveRoomDataBean 12 @Consume liveRoomDataBean: LiveRoomDataBean
11 @Consume liveState: string 13 @Consume liveState: string
12 @Consume contentDetailData: ContentDetailDTO 14 @Consume contentDetailData: ContentDetailDTO
1 -import { ContentDetailDTO } from 'wdBean/Index';  
2 -import { WDAliPlayerController, WDPlayerController } from 'wdPlayer/Index'; 1 +import { WDAliPlayerController } from 'wdPlayer/Index';
3 import { PlayerCommentComponent } from './PlayerCommentComponent'; 2 import { PlayerCommentComponent } from './PlayerCommentComponent';
4 import { PlayerTitleComponent } from './PlayerTitleComponent'; 3 import { PlayerTitleComponent } from './PlayerTitleComponent';
5 import { PlayerVideoControlComponent } from './PlayerVideoControlComponent'; 4 import { PlayerVideoControlComponent } from './PlayerVideoControlComponent';
6 5
  6 +/**
  7 + * 沉浸直播 --- 横滑展示组件
  8 + */
7 @Component 9 @Component
8 export struct PlayerUIComponent { 10 export struct PlayerUIComponent {
9 private playerController?: WDAliPlayerController 11 private playerController?: WDAliPlayerController
@@ -12,10 +14,6 @@ export struct PlayerUIComponent { @@ -12,10 +14,6 @@ export struct PlayerUIComponent {
12 build() { 14 build() {
13 Stack() { 15 Stack() {
14 PlayerTitleComponent() 16 PlayerTitleComponent()
15 - // Row() {  
16 - // // 全屏与暂停按钮  
17 - // }.layoutWeight(1)  
18 -  
19 17
20 PlayerCommentComponent() 18 PlayerCommentComponent()
21 .visibility(this.isShowControl ? Visibility.Hidden : Visibility.Visible) 19 .visibility(this.isShowControl ? Visibility.Hidden : Visibility.Visible)
@@ -59,7 +59,8 @@ export struct WDPlayerRenderVLiveView { @@ -59,7 +59,8 @@ export struct WDPlayerRenderVLiveView {
59 59
60 this.playerController.onVideoSizeChange = (width: number, height: number) => { 60 this.playerController.onVideoSizeChange = (width: number, height: number) => {
61 // console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`) 61 // console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`)
62 - Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`) 62 + // Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`)
  63 + console.error(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`)
63 this.videoWidth = width; 64 this.videoWidth = width;
64 this.videoHeight = height; 65 this.videoHeight = height;
65 this.updateLayout() 66 this.updateLayout()