Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-04-17 17:22:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7ad828d3ce6b4956eca59c8dca99902fa046bc5e
7ad828d3
1 parent
be8bb380
直播回看列表及分页加载处理。
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
61 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhGridLayout02.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageHelper.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhGridLayout02.ets
View file @
7ad828d
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, Logger, StringUtils, ToastUtils } from 'wdKit/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
const TAG = 'Zh_Grid_Layout-02';
const FULL_PARENT: string = '100%';
...
...
@@ -11,46 +13,76 @@ let listSize: number = 2;
* Zh_Grid_Layout-02
*
*/
@Preview
@Component
export struct ZhGridLayout02 {
@State compDTO: CompDTO = {} as CompDTO
@State operDataList: ContentDTO[] = []
currentPage = 1
pageSize = 12
aboutToAppear() {
if (this.compDTO.operDataList) {
listSize = this.compDTO.operDataList.length > 5 ? 2 : this.compDTO.operDataList.length;
}
Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle)
this.currentPage = 1
PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
this.operDataList = []
this.operDataList.push(...liveReviewDTO.list)
})
}
build() {
Column() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
.justifyContent(FlexAlign.Start)
.margin({ top: 8, bottom: 8 })
.width(CommonConstants.FULL_WIDTH)
GridRow({
columns: { sm: listSize, md: 2 },
breakpoints: { value: ['320vp', '520vp', '840vp'] }
}) {
ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
GridCol() {
this.buildItemCard(this.compDTO.operDataList[index]);
Scroll() {
Column() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
.justifyContent(FlexAlign.Start)
.margin({ top: 8, bottom: 8 })
.width(CommonConstants.FULL_WIDTH)
GridRow({
columns: { sm: listSize, md: 2 },
breakpoints: { value: ['320vp', '520vp', '840vp'] }
}) {
ForEach(this.operDataList, (item: ContentDTO, index: number) => {
GridCol() {
this.buildItemCard(item);
}
})
}
})
}
}
.width("100%")
.height("100%")
// .layoutWeight(1)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.onReachStart(() => {
Logger.debug(TAG, 'onReachStart')
})
.onReachEnd(() => {
Logger.debug(TAG, 'onReachEnd')
this.addItems()
})
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
}
.width(CommonConstants.FULL_WIDTH)
// .width("100%")
.height("100%")
// .layoutWeight(1)
.padding({
top: 14,
left: 16,
...
...
@@ -78,6 +110,15 @@ export struct ZhGridLayout02 {
}
.width('100%')
}
addItems() {
Logger.debug(TAG, 'addItems')
this.currentPage++
PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
this.operDataList.push(...liveReviewDTO.list)
Logger.debug(TAG, 'addItems after: ' + this.operDataList.length)
})
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
View file @
7ad828d
...
...
@@ -77,11 +77,13 @@ export struct PageComponent {
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
} else {
} else
if (!this.pageModel.contentNeedScroll)
{
NoMoreLayout()
}
}
}
// comp自己处理分页,这里设置EdgeEffect.None
.edgeEffect(this.pageModel.contentNeedScroll ? EdgeEffect.None : EdgeEffect.Spring)
.scrollBar(BarState.Off)
.cachedCount(8)
.height(CommonConstants.FULL_PARENT)
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageHelper.ets
View file @
7ad828d
import { PageDTO, CompDTO, PageInfoDTO } from 'wdBean';
import { ViewType } from 'wdConstant/Index';
import { DateTimeUtils, Logger } from 'wdKit';
import { CompStyle, ViewType } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit';
import { closeRefresh } from '../utils/PullDownRefresh';
import PageModel from './PageModel';
import PageViewModel from './PageViewModel';
...
...
@@ -65,39 +65,33 @@ export class PageHelper {
} else {
pageModel.hasMore = false;
}
// TODO 暂时去掉互动数据,待优化。(主要是互动数据返回,如何渲染到ui上)
// TODO updateItems(sizeBefore, data),这里可能有时序问题,导致覆盖别的group数据,需要优化,考虑精准替换
// 二次请求,批查互动数据
PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// 刷新,替换所有数据
// pageModel.compList.replaceAll(...data)
pageModel.compList.updateItems(sizeBefore, data)
pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
})
// TODO 待优化,解决content级别的展现加载
// PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// // pageModel.compList.replaceAll(...data)
// pageModel.compList.updateItems(sizeBefore, data)
// pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
// content级别的展现加载丢给comp自己,这里只需要处理屏蔽分页加载,pageModel.pageScroll
if (isLastGroup) {
closeRefresh(pageModel, true);
// // 最后一个楼层,特殊处理
// // 检测楼层最后一个组件业务数据是否需要通过访问接口获取
// let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1]
// let compSize = CollectionUtils.getListSize(comp.operDataList)
// // 直播回放,需要二次请求数据
// if (compSize <= 0 && comp.dataSourceType == 'LIVE_END') {
// let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize)
// // content数据回来,塞给comp
// comp.operDataList.push(...liveReviewDTO.list)
// }
// 最后一个楼层,特殊处理
// 检测楼层最后一个组件业务数据是否需要通过访问接口获取
let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1]
let compSize = CollectionUtils.getListSize(comp.operDataList)
// 直播回放,需要二次请求数据
if (compSize <= 0 && comp.compStyle == CompStyle.Zh_Grid_Layout_02) {
// 这个comp,数据自己二次请求,自己分页处理,这里加flag,将page层滑动及loadmore ui去掉
pageModel.contentNeedScroll = true
}
}
}
}
/**
* 获取直播回看数据
*/
private async getLiveEnd(pageModel: PageModel) {
let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize)
Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + liveReviewDTO.hasNext);
}
/**
* comp加载更多,分页加载
*/
private compLoadMore(pageModel: PageModel) {
...
...
@@ -125,14 +119,6 @@ export class PageHelper {
promptAction.showToast({ message: err });
})
}
/**
* 节目数据分页加载
* TODO 待完善框架
*/
private contentLoadMore() {
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageModel.ets
View file @
7ad828d
...
...
@@ -20,6 +20,9 @@ export default class PageModel {
// 当前请求数据的group
groupData: GroupInfoDTO = {} as GroupInfoDTO;
compList: LazyDataSource<CompDTO> = new LazyDataSource();
// 是否comp自己处理分页加载;默认是最后一个comp下的content有分页数据,需要节目内容的分页加载
// (如:首页-视频tab-直播tab,最后一个comp是直播回看列表,视频内容需要分页加载)
contentNeedScroll: boolean = false;
// 页面状态,刷新、加载更多等,1-首次、2-下拉、3上拉
loadStrategy: number = 1;
currentPage: number = 1;
...
...
Please
register
or
login
to post a comment