xingzhaojie

Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main

# Conflicts:
#	PeopleDaily_Harmony/entry/src/main/resources/rawfile/comp_list0.json
#	PeopleDaily_Harmony/wdComponent/src/main/ets/Index.ets
#	PeopleDaily_Harmony/wdComponent/src/main/ets/components/PageComponent.ets
Showing 29 changed files with 583 additions and 90 deletions
1 import UIAbility from '@ohos.app.ability.UIAbility'; 1 import UIAbility from '@ohos.app.ability.UIAbility';
2 import hilog from '@ohos.hilog'; 2 import hilog from '@ohos.hilog';
3 import window from '@ohos.window'; 3 import window from '@ohos.window';
4 - 4 +import { AppContext } from 'wdKit';
5 export default class EntryAbility extends UIAbility { 5 export default class EntryAbility extends UIAbility {
6 onCreate(want, launchParam) { 6 onCreate(want, launchParam) {
7 hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); 7 hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
  8 + AppContext.init(this.context)
8 } 9 }
9 10
10 onDestroy() { 11 onDestroy() {
@@ -15,4 +15,7 @@ export { TopNavigationComponent } from "./components/TopNavigationComponent" @@ -15,4 +15,7 @@ export { TopNavigationComponent } from "./components/TopNavigationComponent"
15 15
16 export { LabelComponent } from "./components/LabelComponent" 16 export { LabelComponent } from "./components/LabelComponent"
17 17
18 -export { BannerComponent } from "./components/BannerComponent"  
  18 +export { SmallVideoCardComponent } from "./components/SmallVideoCardComponent"
  19 +
  20 +export { BannerComponent } from "./components/BannerComponent"
  21 +
1 import { BottomNavi, CommonConstants } from 'wdConstant'; 1 import { BottomNavi, CommonConstants } from 'wdConstant';
2 -import { LazyDataSource, Logger } from 'wdKit'; 2 +import { Logger } from 'wdKit';
3 import { TopNavigationComponent } from './TopNavigationComponent'; 3 import { TopNavigationComponent } from './TopNavigationComponent';
4 -import { PageComponent } from './PageComponent';  
5 import { BottomNavDTO } from '../repository/bean/BottomNavDTO'; 4 import { BottomNavDTO } from '../repository/bean/BottomNavDTO';
6 -import { PageViewModel } from '../Index'; 5 +import { UIUtils } from '../repository/UIUtils';
  6 +import { MinePageComponent } from './MinePageComponent';
  7 +import PageViewModel from '../viewmodel/PageViewModel';
7 8
8 const TAG = 'BottomNavigationComponent'; 9 const TAG = 'BottomNavigationComponent';
9 10
@@ -28,13 +29,12 @@ export struct BottomNavigationComponent { @@ -28,13 +29,12 @@ export struct BottomNavigationComponent {
28 */ 29 */
29 readonly SIXTY_OPACITY: number = 0.6; 30 readonly SIXTY_OPACITY: number = 0.6;
30 31
31 -  
32 async aboutToAppear() { 32 async aboutToAppear() {
33 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); 33 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
34 - let bottomNav = await PageViewModel.getBottomNavData(getContext(this))  
35 - if (bottomNav) {  
36 - Logger.info(TAG, `aboutToAppear, bottomNav.length: ${bottomNav.length}`);  
37 - this.bottomNavList = bottomNav 34 + let bottomNav = await PageViewModel.getBottomNavData()
  35 + if (bottomNav && bottomNav.bottomNavList != null) {
  36 + Logger.info(TAG, `aboutToAppear, bottomNav.length: ${bottomNav.bottomNavList.length}`);
  37 + this.bottomNavList = bottomNav.bottomNavList
38 } 38 }
39 } 39 }
40 40
@@ -47,8 +47,9 @@ export struct BottomNavigationComponent { @@ -47,8 +47,9 @@ export struct BottomNavigationComponent {
47 ForEach(this.bottomNavList, (navItem: BottomNavDTO, index: number) => { 47 ForEach(this.bottomNavList, (navItem: BottomNavDTO, index: number) => {
48 TabContent() { 48 TabContent() {
49 Column() { 49 Column() {
50 - if (navItem.topNavChannelList && navItem.topNavChannelList.length == 0 && navItem.name == '我的') {  
51 - PageComponent({ compList: new LazyDataSource() }) // todo:我的页面组件数据列表 50 + if (UIUtils.isMine(navItem)) {
  51 + // 我的页面组件数据列表
  52 + MinePageComponent()
52 } else { 53 } else {
53 TopNavigationComponent({ topNavList: navItem.topNavChannelList }) 54 TopNavigationComponent({ topNavList: navItem.topNavChannelList })
54 } 55 }
  1 +const TAG = 'PageComponent';
  2 +
  3 +/**
  4 + * 我的页面
  5 + */
  6 +@Component
  7 +export struct MinePageComponent {
  8 + // TODO 待完善
  9 + build() {
  10 + Text('我的页面')
  11 + }
  12 +}
  13 +
1 import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; 1 import { CommonConstants, CompStyle, ViewType } from 'wdConstant';
2 import { LazyDataSource, Logger } from 'wdKit'; 2 import { LazyDataSource, Logger } from 'wdKit';
3 import { CompDTO } from '../repository/bean/CompDTO'; 3 import { CompDTO } from '../repository/bean/CompDTO';
4 -import { PageViewModel } from '../viewmodel/PageViewModel'; 4 +import PageViewModel from '../viewmodel/PageViewModel';
5 import { EmptyComponent } from './EmptyComponent'; 5 import { EmptyComponent } from './EmptyComponent';
6 import { ErrorComponent } from './ErrorComponent'; 6 import { ErrorComponent } from './ErrorComponent';
7 import { LabelComponent } from './LabelComponent'; 7 import { LabelComponent } from './LabelComponent';
8 import { LoadingComponent } from './LoadingComponent'; 8 import { LoadingComponent } from './LoadingComponent';
  9 +import { TitleAbbrComponent } from './TitleAbbrComponent';
  10 +import { TitleAllComponent } from './TitleAllComponent';
9 import {BannerComponent} from './BannerComponent' 11 import {BannerComponent} from './BannerComponent'
10 12
11 -  
12 -  
13 -  
14 -  
15 -  
16 -  
17 const TAG = 'PageComponent'; 13 const TAG = 'PageComponent';
18 14
19 @Component 15 @Component
@@ -22,6 +18,10 @@ export struct PageComponent { @@ -22,6 +18,10 @@ export struct PageComponent {
22 // Group数据及子组件数据 18 // Group数据及子组件数据
23 @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); 19 @State compList: LazyDataSource<CompDTO> = new LazyDataSource();
24 @State currentTopNavSelectedIndex: number = 0; 20 @State currentTopNavSelectedIndex: number = 0;
  21 + @State pageId: string = "";
  22 + @State channelId: string = "";
  23 +
  24 + // @Link @Watch('onChange') paIndex:number
25 25
26 build() { 26 build() {
27 if (this.viewType == ViewType.LOADING) { 27 if (this.viewType == ViewType.LOADING) {
@@ -49,7 +49,11 @@ export struct PageComponent { @@ -49,7 +49,11 @@ export struct PageComponent {
49 componentBuilder(compDTO: CompDTO, compIndex: number) { 49 componentBuilder(compDTO: CompDTO, compIndex: number) {
50 if (compDTO.compStyle === CompStyle.Label_03) { 50 if (compDTO.compStyle === CompStyle.Label_03) {
51 LabelComponent({ compDTO: compDTO }) 51 LabelComponent({ compDTO: compDTO })
52 - }else if(compDTO.compStyle === CompStyle.Carousel_Layout_01) { 52 + } else if (compDTO.compStyle === CompStyle.Title_Abbr_01) {
  53 + TitleAbbrComponent({ compDTO: compDTO })
  54 + } else if (compDTO.compStyle === CompStyle.Title_All_01) {
  55 + TitleAllComponent({ compDTO: compDTO })
  56 + } else if(compDTO.compStyle === CompStyle.Carousel_Layout_01) {
53 BannerComponent({ compDTO: compDTO }) 57 BannerComponent({ compDTO: compDTO })
54 } else { 58 } else {
55 // todo:组件未实现 / Component Not Implemented 59 // todo:组件未实现 / Component Not Implemented
@@ -62,17 +66,26 @@ export struct PageComponent { @@ -62,17 +66,26 @@ export struct PageComponent {
62 66
63 async aboutToAppear() { 67 async aboutToAppear() {
64 Logger.info(TAG, `aboutToAppear, this.pageId: ${this.viewType} this.currentTopNavSelectedIndex: ${this.currentTopNavSelectedIndex}`); 68 Logger.info(TAG, `aboutToAppear, this.pageId: ${this.viewType} this.currentTopNavSelectedIndex: ${this.currentTopNavSelectedIndex}`);
65 - if (this.currentTopNavSelectedIndex === 1) { // 顶导tab的第0个item是【热点】,第1个item是【推荐】  
66 - this.compList.replaceAll()  
67 - let pageDto = await PageViewModel.getPageData2(getContext(this))  
68 - if (pageDto && pageDto.compList) {  
69 - this.compList.push(...pageDto.compList)  
70 - }  
71 - } else {  
72 - let pageDto = await PageViewModel.getPageData1(getContext(this))  
73 - if (pageDto && pageDto.compList) {  
74 - this.compList.push(...pageDto.compList)  
75 - } 69 + // if (this.currentTopNavSelectedIndex === 1) { // 顶导tab的第0个item是【热点】,第1个item是【推荐】
  70 + // this.compList.replaceAll()
  71 + // let pageDto = await PageViewModel.getPageData2(getContext(this))
  72 + // if (pageDto && pageDto.compList) {
  73 + // this.compList.push(...pageDto.compList)
  74 + // }
  75 + // } else {
  76 + // let pageDto = await PageViewModel.getPageData1(getContext(this))
  77 + // if (pageDto && pageDto.compList) {
  78 + // this.compList.push(...pageDto.compList)
  79 + // }
  80 + // }
  81 +
  82 + // if (this.currentTopNavSelectedIndex != 1) { // 顶导tab的第0个item是【热点】,第1个item是【推荐】
  83 + // return
  84 + // }
  85 + Logger.debug(TAG,'lllllalalal: ' + this.pageId+' , ' + this.channelId);
  86 + let pageDto = await PageViewModel.getPageData(this.pageId, this.pageId, this.channelId)
  87 + if (pageDto && pageDto.compList) {
  88 + this.compList.push(...pageDto.compList)
76 } 89 }
77 } 90 }
78 } 91 }
  1 +import { CommonConstants } from 'wdConstant/src/main/ets/constants/CommonConstants'
  2 +
  3 +@Entry
  4 +@Component
  5 +export struct SmallVideoCardComponent {
  6 + build() {
  7 + Row() {
  8 + Column() {
  9 + Text('“畅享亚运”新模式活动打卡,看杭州打开“金角银边活动启动 跟着体育明星云打卡,看杭州打开“金角银边')
  10 + .fontWeight(400)
  11 + .fontSize($r('app.float.font_size_17'))
  12 + .maxLines(4)
  13 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  14 + .fontColor($r('app.color.color_222222'))
  15 + .lineHeight(25)
  16 + Row() {
  17 + Text('人民日报')
  18 + .labelTextStyle()
  19 + Image($r('app.media.point'))
  20 + .width(16)
  21 + .height(16)
  22 + Text('20分钟前')
  23 + .labelTextStyle()
  24 + .margin({
  25 + right: 6
  26 + })
  27 + Text('2000评')
  28 + .labelTextStyle()
  29 + }
  30 + }
  31 + .height(156)
  32 + .layoutWeight(1)
  33 + .justifyContent(FlexAlign.SpaceBetween)
  34 + .alignItems(HorizontalAlign.Start)
  35 + .margin({ right: 12 })
  36 +
  37 + Stack({ alignContent: Alignment.BottomEnd }) {
  38 + Image('https://www.harmonyos.com/resource/image/partner/harmonyos-connect/pic_shengtai_connect_qudao_xianxia.jpg')
  39 + .width(117)
  40 + .aspectRatio(117 / 156)
  41 + .border({ radius: 4 })
  42 + Row() {
  43 + Image($r('app.media.iv_card_play_yellow_flag'))
  44 + .width(22)
  45 + .height(18)
  46 + Text('10:00')
  47 + .fontSize($r('app.float.font_size_13'))
  48 + .fontWeight(400)
  49 + .fontColor($r('app.color.color_fff'))
  50 + }
  51 + .height(18)
  52 + .padding({ right: 4 })
  53 + .margin({
  54 + right: 4,
  55 + bottom: 4
  56 + })
  57 + .backgroundColor($r('app.color.color_4d000000'))
  58 + }
  59 + }
  60 + .width(CommonConstants.FULL_WIDTH)
  61 + .height(184)
  62 + .padding({
  63 + top: 14,
  64 + bottom: 14,
  65 + left: 16,
  66 + right: 16
  67 + })
  68 + }
  69 +}
  70 +
  71 +@Extend(Text) function labelTextStyle() {
  72 + .fontSize($r('app.float.font_size_12'))
  73 + .fontWeight(400)
  74 + .fontColor($r('app.color.color_B0B0B0'))
  75 +}
  1 +//缩略标题
  2 +import { CommonConstants } from 'wdConstant'
  3 +import { CompDTO } from '../repository/bean/CompDTO'
  4 +
  5 +@Component
  6 +export struct TitleAbbrComponent {
  7 + @State compDTO: CompDTO = {} as CompDTO
  8 +
  9 + build() {
  10 + Column() {
  11 + Text(this.compDTO.operDataList[0].title)
  12 + .fontSize($r("app.float.font_size_16"))
  13 + .fontColor($r("app.color.color_222222"))
  14 + .maxLines(3)
  15 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  16 + .width(CommonConstants.FULL_WIDTH)
  17 + Row() {
  18 + Text("锐评")
  19 + .fontSize($r("app.float.font_size_12"))
  20 + .fontColor($r("app.color.color_ED2800"))
  21 + Text(this.compDTO.operDataList[0].source)
  22 + .fontSize($r("app.float.font_size_12"))
  23 + .fontColor($r("app.color.color_B0B0B0"))
  24 + .margin({ left: 6 })
  25 + Image($r("app.media.point"))
  26 + .width(16)
  27 + .height(16)
  28 +
  29 + Text("46分钟前")
  30 + .fontSize($r("app.float.font_size_12"))
  31 + .fontColor($r("app.color.color_B0B0B0"))
  32 +
  33 + }.width(CommonConstants.FULL_WIDTH)
  34 + .justifyContent(FlexAlign.Start)
  35 + .margin({ top: 8 })
  36 +
  37 + }.width(CommonConstants.FULL_WIDTH)
  38 + .padding({
  39 + top: 14,
  40 + left: 16,
  41 + right: 16,
  42 + bottom: 14
  43 + })
  44 + .backgroundColor($r("app.color.white"))
  45 + .margin({ bottom: 8 })
  46 + }
  47 +}
  1 +//全标题 "compStyle":"3",
  2 +import { CommonConstants } from 'wdConstant'
  3 +import { CompDTO } from '../repository/bean/CompDTO'
  4 +
  5 +@Component
  6 +export struct TitleAllComponent {
  7 + @State compDTO: CompDTO = {} as CompDTO
  8 +
  9 + build() {
  10 + Column() {
  11 + Text(this.compDTO.operDataList[0].title)
  12 + .fontSize($r("app.float.font_size_16"))
  13 + .fontColor($r("app.color.color_222222"))
  14 + .width(CommonConstants.FULL_WIDTH)
  15 + Row() {
  16 + Text("锐评")
  17 + .fontSize($r("app.float.font_size_12"))
  18 + .fontColor($r("app.color.color_ED2800"))
  19 + Text(this.compDTO.operDataList[0].source)
  20 + .fontSize($r("app.float.font_size_12"))
  21 + .fontColor($r("app.color.color_B0B0B0"))
  22 + .margin({ left: 6 })
  23 + Image($r("app.media.point"))
  24 + .width(16)
  25 + .height(16)
  26 +
  27 + Text("46分钟前")
  28 + .fontSize($r("app.float.font_size_12"))
  29 + .fontColor($r("app.color.color_B0B0B0"))
  30 +
  31 + }.width(CommonConstants.FULL_WIDTH)
  32 + .justifyContent(FlexAlign.Start)
  33 + .margin({ top: 8 })
  34 +
  35 + }.width("100%")
  36 + .padding({
  37 + top: 14,
  38 + left: 16,
  39 + right: 16,
  40 + bottom: 14
  41 + })
  42 + .backgroundColor($r("app.color.white"))
  43 + .margin({ bottom: 8 })
  44 + }
  45 +}
@@ -21,7 +21,7 @@ export struct TopNavigationComponent { @@ -21,7 +21,7 @@ export struct TopNavigationComponent {
21 Tabs() { 21 Tabs() {
22 ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => { 22 ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => {
23 TabContent() { 23 TabContent() {
24 - PageComponent({ currentTopNavSelectedIndex: index }) 24 + PageComponent({ currentTopNavSelectedIndex: index, pageId: navItem.pageId, channelId: navItem.channelId })
25 } 25 }
26 .tabBar(this.tabBarBuilder(navItem, index)) 26 .tabBar(this.tabBarBuilder(navItem, index))
27 }, (navItem: TopNavDTO) => JSON.stringify(navItem)); 27 }, (navItem: TopNavDTO) => JSON.stringify(navItem));
  1 +import HashMap from '@ohos.util.HashMap'
  2 +import { ConfigConstants } from 'wdConstant/src/main/ets/constants/ConfigConstants'
  3 +import { DateTimeUtils, Logger } from 'wdKit'
  4 +
  5 +/**
  6 + * 网络请求业务侧工具类
  7 + */
  8 +export class HttpUrlUtils {
  9 + /**
  10 + * 现网地址
  11 + */
  12 + static readonly HOST: string = "https://pd-apis-uat.pdnews.cn";
  13 + /**
  14 + * 启动接口(底导接口)
  15 + */
  16 + static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup";
  17 + /**
  18 + * 展现comp接口
  19 + */
  20 + static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
  21 +
  22 + static getCommonHeaders(): HashMap<string, string> {
  23 + let headers: HashMap<string, string> = new HashMap<string, string>()
  24 + headers.set('User-Agent', 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)')
  25 + headers.set('channel', this.getChannel())
  26 + headers.set('appCode', ConfigConstants.appCode)
  27 + headers.set('plat', this.getPlat())
  28 + headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a')
  29 + headers.set('Content-Type', 'application/json; charset=utf-8')
  30 + headers.set('timestamp', this.getTimestamp())
  31 + headers.set('RMRB-X-TOKEN', this.getXToken())
  32 + headers.set('device_id', this.getDeviceId())
  33 + headers.set('cookie', 'RMRB-X-TOKEN=eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc')
  34 + headers.set('build_version', this.getVersion())
  35 + headers.set('adcode', this.getAdCode())
  36 + headers.set('os_version', this.getOsVersion())
  37 + headers.set('X-Ca-Stage', 'PRE')
  38 + headers.set('versionCode', this.getVersionCode())
  39 + headers.set('system', this.getTerminalId())
  40 + headers.set('version_name', 'debug')
  41 + headers.set('EagleEye-TraceID', '0B6DE03D2997435BA875FFBE05425ED2')
  42 + headers.set('imei', this.getImei())
  43 + headers.set('Accept-Language', 'zh')
  44 + headers.set('city', this.getCity())
  45 + headers.set('city_dode', this.getCityCode())
  46 + // TODO 判断是否登录
  47 + headers.set('userId', this.getUserId())
  48 + headers.set('userType', this.getUserType())
  49 + Logger.debug("TAG", 'getCommonHeaders headers: ' + headers);
  50 + return headers;
  51 + }
  52 +
  53 + static getBottomNavGroupUrl() {
  54 + // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
  55 + return this.HOST + this.BOTTOM_NAV_PATH;
  56 + }
  57 +
  58 + static getCompInfoUrl(pageId: string, groupId: string, channelId: string) {
  59 + let url = this.HOST + this.COMP_PATH;
  60 + // TODO 暂定只请求第一页,后续对接分页加载,参数再调整
  61 + url = url + "?channelStrategy=2&pageSize=20&pageNum=1&loadStrategy=first_load"
  62 + + "&districtCode=" + this.getDistrictCode()
  63 + + "&provinceCode=" + this.getProvinceCode()
  64 + + "&cityCode=" + this.getCityCode()
  65 + // + "&refreshTime=" + DateTimeUtils.getCurrentTimeMillis()
  66 + + "&refreshTime=" + "1703472405653"
  67 + + "&pageId=" + pageId
  68 + + "&groupId=" + groupId
  69 + + "&channelId=" + channelId;
  70 + return url;
  71 + }
  72 +
  73 +
  74 + private static getCity() {
  75 + // TODO 对接定位
  76 + return '%E5%90%88%E8%82%A5%E5%B8%82';
  77 + }
  78 +
  79 + private static getChannel() {
  80 + // TODO 对接配置
  81 + return 'rmrb_china_0000';
  82 + }
  83 +
  84 + private static getPlat() {
  85 + return 'Phone';
  86 + }
  87 +
  88 + private static getTimestamp() {
  89 + // return DateTimeUtils.getCurrentTime() + '';
  90 + return '155203523';
  91 + }
  92 +
  93 + private static getXToken() {
  94 + return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc';
  95 + }
  96 +
  97 + private static getDeviceId() {
  98 + // TODO
  99 + return 'b5cf725d-193d-3215-8c77-e76fe15ce64d';
  100 + }
  101 +
  102 + private static getVersion() {
  103 + // TODO
  104 + return '202312251034';
  105 + }
  106 +
  107 + private static getVersionCode() {
  108 + // TODO
  109 + return '7301';
  110 + }
  111 +
  112 + private static getAdCode() {
  113 + return '340000';
  114 + }
  115 +
  116 + private static getOsVersion() {
  117 + // TODO
  118 + return '13';
  119 + }
  120 +
  121 + private static getCityCode() {
  122 + // TODO
  123 + return '340100';
  124 + }
  125 +
  126 + private static getProvinceCode() {
  127 + // TODO
  128 + return '340000';
  129 + }
  130 +
  131 + /**
  132 + * 地区code
  133 + */
  134 + private static getDistrictCode() {
  135 + // TODO
  136 + return '340103';
  137 + }
  138 +
  139 + private static getTerminalId() {
  140 + return 'Android';
  141 + }
  142 +
  143 + private static getImei() {
  144 + // TODO
  145 + return 'b5cf725d-193d-3215-8c77-e76fe15ce64d';
  146 + }
  147 +
  148 + private static getUserId() {
  149 + // TODO 对接登录
  150 + return '459776297474949';
  151 + }
  152 +
  153 + private static getUserType() {
  154 + return '2';
  155 + }
  156 +}
1 import { ResponseDTO, WDHttp } from 'wdNetwork'; 1 import { ResponseDTO, WDHttp } from 'wdNetwork';
2 import { NavigationBodyDTO } from './bean/NavigationBodyDTO'; 2 import { NavigationBodyDTO } from './bean/NavigationBodyDTO';
3 import { PageDTO } from './bean/PageDTO'; 3 import { PageDTO } from './bean/PageDTO';
  4 +import HashMap from '@ohos.util.HashMap';
  5 +import { HttpUrlUtils } from '../network/HttpUrlUtils';
4 6
5 export class PageRepository { 7 export class PageRepository {
6 -  
7 - static fetchNavigationDataApi(url: string) {  
8 - return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url) 8 + static fetchNavigationDataApi() {
  9 + let url = HttpUrlUtils.getBottomNavGroupUrl();
  10 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  11 + return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url, headers)
9 }; 12 };
10 13
11 - static fetchPageData(url: string) {  
12 - return WDHttp.get<ResponseDTO<PageDTO>>(url) 14 + static fetchPageData(pageId: string, groupId: string, channelId: string) {
  15 + let url = HttpUrlUtils.getCompInfoUrl(pageId, groupId, channelId)
  16 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  17 + return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
13 }; 18 };
14 } 19 }
  1 +/**
  2 + * 网络请求业务侧工具类
  3 + */
  4 +import { BottomNavDTO } from './bean/BottomNavDTO';
  5 +
  6 +export class UIUtils {
  7 +
  8 + /**
  9 + * 判断是否为我的页面
  10 + */
  11 + static isMine(navItem: BottomNavDTO): boolean {
  12 + if (navItem == null) {
  13 + return false;
  14 + }
  15 + return navItem.type == '2';
  16 + }
  17 +}
@@ -36,5 +36,6 @@ export interface BottomNavDTO { @@ -36,5 +36,6 @@ export interface BottomNavDTO {
36 statusBarColor: number; 36 statusBarColor: number;
37 topNavChannelList: TopNavDTO[]; 37 topNavChannelList: TopNavDTO[];
38 topStyle: string; 38 topStyle: string;
  39 + // 1-普通页面,2-我的
39 type: string; 40 type: string;
40 } 41 }
@@ -33,4 +33,5 @@ export interface ContentDTO { @@ -33,4 +33,5 @@ export interface ContentDTO {
33 title: string; 33 title: string;
34 vImageUrl: string; 34 vImageUrl: string;
35 screenType: string; 35 screenType: string;
  36 + source:string;
36 } 37 }
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * 顶导 2 * 顶导
3 */ 3 */
4 export interface TopNavDTO { 4 export interface TopNavDTO {
5 - channelId: number; 5 + channelId: string;
6 channelStyle: number; 6 channelStyle: number;
7 channelType: number; 7 channelType: number;
8 defaultPermitted: number; 8 defaultPermitted: number;
@@ -21,7 +21,7 @@ export interface TopNavDTO { @@ -21,7 +21,7 @@ export interface TopNavDTO {
21 myChannel: string; 21 myChannel: string;
22 name: string; 22 name: string;
23 num: number; 23 num: number;
24 - pageId: number; 24 + pageId: string;
25 pageType: string; 25 pageType: string;
26 underlineCColor: string; 26 underlineCColor: string;
27 } 27 }
  1 +import { Logger } from 'wdKit';
  2 +import { ResponseDTO } from 'wdNetwork';
  3 +
  4 +/**
  5 + * 处理返回后的数据
  6 + */
  7 +export abstract class BaseViewModel {
  8 + abstract getLogTag(): string;
  9 +
  10 + public isRespondsInvalid(resDTO: ResponseDTO<any>, tag?: string): boolean {
  11 + if (resDTO == null) {
  12 + Logger.error(this.getLogTag(), `${tag == null ? '' : tag + ', '}resDTO is empty`);
  13 + return true;
  14 + }
  15 + // code = 0, success
  16 + if (resDTO.code != 0) {
  17 + Logger.error(this.getLogTag(), `${tag == null ? '' : tag + ', '}code error, code:${resDTO.code}, message:${resDTO.message}`);
  18 + return true;
  19 + }
  20 + if (!resDTO.data) {
  21 + Logger.error(this.getLogTag(), `${tag == null ? '' : tag + ', '}resDTO.data is null`);
  22 + return true;
  23 + }
  24 + return false;
  25 + }
  26 +}
1 -import { Logger, ResourcesUtils } from 'wdKit'; 1 +import { AppContext, Logger, ResourcesUtils } from 'wdKit';
2 import { ResponseDTO, } from 'wdNetwork'; 2 import { ResponseDTO, } from 'wdNetwork';
3 import { PageRepository } from '../repository/PageRepository'; 3 import { PageRepository } from '../repository/PageRepository';
4 import http from '@ohos.net.http'; 4 import http from '@ohos.net.http';
5 import { NavigationBodyDTO } from '../repository/bean/NavigationBodyDTO'; 5 import { NavigationBodyDTO } from '../repository/bean/NavigationBodyDTO';
6 import { BottomNavDTO } from '../repository/bean/BottomNavDTO'; 6 import { BottomNavDTO } from '../repository/bean/BottomNavDTO';
7 import { PageDTO } from '../repository/bean/PageDTO'; 7 import { PageDTO } from '../repository/bean/PageDTO';
  8 +import { BaseViewModel } from './BaseViewModel';
  9 +import Router from '@system.router';
  10 +import router from '@ohos.router';
8 11
9 const TAG = 'PageViewModel'; 12 const TAG = 'PageViewModel';
  13 +/**
  14 + * mock数据开关,默认关。
  15 + * mock数据是本地json数据,可自行修改内容(‘entry\src\main\resources\rawfile\’目录)
  16 + */
  17 +const mock_switch = true;
10 18
11 /** 19 /**
12 * 处理返回后的数据 20 * 处理返回后的数据
13 */ 21 */
14 -export class PageViewModel { 22 +export class PageViewModel extends BaseViewModel {
  23 + getLogTag() {
  24 + return TAG;
  25 + }
  26 +
15 /** 27 /**
16 * get Nav Data from Resource . 28 * get Nav Data from Resource .
17 * 29 *
18 * @return BottomNavBean[] Nav Data List 30 * @return BottomNavBean[] Nav Data List
19 */ 31 */
20 - static async getBottomNavData(context: Context): Promise<BottomNavDTO[]> { 32 + async getBottomNavData(): Promise<NavigationBodyDTO> {
21 Logger.info(TAG, `getBottomNavData start`); 33 Logger.info(TAG, `getBottomNavData start`);
22 - let compRes: ResponseDTO<NavigationBodyDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<NavigationBodyDTO>>(context, 'bottom_nav.json');  
23 - if (!compRes || !compRes.data || !compRes.data.bottomNavList) {  
24 - Logger.info(TAG, `getBottomNavData compRes bottomNavList is empty`);  
25 - return [] 34 + if (mock_switch) {
  35 + return this.getBottomNavDataMock();
26 } 36 }
27 - Logger.info(TAG, `getBottomNavData getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);  
28 - return compRes.data.bottomNavList 37 + return this.getNavData();
  38 + }
  39 +
  40 + async getBottomNavDataMock(): Promise<NavigationBodyDTO> {
  41 + Logger.info(TAG, `getBottomNavDataMock start`);
  42 + let compRes: ResponseDTO<NavigationBodyDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<NavigationBodyDTO>>('bottom_nav.json');
  43 + if (!compRes || !compRes.data) {
  44 + Logger.info(TAG, `getBottomNavDataMock compRes bottomNavList is empty`);
  45 + return null
  46 + }
  47 + Logger.info(TAG, `getBottomNavDataMock getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
  48 + return compRes.data
29 } 49 }
30 50
31 - static getNavData(url: string): Promise<NavigationBodyDTO> { 51 + private getNavData(): Promise<NavigationBodyDTO> {
32 return new Promise<NavigationBodyDTO>((success, error) => { 52 return new Promise<NavigationBodyDTO>((success, error) => {
33 Logger.info(TAG, `getNavData start`); 53 Logger.info(TAG, `getNavData start`);
34 - PageRepository.fetchNavigationDataApi(url).then((navResDTO: ResponseDTO<NavigationBodyDTO>) => {  
35 - if (!navResDTO) {  
36 - Logger.error(TAG, 'getNavData then navResDTO is empty');  
37 - error('navResDTO is empty'); 54 + PageRepository.fetchNavigationDataApi().then((navResDTO: ResponseDTO<NavigationBodyDTO>) => {
  55 + if (this.isRespondsInvalid(navResDTO, 'getNavData')) {
  56 + error("page data invalid");
38 return 57 return
39 } 58 }
40 - if (navResDTO.code != http.ResponseCode.OK) {  
41 - Logger.error(TAG, `getNavData then code:${navResDTO.code}, message:${navResDTO.message}`);  
42 - error('navResDTO Response Code is failure');  
43 - return  
44 - }  
45 - if (!navResDTO.data?.bottomNavList) {  
46 - error('navResDTO list is empty');  
47 - return  
48 - }  
49 - // let navResStr = JSON.stringify(navResDTO);  
50 Logger.info(TAG, "getNavData then,navResDTO.timeStamp:" + navResDTO.timestamp); 59 Logger.info(TAG, "getNavData then,navResDTO.timeStamp:" + navResDTO.timestamp);
51 let navigationBean = navResDTO.data 60 let navigationBean = navResDTO.data
52 success(navigationBean); 61 success(navigationBean);
@@ -62,8 +71,8 @@ export class PageViewModel { @@ -62,8 +71,8 @@ export class PageViewModel {
62 * 71 *
63 * @return {GroupDTO} compRes.data 72 * @return {GroupDTO} compRes.data
64 */ 73 */
65 - static async getPageData1(context: Context): Promise<PageDTO> {  
66 - let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context, 'comp_list0.json'); 74 + private async getPageData1(): Promise<PageDTO> {
  75 + let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>('comp_list0.json');
67 if (!compRes || !compRes.data) { 76 if (!compRes || !compRes.data) {
68 Logger.info(TAG, `getCompList compRes is empty`); 77 Logger.info(TAG, `getCompList compRes is empty`);
69 return {} as PageDTO 78 return {} as PageDTO
@@ -76,29 +85,28 @@ export class PageViewModel { @@ -76,29 +85,28 @@ export class PageViewModel {
76 * Get Group data. 85 * Get Group data.
77 * 86 *
78 * @return {GroupDTO} compRes.data 87 * @return {GroupDTO} compRes.data
  88 + * @deprecated
79 */ 89 */
80 - static async getPageData2(context: Context): Promise<PageDTO> {  
81 - let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context, 'comp_list2.json'); 90 + private async getPageData2(): Promise<PageDTO> {
  91 + let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>('comp_list2.json');
82 if (!compRes || !compRes.data) { 92 if (!compRes || !compRes.data) {
83 Logger.info(TAG, `getCompList compRes is empty`); 93 Logger.info(TAG, `getCompList compRes is empty`);
84 return {} as PageDTO 94 return {} as PageDTO
85 } 95 }
  96 + // router.push('')
86 Logger.info(TAG, `getCompList getResourcesJson compRes : ${JSON.stringify(compRes)}`); 97 Logger.info(TAG, `getCompList getResourcesJson compRes : ${JSON.stringify(compRes)}`);
87 return compRes.data 98 return compRes.data
88 } 99 }
89 100
90 -  
91 - static getPageData(url: string): Promise<PageDTO> { 101 + async getPageData(pageId: string, groupId: string, channelId: string): Promise<PageDTO> {
  102 + Logger.error(TAG, 'getPageData pageId: ' + pageId);
  103 + if (mock_switch) {
  104 + return this.getPageData1();
  105 + }
92 return new Promise<PageDTO>((success, error) => { 106 return new Promise<PageDTO>((success, error) => {
93 - PageRepository.fetchPageData(url).then((resDTO: ResponseDTO<PageDTO>) => {  
94 - if (!resDTO) {  
95 - Logger.error(TAG, 'getPageData then resDTO is empty');  
96 - error("page data is empty");  
97 - return  
98 - }  
99 - if (resDTO.code != http.ResponseCode.OK || !resDTO.data) {  
100 - Logger.error(TAG, `getPageData then code:${resDTO.code}, message:${resDTO.message}`);  
101 - error(`get page data error code:${resDTO.code}, message:${resDTO.message}`); 107 + PageRepository.fetchPageData(pageId, groupId, channelId).then((resDTO: ResponseDTO<PageDTO>) => {
  108 + if (this.isRespondsInvalid(resDTO, 'getPageData')) {
  109 + error("page data invalid");
102 return 110 return
103 } 111 }
104 Logger.info(TAG, "getPageData then,resDTO.timeStamp:" + resDTO.timestamp); 112 Logger.info(TAG, "getPageData then,resDTO.timeStamp:" + resDTO.timestamp);
@@ -112,7 +120,6 @@ export class PageViewModel { @@ -112,7 +120,6 @@ export class PageViewModel {
112 } 120 }
113 121
114 122
115 -  
116 let pageViewModel = new PageViewModel(); 123 let pageViewModel = new PageViewModel();
117 124
118 export default pageViewModel as PageViewModel; 125 export default pageViewModel as PageViewModel;
@@ -19,6 +19,26 @@ @@ -19,6 +19,26 @@
19 { 19 {
20 "name": "color_FE4B05", 20 "name": "color_FE4B05",
21 "value": "#FE4B05" 21 "value": "#FE4B05"
  22 + },
  23 + {
  24 + "name": "color_222222",
  25 + "value": "#222222"
  26 + },
  27 + {
  28 + "name": "color_ED2800",
  29 + "value": "#ED2800"
  30 + },
  31 + {
  32 + "name": "color_B0B0B0",
  33 + "value": "#B0B0B0"
  34 + },
  35 + {
  36 + "name": "color_fff",
  37 + "value": "#ffffff"
  38 + },
  39 + {
  40 + "name": "color_4d000000",
  41 + "value": "#4d000000"
22 } 42 }
23 ] 43 ]
24 } 44 }
@@ -10,7 +10,11 @@ @@ -10,7 +10,11 @@
10 }, 10 },
11 { 11 {
12 "name": "font_size_12", 12 "name": "font_size_12",
13 - "value": "11fp" 13 + "value": "12fp"
  14 + },
  15 + {
  16 + "name": "font_size_13",
  17 + "value": "13fp"
14 }, 18 },
15 { 19 {
16 "name": "font_size_14", 20 "name": "font_size_14",
@@ -21,6 +25,10 @@ @@ -21,6 +25,10 @@
21 "value": "16fp" 25 "value": "16fp"
22 }, 26 },
23 { 27 {
  28 + "name": "font_size_17",
  29 + "value": "17fp"
  30 + },
  31 + {
24 "name": "normal_text_size", 32 "name": "normal_text_size",
25 "value": "16fp" 33 "value": "16fp"
26 }, 34 },
@@ -28,7 +28,7 @@ export class ConfigConstants { @@ -28,7 +28,7 @@ export class ConfigConstants {
28 /** 28 /**
29 * 产品渠道应用对照关系: 29 * 产品渠道应用对照关系:
30 */ 30 */
31 - static readonly appCode: string = ""; 31 + static readonly appCode: string = "83092caa603a421aa0222308b3f6b27a";
32 /** 32 /**
33 * 基线代码和客户端应用版本号规范 33 * 基线代码和客户端应用版本号规范
34 */ 34 */
@@ -19,4 +19,6 @@ export const enum CompStyle { @@ -19,4 +19,6 @@ export const enum CompStyle {
19 Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播 19 Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播
20 Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单 20 Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单
21 Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动 21 Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动
  22 + Title_Abbr_01 = 'Title_Abbr_01', // 标题缩略
  23 + Title_All_01 = 'Title_All_01', // 全标题
22 } 24 }
@@ -10,3 +10,7 @@ export { BasicDataSource } from './utils/BasicDataSource'; @@ -10,3 +10,7 @@ export { BasicDataSource } from './utils/BasicDataSource';
10 10
11 export { LazyDataSource } from './utils/LazyDataSource' 11 export { LazyDataSource } from './utils/LazyDataSource'
12 12
  13 +export { DateTimeUtils } from './utils/DateTimeUtils'
  14 +
  15 +export { AppContext } from './utils/AppContext'
  16 +
  1 +/**
  2 + * 应用ability上下文管理类
  3 + */
  4 +export class AppContext {
  5 + private static sContext: Context;
  6 +
  7 + public static init(abilityContext: Context) {
  8 + this.sContext = abilityContext;
  9 + }
  10 +
  11 + public static getAbilityContext() {
  12 + return this.sContext;
  13 + }
  14 +}
@@ -316,6 +316,21 @@ export class DateTimeUtils { @@ -316,6 +316,21 @@ export class DateTimeUtils {
316 static isTomorrow(date: number): boolean { 316 static isTomorrow(date: number): boolean {
317 return this.isSameDay(date, this.addDays(Date.now(), 1).getTime()); 317 return this.isSameDay(date, this.addDays(Date.now(), 1).getTime());
318 } 318 }
  319 +
  320 +
  321 + /**
  322 + * 获取当前时间戳,秒
  323 + * */
  324 + public static getCurrentTime(): number {
  325 + let time: number = new Date().getTime();
  326 + return Math.floor(time / 1000);
  327 + }
  328 + /**
  329 + * 获取当前时间戳,毫秒
  330 + * */
  331 + public static getCurrentTimeMillis(): number {
  332 + return new Date().getTime();
  333 + }
319 } 334 }
320 335
321 // const dateTimeUtils = new DateTimeUtils() 336 // const dateTimeUtils = new DateTimeUtils()
1 import buffer from '@ohos.buffer'; 1 import buffer from '@ohos.buffer';
  2 +import { AppContext } from './AppContext';
2 import { Logger } from './Logger'; 3 import { Logger } from './Logger';
3 4
4 const TAG = "ResourcesUtils"; 5 const TAG = "ResourcesUtils";
@@ -13,7 +14,10 @@ export class ResourcesUtils { @@ -13,7 +14,10 @@ export class ResourcesUtils {
13 * @param filename 仅文件名(不包含路径,文件在src\main\resources\rawfile下),如:"agconnect-services.json",test.xml, 14 * @param filename 仅文件名(不包含路径,文件在src\main\resources\rawfile下),如:"agconnect-services.json",test.xml,
14 * @returns text 字符串 15 * @returns text 字符串
15 */ 16 */
16 - static getResourcesText(context: Context, filename: string): Promise<string> { 17 + static getResourcesText(filename: string, context?: Context): Promise<string> {
  18 + if (context == null) {
  19 + context = AppContext.getAbilityContext();
  20 + }
17 return new Promise((success, error) => { 21 return new Promise((success, error) => {
18 Logger.info(TAG, "ResourcesUtils getResourcesText filename:" + filename); 22 Logger.info(TAG, "ResourcesUtils getResourcesText filename:" + filename);
19 context.resourceManager.getRawFileContent(filename).then((content: Uint8Array) => { 23 context.resourceManager.getRawFileContent(filename).then((content: Uint8Array) => {
@@ -53,14 +57,17 @@ export class ResourcesUtils { @@ -53,14 +57,17 @@ export class ResourcesUtils {
53 * 调用方式: 57 * 调用方式:
54 * let compRes: MGHttp.ResponseDTO<BodyComponent> = await ResourcesUtils.getResourcesJson<MGHttp.ResponseDTO<BodyComponent>>(context, 'model/componentList.json'); 58 * let compRes: MGHttp.ResponseDTO<BodyComponent> = await ResourcesUtils.getResourcesJson<MGHttp.ResponseDTO<BodyComponent>>(context, 'model/componentList.json');
55 */ 59 */
56 - static getResourcesJson<R>(context:Context, filename: string): Promise<R> { 60 + static getResourcesJson<R>(filename: string, context?: Context): Promise<R> {
57 Logger.info(TAG, `getResourcesJson filename: ${filename}`); 61 Logger.info(TAG, `getResourcesJson filename: ${filename}`);
  62 + if (context == null) {
  63 + context = AppContext.getAbilityContext();
  64 + }
58 return new Promise<R>((resolve, reject) => { 65 return new Promise<R>((resolve, reject) => {
59 - ResourcesUtils.getResourcesText(context, filename) 66 + ResourcesUtils.getResourcesText(filename, context)
60 .then((text: string) => { 67 .then((text: string) => {
61 try { 68 try {
62 // let config: R = JSON.parse(text) 69 // let config: R = JSON.parse(text)
63 - let config:R = JSON.parse(text) as R; 70 + let config: R = JSON.parse(text) as R;
64 if (config) { 71 if (config) {
65 Logger.info(TAG, "getResourcesJson parse JSON file success."); 72 Logger.info(TAG, "getResourcesJson parse JSON file success.");
66 // Logger.info(TAG, `getResourcesJson config : ${JSON.stringify(config)}`); 73 // Logger.info(TAG, `getResourcesJson config : ${JSON.stringify(config)}`);
@@ -74,7 +81,7 @@ export class ResourcesUtils { @@ -74,7 +81,7 @@ export class ResourcesUtils {
74 reject(err) 81 reject(err)
75 } 82 }
76 }) 83 })
77 - .catch((error:Error) => { 84 + .catch((error: Error) => {
78 reject(error) 85 reject(error)
79 }) 86 })
80 }) 87 })
1 -import type { AxiosError, AxiosRequestConfig} from '@ohos/axios'; 1 +import { AxiosError, AxiosHeaders, AxiosRequestConfig, RawAxiosRequestHeaders } from '@ohos/axios';
  2 +import HashMap from '@ohos.util.HashMap';
2 import service from './AxiosRequest'; 3 import service from './AxiosRequest';
3 4
4 export class HttpRequest { 5 export class HttpRequest {
@@ -6,17 +7,28 @@ export class HttpRequest { @@ -6,17 +7,28 @@ export class HttpRequest {
6 static request<T = any>(config: AxiosRequestConfig): Promise<T> { 7 static request<T = any>(config: AxiosRequestConfig): Promise<T> {
7 return new Promise<T>((resolve, reject) => { 8 return new Promise<T>((resolve, reject) => {
8 service.request<any, T>(config) 9 service.request<any, T>(config)
9 - .then((res:T) => { 10 + .then((res: T) => {
10 resolve(res) 11 resolve(res)
11 }) 12 })
12 - .catch((err:AxiosError) => { 13 + .catch((err: AxiosError) => {
13 reject(err) 14 reject(err)
14 }) 15 })
15 }) 16 })
16 // return service.request<any, T>(config) 17 // return service.request<any, T>(config)
17 } 18 }
18 19
19 - static get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T> { 20 + private static get0<T = any>(url: string, config?: AxiosRequestConfig): Promise<T> {
  21 + return service.get(url, config)
  22 + }
  23 +
  24 + static get<T = any>(url: string, headers?: HashMap<string, string>): Promise<T> {
  25 + let requestHeaders: AxiosHeaders = new AxiosHeaders()
  26 + headers?.forEach((v, k) => {
  27 + requestHeaders.set(k, v);
  28 + });
  29 + let config: AxiosRequestConfig = {
  30 + headers: requestHeaders as RawAxiosRequestHeaders
  31 + }
20 return service.get(url, config) 32 return service.get(url, config)
21 } 33 }
22 34