liyubing

feat: 进入横屏多路直播-置空-评论预显示禁止直播间,大家聊不支持下拉刷新

@@ -71,7 +71,6 @@ export struct DetailPlayLiveCommon { @@ -71,7 +71,6 @@ export struct DetailPlayLiveCommon {
71 .then((data: Array<ContentDetailDTO>) => { 71 .then((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 this.liveLandscape = 75 this.liveLandscape =
77 detailData?.liveInfo?.liveLandScape //String(this.contentDetailData?.liveInfo?.liveLandScape || '') 76 detailData?.liveInfo?.liveLandScape //String(this.contentDetailData?.liveInfo?.liveLandScape || '')
@@ -84,6 +84,7 @@ export struct DetailPlayLivePage { @@ -84,6 +84,7 @@ export struct DetailPlayLivePage {
84 } 84 }
85 }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) 85 }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
86 86
  87 +
87 // LiveCommentComponent({ heartNum: this.liveRoomDataBean.likeNum }) 88 // LiveCommentComponent({ heartNum: this.liveRoomDataBean.likeNum })
88 // .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) 89 // .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
89 } 90 }
@@ -12,6 +12,10 @@ import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment @@ -12,6 +12,10 @@ import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment
12 12
13 const TAG: string = 'TabChatComponent'; 13 const TAG: string = 'TabChatComponent';
14 14
  15 +/**
  16 + *
  17 + * 非沉浸式---大家聊
  18 + */
15 @Component 19 @Component
16 export struct TabChatComponent { 20 export struct TabChatComponent {
17 @State private pageModel: PageModel = new PageModel() 21 @State private pageModel: PageModel = new PageModel()
@@ -13,11 +13,9 @@ export struct TabComponent { @@ -13,11 +13,9 @@ export struct TabComponent {
13 @State currentIndex: number = 0 13 @State currentIndex: number = 0
14 private controller: TabsController = new TabsController() 14 private controller: TabsController = new TabsController()
15 @Prop tabs: string[] = [] 15 @Prop tabs: string[] = []
16 -  
17 aboutToAppear(): void { 16 aboutToAppear(): void {
18 17
19 } 18 }
20 -  
21 /** 19 /**
22 * 评论切换到大家聊 20 * 评论切换到大家聊
23 */ 21 */
1 import { ContentDetailDTO, LiveDetailsBean } from 'wdBean/Index' 1 import { ContentDetailDTO, LiveDetailsBean } from 'wdBean/Index'
2 import { LiveCountdownComponent } from './LiveCountdownComponent' 2 import { LiveCountdownComponent } from './LiveCountdownComponent'
3 3
  4 +/**
  5 + * 非沉浸式---简介
  6 + */
4 @Component 7 @Component
5 export struct TabInfoComponent { 8 export struct TabInfoComponent {
6 @Consume contentDetailData: ContentDetailDTO 9 @Consume contentDetailData: ContentDetailDTO
1 -import { ContentDetailDTO, LiveDetailsBean, LiveRoomItemBean } from 'wdBean/Index'  
2 -import { EmptyComponent, ErrorComponent, ListHasNoMoreDataUI, WDViewDefaultType } from 'wdComponent/Index' 1 +import { ContentDetailDTO, LiveRoomItemBean } from 'wdBean/Index'
  2 +import { CustomPullToRefresh, EmptyComponent, ErrorComponent, WDViewDefaultType } from 'wdComponent/Index'
3 import { TabLiveItemComponent } from './TabLiveItemComponent' 3 import { TabLiveItemComponent } from './TabLiveItemComponent'
4 import CustomRefreshLoadLayout from 'wdComponent/src/main/ets/components/page/CustomRefreshLoadLayout' 4 import CustomRefreshLoadLayout from 'wdComponent/src/main/ets/components/page/CustomRefreshLoadLayout'
5 import { RefreshLayoutBean } from 'wdComponent/src/main/ets/components/page/RefreshLayoutBean' 5 import { RefreshLayoutBean } from 'wdComponent/src/main/ets/components/page/RefreshLayoutBean'
6 import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' 6 import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel'
7 import { ViewType } from 'wdConstant/Index' 7 import { ViewType } from 'wdConstant/Index'
8 -import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout'  
9 -import { StringUtils } from 'wdKit/Index' 8 +import { LazyDataSource, StringUtils } from 'wdKit/Index'
10 import { LiveViewModel } from '../../viewModel/LiveViewModel' 9 import { LiveViewModel } from '../../viewModel/LiveViewModel'
11 import { Logger } from 'wdKit' 10 import { Logger } from 'wdKit'
  11 +import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout'
  12 +import { PeopleShipNoMoreData } from 'wdComponent/src/main/ets/components/reusable/PeopleShipNoMoreData'
12 13
13 const TAG: string = 'TabLiveComponent'; 14 const TAG: string = 'TabLiveComponent';
14 15
@@ -18,12 +19,13 @@ const TAG: string = 'TabLiveComponent'; @@ -18,12 +19,13 @@ const TAG: string = 'TabLiveComponent';
18 @Component 19 @Component
19 export struct TabLiveComponent { 20 export struct TabLiveComponent {
20 liveViewModel: LiveViewModel = new LiveViewModel() 21 liveViewModel: LiveViewModel = new LiveViewModel()
21 - @State liveList: Array<LiveRoomItemBean> = [] 22 + @State liveList: LazyDataSource<LiveRoomItemBean> = new LazyDataSource();
22 @Consume @Watch('updateData') contentDetailData: ContentDetailDTO 23 @Consume @Watch('updateData') contentDetailData: ContentDetailDTO
23 @State private pageModel: PageModel = new PageModel() 24 @State private pageModel: PageModel = new PageModel()
  25 + private scroller: Scroller = new Scroller()
24 26
25 aboutToAppear(): void { 27 aboutToAppear(): void {
26 - this.getLiveList() 28 + this.getLiveList()
27 } 29 }
28 30
29 build() { 31 build() {
@@ -35,7 +37,19 @@ export struct TabLiveComponent { @@ -35,7 +37,19 @@ export struct TabLiveComponent {
35 } else if (this.pageModel.viewType == ViewType.EMPTY) { 37 } else if (this.pageModel.viewType == ViewType.EMPTY) {
36 EmptyComponent({ emptyType: WDViewDefaultType.WDViewDefaultType_NoContent1 }) 38 EmptyComponent({ emptyType: WDViewDefaultType.WDViewDefaultType_NoContent1 })
37 } else { 39 } else {
38 - this.ListLayout() 40 + CustomPullToRefresh({
  41 + alldata: this.liveList,
  42 + scroller: this.scroller,
  43 + hasMore: false,
  44 + customList: () => {
  45 + this.ListLayout()
  46 + },
  47 + onRefresh: (resolve) => {
  48 + this.pageModel.currentPage = 1
  49 + this.getLiveList(resolve)
  50 + },
  51 + })
  52 +
39 } 53 }
40 } 54 }
41 .alignContent(Alignment.Top) 55 .alignContent(Alignment.Top)
@@ -46,32 +60,35 @@ export struct TabLiveComponent { @@ -46,32 +60,35 @@ export struct TabLiveComponent {
46 60
47 @Builder 61 @Builder
48 ListLayout() { 62 ListLayout() {
49 - List() {  
50 - ListItem() {  
51 - // 下拉刷新 TODO 待对接新的下拉刷新组件  
52 - // RefreshLayout({  
53 - // refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,  
54 - // this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)  
55 - // })  
56 - }  
57 63
58 - ForEach(this.liveList, (item: LiveRoomItemBean) => { 64 + List({ scroller: this.scroller }) {
  65 + // 下拉刷新
  66 + LazyForEach(this.liveList, (item: LiveRoomItemBean, index: number) => {
59 ListItem() { 67 ListItem() {
60 TabLiveItemComponent({ item: item }) 68 TabLiveItemComponent({ item: item })
61 } 69 }
62 - }) 70 + },
  71 + (item: LiveRoomItemBean, contentIndex: number) => JSON.stringify(item)
  72 + )
63 // 加载更多 73 // 加载更多
64 ListItem() { 74 ListItem() {
65 - if (this.pageModel.hasMore) {  
66 - // LoadMoreLayout({  
67 - // refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,  
68 - // this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)  
69 - // })  
70 - } else {  
71 - ListHasNoMoreDataUI() 75 + if (this.pageModel.hasMore && this.liveList && this.liveList.totalCount() > 0) {
  76 + LoadMoreLayout({ isVisible: this.pageModel.hasMore })
  77 + } else if (!this.pageModel.hasMore && !this.pageModel.isLoading) {
  78 + PeopleShipNoMoreData()
72 } 79 }
73 } 80 }
74 } 81 }
  82 + .edgeEffect(EdgeEffect.None)
  83 + .scrollBar(BarState.Off)
  84 + .onReachEnd(() => {
  85 + Logger.debug(TAG, "触底了");
  86 + if (!this.pageModel.isLoading && this.pageModel.hasMore) {
  87 + //加载分页数据
  88 + //this.currentPage++;
  89 + this.getLiveList()
  90 + }
  91 + })
75 } 92 }
76 93
77 @Builder 94 @Builder
@@ -82,19 +99,35 @@ export struct TabLiveComponent { @@ -82,19 +99,35 @@ export struct TabLiveComponent {
82 }) 99 })
83 } 100 }
84 101
85 - getLiveList() { 102 + async getLiveList(resolve?: (value: string | PromiseLike<string>) => void) {
86 if (!this.contentDetailData || !this.contentDetailData.newsId) { 103 if (!this.contentDetailData || !this.contentDetailData.newsId) {
87 // 参数不够,直接拦截接口 104 // 参数不够,直接拦截接口
88 return 105 return
89 } 106 }
  107 + if (this.pageModel.isLoading) {
  108 +
  109 + if (resolve) {
  110 + resolve('已更新至最新')
  111 + }
  112 + return
  113 + }
  114 + this.pageModel.isLoading = true
90 this.pageModel.currentPage = 1 115 this.pageModel.currentPage = 1
91 this.liveViewModel.getLiveList( 116 this.liveViewModel.getLiveList(
92 this.pageModel.currentPage, 117 this.pageModel.currentPage,
93 this.contentDetailData?.liveInfo?.mlive?.mliveId, 118 this.contentDetailData?.liveInfo?.mlive?.mliveId,
94 - this.contentDetailData?.newsId+'', 119 + this.contentDetailData?.newsId + '',
95 20) 120 20)
96 .then( 121 .then(
97 (data) => { 122 (data) => {
  123 + this.pageModel.isLoading = false
  124 + if (resolve) {
  125 + if (this.pageModel.currentPage == 1) {
  126 + resolve('已更新至最新')
  127 + } else {
  128 + resolve('')
  129 + }
  130 + }
98 Logger.debug(TAG, '直播间数据:' + `${JSON.stringify(data)}`) 131 Logger.debug(TAG, '直播间数据:' + `${JSON.stringify(data)}`)
99 if (data.barrageResponses && data.barrageResponses.length > 0) { 132 if (data.barrageResponses && data.barrageResponses.length > 0) {
100 /** 133 /**
@@ -106,6 +139,10 @@ export struct TabLiveComponent { @@ -106,6 +139,10 @@ export struct TabLiveComponent {
106 3.内容:详情接口的简介,newIntroduction 139 3.内容:详情接口的简介,newIntroduction
107 */ 140 */
108 this.pageModel.viewType = ViewType.LOADED; 141 this.pageModel.viewType = ViewType.LOADED;
  142 + if(this.pageModel.currentPage ===1){
  143 + this.liveList.clear()
  144 + }
  145 +
109 this.liveList.push(...data.barrageResponses) 146 this.liveList.push(...data.barrageResponses)
110 if (data.barrageResponses.length === this.pageModel.pageSize) { 147 if (data.barrageResponses.length === this.pageModel.pageSize) {
111 this.pageModel.currentPage++; 148 this.pageModel.currentPage++;
@@ -124,9 +161,11 @@ export struct TabLiveComponent { @@ -124,9 +161,11 @@ export struct TabLiveComponent {
124 && this.contentDetailData.liveInfo.liveState != 'wait') { 161 && this.contentDetailData.liveInfo.liveState != 'wait') {
125 this.pageModel.viewType = ViewType.LOADED; 162 this.pageModel.viewType = ViewType.LOADED;
126 this.updateLiveListData() 163 this.updateLiveListData()
  164 + this.pageModel.hasMore = false;
127 } else { 165 } else {
128 this.pageModel.viewType = ViewType.EMPTY; 166 this.pageModel.viewType = ViewType.EMPTY;
129 } 167 }
  168 +
130 } 169 }
131 }, 170 },
132 () => { 171 () => {
@@ -155,7 +194,7 @@ export struct TabLiveComponent { @@ -155,7 +194,7 @@ export struct TabLiveComponent {
155 } 194 }
156 195
157 updateData() { 196 updateData() {
158 - if (this.liveList.length > 0) { 197 + if (this.liveList.totalCount() > 0) {
159 // TODO 拦截刷新?根据业务斟酌下 198 // TODO 拦截刷新?根据业务斟酌下
160 return 199 return
161 } 200 }
@@ -63,7 +63,6 @@ export struct TopPlayComponent { @@ -63,7 +63,6 @@ export struct TopPlayComponent {
63 } 63 }
64 64
65 updateData() { 65 updateData() {
66 -  
67 // 检测等待中的直播预告是否视频资源 66 // 检测等待中的直播预告是否视频资源
68 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1 67 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1
69 && this.contentDetailData.liveInfo.previewUrl && 68 && this.contentDetailData.liveInfo.previewUrl &&