PageModel.ets
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { CompDTO, GroupDTO } from 'wdBean';
import { LazyDataSource } from 'wdKit';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { RefreshConstants as Const } from '../utils/RefreshConstants';
import { PageUIReqBean } from '../components/page/bean/PageUIReqBean';
import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
/**
* 页面下拉刷新、上拉加载数据bean。
* TODO 将业务数据拆出去
*/
export default class PageModel {
// 页面数据
pageId: string = "";
groupId: string = "";
channelId: string = "";
isRecGroup: boolean = false;
pageInfo: PageInfoDTO = {} as PageInfoDTO
groupList: GroupInfoDTO[] = [];
// 当前请求数据的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;
pageSize: number = Const.PAGE_SIZE;
pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text');
pullDownRefreshImage: Resource = $r('app.media.ic_pull_down_refresh');
pullDownRefreshHeight: number = Const.CUSTOM_LAYOUT_HEIGHT;
isVisiblePullDown: boolean = false;
pullUpLoadText: Resource = $r('app.string.pull_up_load_text');
pullUpLoadImage: Resource = $r('app.media.ic_pull_up_load');
pullUpLoadHeight: number = Const.CUSTOM_LAYOUT_HEIGHT;
isVisiblePullUpLoad: boolean = false;
offsetY: number = 0;
viewType: number = ViewType.LOADING;
hasMore: boolean = true;
startIndex = 0;
endIndex = 0;
downY = 0;
lastMoveY = 0;
isRefreshing: boolean = false;
isCanRefresh = false;
isPullRefreshOperation = false;
isLoading: boolean = false;
isCanLoadMore: boolean = false;
// keyGenerator相关字符串,用于刷新list布局
timestamp: String = '1';
/**
* 简单复制业务数据
*/
bizCopy(): PageUIReqBean {
let page = new PageUIReqBean()
page.pageId = this.pageId
page.groupId = this.groupId
page.channelId = this.channelId
page.isRecGroup = this.isRecGroup
page.currentPage = this.currentPage
page.pageSize = this.pageSize
page.groupStrategy = this.groupData.groupStrategy
page.loadStrategy = this.loadStrategy
return page
}
}