wangyujian_wd

feat:1)直播详情-直播间和大家聊接口调试

@@ -192,6 +192,15 @@ export class HttpUrlUtils { @@ -192,6 +192,15 @@ export class HttpUrlUtils {
192 static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; 192 static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
193 193
194 /** 194 /**
  195 + * 直播详情-直播间列表
  196 + */
  197 + static readonly LIVE_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/video/list";
  198 +
  199 + /**
  200 + * 直播详情-大家聊列表
  201 + */
  202 + static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list";
  203 + /**
195 204
196 * 搜索结果 显示tab 数 205 * 搜索结果 显示tab 数
197 */ 206 */
@@ -588,6 +597,16 @@ export class HttpUrlUtils { @@ -588,6 +597,16 @@ export class HttpUrlUtils {
588 return url 597 return url
589 } 598 }
590 599
  600 + static getLiveListUrl() {
  601 + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_LIST_PATH
  602 + return url
  603 + }
  604 +
  605 + static getLiveChatListUrl() {
  606 + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_CHAT_LIST_PATH
  607 + return url
  608 + }
  609 +
591 static getSearchResultCountDataUrl() { 610 static getSearchResultCountDataUrl() {
592 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH 611 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH
593 return url 612 return url
@@ -113,3 +113,6 @@ export { LiveDetailsBean } from './src/main/ets/bean/live/LiveDetailsBean'; @@ -113,3 +113,6 @@ export { LiveDetailsBean } from './src/main/ets/bean/live/LiveDetailsBean';
113 export { ArticleListDTO } from './src/main/ets/bean/component/ArticleListDTO'; 113 export { ArticleListDTO } from './src/main/ets/bean/component/ArticleListDTO';
114 114
115 export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO'; 115 export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO';
  116 +
  117 +export { LiveRoomBean,LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean';
  118 +
  1 +export interface LiveRoomBean {
  2 + pageNum: number
  3 + pageSize: number
  4 + totalCount: number
  5 + barrageResponses: Array<LiveRoomItemBean>
  6 +}
  7 +
  8 +export interface LiveRoomItemBean {
  9 + text: string
  10 + senderUserAvatarUrl: string
  11 + senderUserName: string
  12 + pictureUrls: string[]
  13 + time: string
  14 + //1上墙0未上墙
  15 + isWall: number
  16 + //是否置顶 1置顶0不置顶
  17 + isTop: number
  18 + role: string
  19 +}
@@ -2,6 +2,7 @@ import { LiveDetailsBean } from 'wdBean/Index'; @@ -2,6 +2,7 @@ import { LiveDetailsBean } from 'wdBean/Index';
2 import { LiveViewModel } from '../viewModel/LiveViewModel'; 2 import { LiveViewModel } from '../viewModel/LiveViewModel';
3 import { BottomComponent } from '../widgets/details/BottomComponent'; 3 import { BottomComponent } from '../widgets/details/BottomComponent';
4 import { TabComponent } from '../widgets/details/TabComponent'; 4 import { TabComponent } from '../widgets/details/TabComponent';
  5 +import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
5 6
6 @Entry 7 @Entry
7 @Component 8 @Component
@@ -16,7 +17,7 @@ export struct DetailPlayLivePage { @@ -16,7 +17,7 @@ export struct DetailPlayLivePage {
16 17
17 build() { 18 build() {
18 Column() { 19 Column() {
19 - // TopPlayComponent({playUrl:this.playUrl}) 20 + TopPlayComponent({playUrl:'http://mlive3.video.weibocdn.com/record/alicdn/5018726527666338/index.m3u8'})
20 TabComponent() 21 TabComponent()
21 BottomComponent() 22 BottomComponent()
22 } 23 }
@@ -2,7 +2,7 @@ import HashMap from '@ohos.util.HashMap'; @@ -2,7 +2,7 @@ import HashMap from '@ohos.util.HashMap';
2 import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; 2 import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
4 import { Logger } from 'wdKit'; 4 import { Logger } from 'wdKit';
5 -import { LiveDetailsBean } from 'wdBean/Index'; 5 +import { LiveDetailsBean, LiveRoomBean } from 'wdBean/Index';
6 6
7 const TAG = 'LiveModel' 7 const TAG = 'LiveModel'
8 8
@@ -34,7 +34,78 @@ export class LiveModel { @@ -34,7 +34,78 @@ export class LiveModel {
34 Logger.debug(TAG + ":error ", error.toString()) 34 Logger.debug(TAG + ":error ", error.toString())
35 }) 35 })
36 }) 36 })
  37 + }
37 38
  39 + /**
  40 + * 获取直播详情页面直播间数据列表
  41 + * @param pageNum
  42 + * @param mLiveId
  43 + * @param liveId
  44 + * @param pageSize
  45 + * @returns
  46 + */
  47 + getLiveList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  48 + let params: Record<string, string> = {};
  49 + params['pageNum'] = pageNum + ''
  50 + params['mLiveId'] = mLiveId
  51 + params['liveId'] = liveId
  52 + params['pageSize'] = pageSize + ''
  53 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  54 + return new Promise<LiveRoomBean>((success, fail) => {
  55 + HttpRequest.post<ResponseDTO<LiveRoomBean>>(
  56 + HttpUrlUtils.getLiveListUrl(),
  57 + params,
  58 + headers).then((data: ResponseDTO<LiveRoomBean>) => {
  59 + if (!data || !data.data) {
  60 + fail("数据为空")
  61 + return
  62 + }
  63 + if (data.code != 0) {
  64 + fail(data.message)
  65 + return
  66 + }
  67 + success(data.data)
  68 + }, (error: Error) => {
  69 + fail(error.message)
  70 + Logger.debug(TAG + ":error ", error.toString())
  71 + })
  72 + })
  73 + }
  74 +
  75 + /**
  76 + * 获取直播详情页面大家聊数据列表
  77 + * @param pageNum
  78 + * @param mLiveId
  79 + * @param liveId
  80 + * @param pageSize
  81 + * @returns
  82 + */
  83 + getLiveChatList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  84 + let params: Record<string, string> = {};
  85 + params['pageNum'] = pageNum + ''
  86 + params['mLiveId'] = mLiveId
  87 + params['liveId'] = liveId
  88 + params['pageSize'] = pageSize + ''
  89 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  90 + return new Promise<LiveRoomBean>((success, fail) => {
  91 + HttpRequest.post<ResponseDTO<LiveRoomBean>>(
  92 + HttpUrlUtils.getLiveChatListUrl(),
  93 + params,
  94 + headers).then((data: ResponseDTO<LiveRoomBean>) => {
  95 + if (!data || !data.data) {
  96 + fail("数据为空")
  97 + return
  98 + }
  99 + if (data.code != 0) {
  100 + fail(data.message)
  101 + return
  102 + }
  103 + success(data.data)
  104 + }, (error: Error) => {
  105 + fail(error.message)
  106 + Logger.debug(TAG + ":error ", error.toString())
  107 + })
  108 + })
38 } 109 }
39 } 110 }
40 111
1 -import { LiveDetailsBean } from 'wdBean/Index' 1 +import { LiveDetailsBean, LiveRoomBean } from 'wdBean/Index'
2 import { LiveModel } from './LiveModel' 2 import { LiveModel } from './LiveModel'
3 3
4 const TAG = "LiveViewModel" 4 const TAG = "LiveViewModel"
@@ -19,6 +19,27 @@ export class LiveViewModel { @@ -19,6 +19,27 @@ export class LiveViewModel {
19 fail(message) 19 fail(message)
20 }) 20 })
21 }) 21 })
  22 + }
22 23
  24 + //直播详情直播间数据列表
  25 + getLiveList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  26 + return new Promise<LiveRoomBean>((success, fail) => {
  27 + this.liveModel.getLiveList(pageNum, mLiveId, liveId, pageSize).then((data) => {
  28 + success(data)
  29 + }).catch((message: string) => {
  30 + fail(message)
  31 + })
  32 + })
  33 + }
  34 +
  35 + //直播详情大家聊数据列表
  36 + getLiveChatList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
  37 + return new Promise<LiveRoomBean>((success, fail) => {
  38 + this.liveModel.getLiveChatList(pageNum, mLiveId, liveId, pageSize).then((data) => {
  39 + success(data)
  40 + }).catch((message: string) => {
  41 + fail(message)
  42 + })
  43 + })
23 } 44 }
24 } 45 }
1 -import { ListHasNoMoreDataUI } from 'wdComponent/Index' 1 +import { LiveRoomItemBean } from 'wdBean/Index'
  2 +import { EmptyComponent, ErrorComponent, ListHasNoMoreDataUI } from 'wdComponent/Index'
  3 +import CustomRefreshLoadLayout from 'wdComponent/src/main/ets/components/page/CustomRefreshLoadLayout'
  4 +import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout'
  5 +import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout'
  6 +import { RefreshLayoutBean } from 'wdComponent/src/main/ets/components/page/RefreshLayoutBean'
  7 +import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel'
  8 +import { ViewType } from 'wdConstant/Index'
  9 +import { LiveViewModel } from '../../viewModel/LiveViewModel'
2 import { TabChatItemComponent } from './TabChatItemComponent' 10 import { TabChatItemComponent } from './TabChatItemComponent'
3 11
4 @Component 12 @Component
5 export struct TabChatComponent { 13 export struct TabChatComponent {
6 - arr: string[] = [] 14 + @State private pageModel: PageModel = new PageModel()
  15 + liveViewModel: LiveViewModel = new LiveViewModel()
  16 + @State liveChatList: Array<LiveRoomItemBean> = []
7 17
8 aboutToAppear(): void { 18 aboutToAppear(): void {
9 - for (let index = 0; index < 12; index++) {  
10 - this.arr.push(index + '')  
11 - } 19 + this.getLiveChatList()
12 } 20 }
13 21
14 build() { 22 build() {
15 Stack() { 23 Stack() {
16 - if (this.arr.length == 0) {  
17 - ListHasNoMoreDataUI({ style: 2 }) 24 + if (this.pageModel.viewType == ViewType.LOADING) {
  25 + this.LoadingLayout()
  26 + } else if (this.pageModel.viewType == ViewType.ERROR) {
  27 + ErrorComponent()
  28 + } else if (this.pageModel.viewType == ViewType.EMPTY) {
  29 + EmptyComponent()
18 } else { 30 } else {
  31 + this.ListLayout()
  32 + }
  33 + }
  34 + .align(Alignment.Top)
  35 + .backgroundColor('#F5F5F5')
  36 + .height('100%')
  37 + .width('100%')
  38 + }
  39 +
  40 + @Builder
  41 + ListLayout() {
19 List() { 42 List() {
20 - ForEach(this.arr, (item: string) => {  
21 ListItem() { 43 ListItem() {
22 - TabChatItemComponent() 44 + // 下拉刷新
  45 + RefreshLayout({
  46 + refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,
  47 + this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
  48 + })
  49 + }
  50 +
  51 + ForEach(this.liveChatList, (item: LiveRoomItemBean) => {
  52 + ListItem() {
  53 + TabChatItemComponent({ item: item })
23 } 54 }
24 }) 55 })
  56 + // 加载更多
25 ListItem() { 57 ListItem() {
  58 + if (this.pageModel.hasMore) {
  59 + LoadMoreLayout({
  60 + refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
  61 + this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
  62 + })
  63 + } else {
26 ListHasNoMoreDataUI() 64 ListHasNoMoreDataUI()
27 } 65 }
28 } 66 }
29 } 67 }
30 } 68 }
31 - .align(Alignment.Top)  
32 - .backgroundColor('#F5F5F5')  
33 - .height('100%')  
34 - .width('100%') 69 +
  70 + @Builder
  71 + LoadingLayout() {
  72 + CustomRefreshLoadLayout({
  73 + refreshBean: new RefreshLayoutBean(true,
  74 + $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.pageModel.pullDownRefreshHeight)
  75 + })
  76 + }
  77 +
  78 + getLiveChatList() {
  79 + this.pageModel.currentPage = 1
  80 + this.liveViewModel.getLiveChatList(1, '20000016257', '20000016229', 20,)
  81 + .then(
  82 + (data) => {
  83 + if (data.barrageResponses && data.barrageResponses.length > 0) {
  84 + this.pageModel.viewType = ViewType.LOADED;
  85 + this.liveChatList.push(...data.barrageResponses)
  86 + if (data.barrageResponses.length === this.pageModel.pageSize) {
  87 + this.pageModel.currentPage++;
  88 + this.pageModel.hasMore = true;
  89 + } else {
  90 + this.pageModel.hasMore = false;
  91 + }
  92 + } else {
  93 + this.pageModel.viewType = ViewType.EMPTY;
  94 + }
  95 + },
  96 + () => {
  97 +
  98 + })
35 } 99 }
36 100
37 aboutToDisappear(): void { 101 aboutToDisappear(): void {
  1 +import { LiveRoomItemBean } from 'wdBean/Index'
  2 +
1 @Component 3 @Component
2 export struct TabChatItemComponent { 4 export struct TabChatItemComponent {
  5 + item: LiveRoomItemBean = {} as LiveRoomItemBean
  6 +
3 aboutToAppear(): void { 7 aboutToAppear(): void {
4 } 8 }
5 9
6 build() { 10 build() {
7 Row() { 11 Row() {
8 - Image('https://img0.baidu.com/it/u=4105778329,1297102594&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500') 12 + Image(this.item.senderUserAvatarUrl)
9 .borderRadius(90) 13 .borderRadius(90)
10 .width(24) 14 .width(24)
11 .height(24) 15 .height(24)
12 Text() { 16 Text() {
13 - Span('10999@qq.com: ') 17 + Span(this.item.senderUserName + ': ')
14 .fontColor('#666666') 18 .fontColor('#666666')
15 - Span('少年强则国强:山中有精灵也不过如此了') 19 + Span(this.item.text)
16 .fontColor('#222222') 20 .fontColor('#222222')
17 } 21 }
18 .margin({ left: 8 }) 22 .margin({ left: 8 })
  1 +import { LiveRoomItemBean } from 'wdBean/Index'
1 import { ListHasNoMoreDataUI } from 'wdComponent/Index' 2 import { ListHasNoMoreDataUI } from 'wdComponent/Index'
  3 +import { LiveViewModel } from '../../viewModel/LiveViewModel'
2 import { TabLiveItemComponent } from './TabLiveItemComponent' 4 import { TabLiveItemComponent } from './TabLiveItemComponent'
3 5
4 @Component 6 @Component
5 export struct TabLiveComponent { 7 export struct TabLiveComponent {
6 - arr: string[] = [] 8 + liveViewModel: LiveViewModel = new LiveViewModel()
  9 + @State liveList: Array<LiveRoomItemBean> = []
7 10
8 aboutToAppear(): void { 11 aboutToAppear(): void {
9 - for (let index = 0; index < 2; index++) {  
10 - this.arr.push(index + '')  
11 - } 12 + this.getLiveList()
12 } 13 }
13 14
14 build() { 15 build() {
15 Stack() { 16 Stack() {
16 - if (this.arr.length == 0) { 17 + if (this.liveList.length == 0) {
17 ListHasNoMoreDataUI({ style: 2 }) 18 ListHasNoMoreDataUI({ style: 2 })
18 } else { 19 } else {
19 List() { 20 List() {
20 - ForEach(this.arr, (item: string) => { 21 + ForEach(this.liveList, (item: LiveRoomItemBean) => {
21 ListItem() { 22 ListItem() {
22 TabLiveItemComponent({ item: item }) 23 TabLiveItemComponent({ item: item })
23 } 24 }
@@ -35,6 +36,17 @@ export struct TabLiveComponent { @@ -35,6 +36,17 @@ export struct TabLiveComponent {
35 36
36 } 37 }
37 38
  39 + getLiveList() {
  40 + this.liveViewModel.getLiveList(1, '20000016257', '20000016229', 20,)
  41 + .then(
  42 + (data) => {
  43 + this.liveList = data.barrageResponses
  44 + },
  45 + () => {
  46 +
  47 + })
  48 + }
  49 +
38 aboutToDisappear(): void { 50 aboutToDisappear(): void {
39 } 51 }
40 } 52 }
  1 +import { LiveRoomItemBean } from 'wdBean/Index'
  2 +import { DateTimeUtils } from 'wdKit/Index'
  3 +
1 @Component 4 @Component
2 export struct TabLiveItemComponent { 5 export struct TabLiveItemComponent {
3 - item: string = '' 6 + item: LiveRoomItemBean = {} as LiveRoomItemBean
4 7
5 aboutToAppear(): void { 8 aboutToAppear(): void {
6 9
@@ -9,18 +12,18 @@ export struct TabLiveItemComponent { @@ -9,18 +12,18 @@ export struct TabLiveItemComponent {
9 build() { 12 build() {
10 Column() { 13 Column() {
11 Row() { 14 Row() {
12 - Image('https://img0.baidu.com/it/u=4105778329,1297102594&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500') 15 + Image(this.item.senderUserAvatarUrl)
13 .borderRadius(90) 16 .borderRadius(90)
14 .width(24) 17 .width(24)
15 .height(24) 18 .height(24)
16 - Text('人民日报直播频道') 19 + Text(this.item.senderUserName)
17 .maxLines(1) 20 .maxLines(1)
18 .textOverflow({ overflow: TextOverflow.Ellipsis }) 21 .textOverflow({ overflow: TextOverflow.Ellipsis })
19 .fontSize('14fp') 22 .fontSize('14fp')
20 .fontWeight(400) 23 .fontWeight(400)
21 .fontColor('#222222') 24 .fontColor('#222222')
22 .margin({ left: 8 }) 25 .margin({ left: 8 })
23 - Text('嘉宾') 26 + Text('主持人')
24 .maxLines(1) 27 .maxLines(1)
25 .textOverflow({ overflow: TextOverflow.Ellipsis }) 28 .textOverflow({ overflow: TextOverflow.Ellipsis })
26 .fontSize('11fp') 29 .fontSize('11fp')
@@ -35,7 +38,8 @@ export struct TabLiveItemComponent { @@ -35,7 +38,8 @@ export struct TabLiveItemComponent {
35 }) 38 })
36 .borderRadius(2) 39 .borderRadius(2)
37 .margin({ left: 8 }) 40 .margin({ left: 8 })
38 - Text('1小时前') 41 + .visibility('host' == this.item.role ? Visibility.Visible : Visibility.None)
  42 + Text(DateTimeUtils.getCommentTime(new Date(this.item.time).getTime()))
39 .maxLines(1) 43 .maxLines(1)
40 .textOverflow({ overflow: TextOverflow.Ellipsis }) 44 .textOverflow({ overflow: TextOverflow.Ellipsis })
41 .fontSize('12fp') 45 .fontSize('12fp')
@@ -58,10 +62,11 @@ export struct TabLiveItemComponent { @@ -58,10 +62,11 @@ export struct TabLiveItemComponent {
58 }) 62 })
59 .borderRadius(2) 63 .borderRadius(2)
60 .margin({ left: 8 }) 64 .margin({ left: 8 })
  65 + .visibility(1 == this.item.isTop ? Visibility.Visible : Visibility.None)
61 } 66 }
62 .width('100%') 67 .width('100%')
63 68
64 - Text('国务院新闻办公室将于7月25日上午10时举行国务院政策例行吹风会,请应急管理部副部长、水利部副部长王道席和自然资源部、水利部、应急管理部、中国气象局、国家消防救援局有关负责人介绍防汛抗旱工作情况,并答记者问。') 69 + Text(this.item.text)
65 .fontSize('14fp') 70 .fontSize('14fp')
66 .fontWeight(400) 71 .fontWeight(400)
67 .fontColor('#222222') 72 .fontColor('#222222')
@@ -69,21 +74,25 @@ export struct TabLiveItemComponent { @@ -69,21 +74,25 @@ export struct TabLiveItemComponent {
69 left: 32, 74 left: 32,
70 top: 6 75 top: 6
71 }) 76 })
72 -  
73 - Image('https://t7.baidu.com/it/u=3690528415,706188365&fm=193&f=GIF') 77 + List() {
  78 + ForEach(this.item.pictureUrls, (item: string, index: number) => {
  79 + ListItem() {
  80 + Image(item)
74 .height(174) 81 .height(174)
75 .width(310) 82 .width(310)
76 .aspectRatio(310 / 174) 83 .aspectRatio(310 / 174)
77 .objectFit(ImageFit.Auto) 84 .objectFit(ImageFit.Auto)
78 .borderRadius(4) 85 .borderRadius(4)
79 - .margin({ 86 + }
  87 + })
  88 + }.margin({
80 left: 32, 89 left: 32,
81 top: 8 90 top: 8
82 }) 91 })
83 }.margin({ 92 }.margin({
84 - left:15,  
85 - top:15,  
86 - right:15 93 + left: 15,
  94 + top: 15,
  95 + right: 15
87 }) 96 })
88 } 97 }
89 98
@@ -3,6 +3,34 @@ @@ -3,6 +3,34 @@
3 { 3 {
4 "name": "shared_desc", 4 "name": "shared_desc",
5 "value": "description" 5 "value": "description"
  6 + },
  7 + {
  8 + "name": "footer_text",
  9 + "value": "已经到底了"
  10 + },
  11 + {
  12 + "name": "pull_up_load_text",
  13 + "value": "加载中..."
  14 + },
  15 + {
  16 + "name": "pull_down_refresh_text",
  17 + "value": "下拉刷新"
  18 + },
  19 + {
  20 + "name": "release_refresh_text",
  21 + "value": "松开刷新"
  22 + },
  23 + {
  24 + "name": "refreshing_text",
  25 + "value": "正在刷新"
  26 + },
  27 + {
  28 + "name": "refresh_success_text",
  29 + "value": "刷新成功"
  30 + },
  31 + {
  32 + "name": "refresh_fail_text",
  33 + "value": "刷新失败"
6 } 34 }
7 ] 35 ]
8 } 36 }