PageViewModel.ets
1.47 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
import { BottomNavBean, GroupDTO, NavigationBody } from 'wdBean';
import { Logger, ResourcesUtils } from 'wdKit';
import { ResponseDTO } from 'wdNetwork';
const TAG = 'PageViewModel';
/**
* 处理返回后的数据
*/
export class PageViewModel {
/**
* get Nav Data from Resource .
*
* @return BottomNavBean[] Nav Data List
*/
static getBottomNavData(context: Context): BottomNavBean[] {
Logger.info(TAG, `getBottomNavData start`);
let compRes: ResponseDTO<NavigationBody> | null = ResourcesUtils.getResourcesJsonSync<ResponseDTO<NavigationBody>>(context, 'bottom_nav.json');
if (!compRes || !compRes.data || !compRes.data.bottomNavList) {
Logger.info(TAG, `getBottomNavData compRes bottomNavList is empty`);
return []
}
Logger.info(TAG, `getBottomNavData getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data.bottomNavList
}
/**
* Get Group data.
*
* @return {GroupDTO} compRes.data
*/
static getGroupDTO(context: Context): GroupDTO {
let compRes: ResponseDTO<GroupDTO> | null = ResourcesUtils.getResourcesJsonSync<ResponseDTO<GroupDTO>>(context, 'comp_list.json');
if (!compRes || !compRes.data) {
Logger.info(TAG, `getCompList compRes is empty`);
return {} as GroupDTO
}
Logger.info(TAG, `getCompList getResourcesJson compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
let pageViewModel = new PageViewModel();
export default pageViewModel as PageViewModel;