fanmingyou3_wd

添加早晚报页面

Showing 23 changed files with 630 additions and 143 deletions
  1 +import { MorningEveningPaperComponent } from 'wdComponent';
  2 +import { Logger } from 'wdKit';
  3 +
  4 +const TAG = 'MorningEveningPaperPage';
  5 +
  6 +@Entry
  7 +@Component
  8 +struct MorningEveningPaperPage {
  9 + build() {
  10 + Column() {
  11 + MorningEveningPaperComponent()
  12 + }
  13 + }
  14 +
  15 + pageTransition() {
  16 + // 定义页面进入时的效果,从底侧滑入
  17 + PageTransitionEnter({ type: RouteType.None, duration: 300 })
  18 + .slide(SlideEffect.Bottom)
  19 + // 定义页面退出时的效果,向底侧滑出
  20 + PageTransitionExit({ type: RouteType.None, duration: 300 })
  21 + .slide(SlideEffect.Bottom)
  22 + }
  23 +
  24 + aboutToAppear() {
  25 + Logger.info(TAG, 'aboutToAppear');
  26 + }
  27 +
  28 + aboutToDisappear() {
  29 + Logger.info(TAG, 'aboutToDisappear');
  30 + }
  31 +
  32 + onPageShow() {
  33 + Logger.info(TAG, 'onPageShow');
  34 + }
  35 +
  36 + onPageHide() {
  37 + Logger.info(TAG, 'onPageHide');
  38 + }
  39 +
  40 + onBackPress() {
  41 + Logger.info(TAG, 'onBackPress');
  42 + }
  43 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 "pages/MainPage", 3 "pages/MainPage",
4 "pages/web/DefaultWebPage", 4 "pages/web/DefaultWebPage",
5 "pages/ENewspaper", 5 "pages/ENewspaper",
6 - "pages/ImageAndTextDetailPage" 6 + "pages/ImageAndTextDetailPage",
  7 + "pages/MorningEveningPaperPage"
7 ] 8 ]
8 } 9 }
@@ -12,14 +12,17 @@ export { ItemBean } from './src/main/ets/bean/ItemBean'; @@ -12,14 +12,17 @@ export { ItemBean } from './src/main/ets/bean/ItemBean';
12 12
13 // Content 13 // Content
14 export { ContentDTO } from './src/main/ets/bean/content/ContentDTO'; 14 export { ContentDTO } from './src/main/ets/bean/content/ContentDTO';
  15 +
15 export { Action } from './src/main/ets/bean/content/Action' 16 export { Action } from './src/main/ets/bean/content/Action'
16 17
17 export { Params } from './src/main/ets/bean/content/Params' 18 export { Params } from './src/main/ets/bean/content/Params'
18 19
19 export { Pic } from './src/main/ets/bean/content/Pic' 20 export { Pic } from './src/main/ets/bean/content/Pic'
  21 +
20 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; 22 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO';
21 -export { InteractParam } from './src/main/ets/bean/content/InteractParam';  
22 -export { ContentBean } from './src/main/ets/bean/content/ContentBean'; 23 +
  24 +export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
  25 +
23 export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean'; 26 export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean';
24 27
25 export { LabelDTO } from './src/main/ets/bean/component/extra/LabelDTO'; 28 export { LabelDTO } from './src/main/ets/bean/component/extra/LabelDTO';
@@ -62,3 +65,7 @@ export { H5ReceiveDataJsonBean } from './src/main/ets/bean/h5/H5ReceiveDataJsonB @@ -62,3 +65,7 @@ export { H5ReceiveDataJsonBean } from './src/main/ets/bean/h5/H5ReceiveDataJsonB
62 export { H5ReceiveDataExtraBean } from './src/main/ets/bean/h5/H5ReceiveDataExtraBean'; 65 export { H5ReceiveDataExtraBean } from './src/main/ets/bean/h5/H5ReceiveDataExtraBean';
63 66
64 export { ResponseBean } from './src/main/ets/bean/h5/ResponseBean'; 67 export { ResponseBean } from './src/main/ets/bean/h5/ResponseBean';
  68 +
  69 +export { MorningEveningPaperDTO } from './src/main/ets/bean/component/MorningEveningPaperDTO';
  70 +
  71 +export { FrontLinkObject } from './src/main/ets/bean/component/FrontLinkObject';
  1 +export interface FrontLinkObject {
  2 + coverSize: string;
  3 + coverUrl: string;
  4 + linkUrl: string;
  5 + newsId: string;
  6 + newsLevel: string;
  7 + // newsPageId?: any;
  8 + newsRelId: number;
  9 + // newsRelType?: any;
  10 + newsType: number;
  11 + publishTime: string;
  12 + source: string;
  13 + summary: string;
  14 + title: string;
  15 +}
@@ -4,10 +4,10 @@ import { CompDTO } from './CompDTO'; @@ -4,10 +4,10 @@ import { CompDTO } from './CompDTO';
4 * 组件列表的body 4 * 组件列表的body
5 */ 5 */
6 export interface GroupDTO { 6 export interface GroupDTO {
7 - pageId: string; // 页面id  
8 - id: number; // 楼层id  
9 - name: string; // 名称  
10 - branchMark: boolean;  
11 - compList: CompDTO[]; // Components集合的布局信息  
12 - // compAdList?: any[]; 7 + blockDesc: string;
  8 + groupStrategy: number;
  9 + id: number;
  10 + // itemNum?: any;
  11 + showType: number;
  12 + sortValue: number;
13 } 13 }
  1 +import { GroupDTO } from './GroupDTO';
  2 +import { TopicInfoDTO } from './TopicInfoDTO';
  3 +
  4 +export interface MorningEveningPaperDTO {
  5 + backIconUrl: string;
  6 + backgroundColor: string;
  7 + backgroundImgUrl: string;
  8 + baselineColor: string;
  9 + baselineCopywriting: string;
  10 + baselineShow: number;
  11 + // channelInfo?: any;
  12 + // cornersAdv?: any;
  13 + // cornersAdv2: any[];
  14 + description: string;
  15 + groups: GroupDTO[];
  16 + hasAdInfo: number;
  17 + hasPopUp: number;
  18 + id: number;
  19 + mainLogoImgUrl: string;
  20 + name: string;
  21 + // pageTopParams?: any;
  22 + pageTopType: number;
  23 + pageType: number;
  24 + // popUps: any[];
  25 + pushupLogoImgUrl: string;
  26 + shareCoverUrl: string;
  27 + shareIconUrl: string;
  28 + shareName: string;
  29 + shareSummary: string;
  30 + shareUrl: string;
  31 + statusBarColor: string;
  32 + templateType: number;
  33 + titleColor: string;
  34 + topicInfo: TopicInfoDTO;
  35 +}
  1 +import { FrontLinkObject } from './FrontLinkObject';
  2 +
  3 +export interface TopicInfoDTO {
  4 + axisColor: string;
  5 + // channelId?: any;
  6 + commentFlag: number;
  7 + commentPreviewFlag: number;
  8 + commentShowFlag: number;
  9 + frontFlag: number;
  10 + frontLinkObject: FrontLinkObject;
  11 + posterFlag: number;
  12 + posterUrl: string;
  13 + // relId?: any;
  14 + // relObjectId?: any;
  15 + // relType?: any;
  16 + shareCoverUrl: string;
  17 + shareOpen: number;
  18 + sharePosterCoverUrl: string;
  19 + // sharePosterOpen?: any;
  20 + shareSummary: string;
  21 + shareTitle: string;
  22 + shareUrl: string;
  23 + slideColor: string;
  24 + summary: string;
  25 + title: string;
  26 + // titleShow?: any;
  27 + topicDate: string;
  28 + topicId: string;
  29 + topicPattern: number;
  30 + // topicTemplate?: any;
  31 + topicType: number;
  32 + transluceImgUrl: string;
  33 + visitorComment: number;
  34 + // voteInfo?: any;
  35 +}
1 import { FullColumnImgUrlDTO } from '../detail/FullColumnImgUrlDTO'; 1 import { FullColumnImgUrlDTO } from '../detail/FullColumnImgUrlDTO';
2 import { LiveInfoDTO } from '../detail/LiveInfoDTO'; 2 import { LiveInfoDTO } from '../detail/LiveInfoDTO';
3 import { VideoInfoDTO } from '../detail/VideoInfoDTO'; 3 import { VideoInfoDTO } from '../detail/VideoInfoDTO';
4 -import { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; 4 +import { InteractDataDTO } from './InteractDataDTO';
  5 +
5 export interface ContentDTO { 6 export interface ContentDTO {
6 cityCode: string; 7 cityCode: string;
7 coverSize: string; 8 coverSize: string;
@@ -34,6 +34,8 @@ export { ENewspaperItemComponent } from "./src/main/ets/components/ENewspaperIte @@ -34,6 +34,8 @@ export { ENewspaperItemComponent } from "./src/main/ets/components/ENewspaperIte
34 34
35 export { ENewspaperListDialog } from "./src/main/ets/dialog/ENewspaperListDialog" 35 export { ENewspaperListDialog } from "./src/main/ets/dialog/ENewspaperListDialog"
36 36
  37 +export { MorningEveningPaperComponent } from "./src/main/ets/components/MorningEveningPaperComponent"
  38 +
37 export { ImageAndTextPageComponent } from "./src/main/ets/components/ImageAndTextPageComponent" 39 export { ImageAndTextPageComponent } from "./src/main/ets/components/ImageAndTextPageComponent"
38 40
39 export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndTextWebComponent" 41 export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndTextWebComponent"
  1 +import router from '@ohos.router'
  2 +import { FrontLinkObject, MorningEveningPaperDTO } from 'wdBean'
  3 +import { Logger } from 'wdKit';
  4 +import PageViewModel from '../viewmodel/PageViewModel';
  5 +import { PageComponent } from './page/PageComponent';
  6 +
  7 +const TAG = 'MorningEveningPaperComponent';
  8 +
  9 +@Entry
  10 +@Component
  11 +export struct MorningEveningPaperComponent {
  12 + @State currentTopNavSelectedIndex: number = 0;
  13 + paperPageId: string = '21549'
  14 + @State groupId: string = ''
  15 + @State message: string = 'Hello World'
  16 + @State morningEveningPaperDTO: MorningEveningPaperDTO = {
  17 + name: "新闻夜读",
  18 + topicInfo: {
  19 + frontLinkObject: {
  20 + coverSize: "599*798",
  21 + coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/9a91a96077174087852cf93c5e26acce.jpeg",
  22 + newsId: "30002086032",
  23 + newsRelId: 500000256225,
  24 + summary: "欧尔班多次明确反对欧盟此举。2023年底,匈牙利否决了欧盟对乌克兰的500亿欧元援助计划,认为欧盟不应向乌克兰提供更多资金,而应尽快结束俄乌冲突。因此,欧盟领导人在去年12月欧盟峰会上未能就该计划达成一致。欧尔班多次明确反对欧盟此举。2023年底,匈牙利否决了欧盟对乌克兰的500亿欧元援助计划,认为欧盟不应向乌克兰提供更多资金,而应尽快结束俄乌冲突。因此,欧盟领导人在去年12月欧盟峰会上未能就该计",
  25 + title: "匈牙利总理欧尔班妥协,阻碍欧盟向乌克兰援助的最后一个障碍被解"
  26 + },
  27 + title: "新闻夜读",
  28 + topicDate: "2024-01-16",
  29 + topicId: "10000002068",
  30 + }
  31 + } as MorningEveningPaperDTO
  32 +
  33 + // @State morningEveningPaperDTO: MorningEveningPaperDTO = {} as MorningEveningPaperDTO
  34 +
  35 + async aboutToAppear() {
  36 + console.info(TAG, `aboutToAppear`);
  37 + let paperDTO = await PageViewModel.getMorningEveningPaperData(this.paperPageId)
  38 + if (paperDTO) {
  39 + this.morningEveningPaperDTO = paperDTO;
  40 + if (paperDTO.groups && paperDTO.groups.length > 0) {
  41 + this.groupId = paperDTO.groups[0].id + ''
  42 + }
  43 + Logger.info(TAG, `aboutToAppear, paperDTO is not empty`);
  44 + }
  45 + }
  46 +
  47 + build() {
  48 + Column() {
  49 + RelativeContainer() {
  50 + Image($r('app.media.icon_read_paper'))
  51 + .height($r('app.float.top_arrow_size'))
  52 + .width($r('app.float.top_arrow_size'))
  53 + .alignRules({
  54 + left: { anchor: "__container__", align: HorizontalAlign.Start },
  55 + center: { anchor: "__container__", align: VerticalAlign.Center }
  56 + })
  57 + .id('img_logo1')
  58 +
  59 +
  60 + Row() {
  61 + Text(this.morningEveningPaperDTO?.topicInfo?.title ?? "")
  62 + .fontSize(20)
  63 + .fontColor($r('app.color.white'))
  64 + .maxLines(1)
  65 +
  66 + Text(this.morningEveningPaperDTO?.topicInfo?.topicDate ?? '')// Text('2024年\n1月16日')
  67 + .width(50)
  68 + .fontSize(12)
  69 + .fontColor($r('app.color.white'))
  70 + .maxLines(2)
  71 +
  72 + Image($r('app.media.bg_event_status_end'))
  73 + .height($r('app.float.top_arrow_size'))
  74 + .width(100)
  75 + }
  76 + .alignItems(VerticalAlign.Bottom)
  77 + .alignRules({
  78 + left: { anchor: "img_logo1", align: HorizontalAlign.End },
  79 + center: { anchor: "__container__", align: VerticalAlign.Center } })
  80 + .id('row_paper_date')
  81 +
  82 + Image($r('app.media.icon_close'))
  83 + .height($r('app.float.top_arrow_size'))
  84 + .width($r('app.float.top_arrow_size'))
  85 + .alignRules({
  86 + right: { anchor: "__container__", align: HorizontalAlign.End },
  87 + center: { anchor: "__container__", align: VerticalAlign.Center } })
  88 + .id('img_close')
  89 + .onClick((event: ClickEvent) => {
  90 + console.info(TAG, "img_close")
  91 + router.back()
  92 + })
  93 +
  94 + Image($r('app.media.icon_share'))
  95 + .height($r('app.float.top_arrow_size'))
  96 + .width($r('app.float.top_arrow_size'))
  97 + .alignRules({
  98 + right: { anchor: "img_close", align: HorizontalAlign.Start },
  99 + center: { anchor: "__container__", align: VerticalAlign.Center } })
  100 + .id('img_share')
  101 + }
  102 + .margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
  103 + .height($r('app.float.top_bar_height'))
  104 + .backgroundColor(Color.Black)
  105 +
  106 + List() {
  107 + ListItem() {
  108 + this.buildTopicInfoView(this.morningEveningPaperDTO?.topicInfo?.frontLinkObject)
  109 + }
  110 +
  111 + ListItem() {
  112 + Row() {
  113 + Row() {
  114 + Image($r('app.media.icon_listen'))
  115 + .width(24)
  116 + .height(24)
  117 + .margin({ left: 10 })
  118 + Text('晚上好, 请收听今日新闻播报')
  119 + .fontSize(14)
  120 + .margin({ left: 10 })
  121 + .fontColor(Color.Black)
  122 + .maxLines(1)
  123 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  124 + }
  125 + .width('72%')
  126 + .height(56)
  127 + .backgroundImage($r('app.media.listen_left_bg'))
  128 +
  129 + Row() {
  130 + Image($r('app.media.ic_red_triangle'))
  131 + .width(30)
  132 + .height(30)
  133 + .margin({ left: 15 })
  134 + .objectFit(ImageFit.Contain)
  135 + }
  136 + .justifyContent(FlexAlign.Center)
  137 + // .width(94)
  138 + .width('28%')
  139 + // .aspectRatio(7 / 4)
  140 + .height(56)
  141 + .backgroundImage($r('app.media.listen_right_bg'))
  142 + }
  143 + .width('100%')
  144 + .height(56)
  145 + .justifyContent(FlexAlign.SpaceBetween)
  146 +
  147 + // .backgroundColor(Color.Red)
  148 + }
  149 +
  150 + ListItem() {
  151 + PageComponent({
  152 + currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
  153 + navIndex: 0,
  154 + pageId: '31320', //this.groupId,
  155 + channelId: ''
  156 + })
  157 + }
  158 + }
  159 + // .backgroundColor('#FFF1F3F5')
  160 + // .backgroundColor(Color.Blue)
  161 + .margin({ left: 14, right: 14 })
  162 +
  163 + // .alignListItem(ListItemAlign.Center)
  164 + }.width('100%')
  165 +
  166 + // Row() {
  167 + // Column() {
  168 + // Text(this.message)
  169 + // .fontSize(50)
  170 + // .fontWeight(FontWeight.Bold)
  171 + // }
  172 + // .width('100%')
  173 + // }
  174 + // .height('100%')
  175 + }
  176 +
  177 + /**
  178 + * 布局描述
  179 + *
  180 + * @param FrontLinkObject item 组件项
  181 + * @param index
  182 + */
  183 + @Builder
  184 + buildTopicInfoView(item: FrontLinkObject) {
  185 + RelativeContainer() {
  186 + Image(item?.coverUrl)
  187 + .width("100%")
  188 + .height("100%")
  189 + .alignRules({
  190 + top: { anchor: '__container__', align: VerticalAlign.Top },
  191 + left: { anchor: '__container__', align: HorizontalAlign.Start }
  192 + })
  193 + .id('img_cover')
  194 +
  195 + Row() {
  196 + Text("查看详情")
  197 + .fontSize(20)
  198 + .fontColor($r('app.color.white'))
  199 + .maxLines(1)
  200 +
  201 + Image($r('app.media.more'))
  202 + .height($r('app.float.top_arrow_size'))
  203 + .width(20)
  204 + }
  205 + .margin({ top: 10 })
  206 + // .backgroundColor(Color.Red)
  207 + .alignRules({
  208 + left: { anchor: "__container__", align: HorizontalAlign.Start },
  209 + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }
  210 + })
  211 + .id('row_detail')
  212 +
  213 + Text(item?.summary ?? "")
  214 + .margin({ top: 10 })
  215 + .fontSize(13)
  216 + .fontColor($r('app.color.white'))
  217 + .maxLines(3)
  218 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  219 + .alignRules({
  220 + left: { anchor: "__container__", align: HorizontalAlign.Start },
  221 + bottom: { anchor: "row_detail", align: VerticalAlign.Top }
  222 + })
  223 + .id('txt_summary')
  224 +
  225 + Text(item?.title ?? "")
  226 + .fontSize(23)
  227 + .fontColor($r('app.color.white'))
  228 + .maxLines(2)
  229 + .alignRules({
  230 + left: { anchor: "__container__", align: HorizontalAlign.Start },
  231 + bottom: { anchor: "txt_summary", align: VerticalAlign.Top }
  232 + })
  233 + .id('txt_title')
  234 + }
  235 + .width("100%")
  236 + .aspectRatio(3 / 4)
  237 + // .aspectRatio(1)
  238 + // .backgroundColor(Color.Orange)
  239 + // .hoverEffect(HoverEffect.Scale)
  240 + .onClick((event: ClickEvent) => {
  241 + console.info(TAG, `buildTopicInfoView onClick event`);
  242 + // let taskAction: Action = {
  243 + // type: 'JUMP_H5_BY_WEB_VIEW',
  244 + // params: {
  245 + // url: ConfigConstants.DETAIL_URL
  246 + // } as Params,
  247 + // };
  248 + // WDRouterRule.jumpWithAction(taskAction)
  249 +
  250 + // let taskAction: Action = {
  251 + // type: 'JUMP_DETAIL_PAGE',
  252 + // params: {
  253 + // detailPageType: 7, // 沉浸式竖屏详情页
  254 + // contentID: '863556812'
  255 + // } as Params,
  256 + // };
  257 + // WDRouterRule.jumpWithAction(taskAction)
  258 + })
  259 + }
  260 +}
@@ -30,6 +30,14 @@ export struct TopNavigationComponent { @@ -30,6 +30,14 @@ export struct TopNavigationComponent {
30 } as Params, 30 } as Params,
31 }; 31 };
32 WDRouterRule.jumpWithAction(taskAction) 32 WDRouterRule.jumpWithAction(taskAction)
  33 +
  34 + // let taskAction: Action = {
  35 + // type: 'JUMP_INNER_NEW_PAGE',
  36 + // params: {
  37 + // pageID: 'MorningEveningPaper'
  38 + // } as Params,
  39 + // };
  40 + // WDRouterRule.jumpWithAction(taskAction)
33 }) 41 })
34 Tabs() { 42 Tabs() {
35 ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => { 43 ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => {
1 import HashMap from '@ohos.util.HashMap'; 1 import HashMap from '@ohos.util.HashMap';
2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
3 import { DateTimeUtils } from 'wdKit'; 3 import { DateTimeUtils } from 'wdKit';
4 -import { ContentDetailDTO, NavigationBodyDTO, PageDTO,InteractDataDTO } from 'wdBean'; 4 +import { ContentDetailDTO, NavigationBodyDTO, PageDTO,InteractDataDTO, MorningEveningPaperDTO } from 'wdBean';
5 5
6 export class PageRepository { 6 export class PageRepository {
7 static getBottomNavGroupUrl() { 7 static getBottomNavGroupUrl() {
@@ -9,6 +9,19 @@ export class PageRepository { @@ -9,6 +9,19 @@ export class PageRepository {
9 return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH; 9 return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH;
10 } 10 }
11 11
  12 + static getPageInfoUrl(pageId: string) {
  13 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH;
  14 + // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
  15 + url = url + "?channelStrategy=2&loadStrategy=first_load"
  16 + + "&districtCode=" + HttpUrlUtils.getDistrictCode()
  17 + + "&provinceCode=" + HttpUrlUtils.getProvinceCode()
  18 + + "&cityCode=" + HttpUrlUtils.getCityCode()
  19 + + "&refreshTime=" + DateTimeUtils.getTimeStamp()
  20 + + "&pageId=" + pageId
  21 + // Logger.debug("TAG", 'getCompInfoUrl url: '+url);
  22 + return url;
  23 + }
  24 +
12 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { 25 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
13 let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; 26 let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
14 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? 27 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
@@ -36,7 +49,7 @@ export class PageRepository { @@ -36,7 +49,7 @@ export class PageRepository {
36 } 49 }
37 50
38 static getInteractDataUrl() { 51 static getInteractDataUrl() {
39 - let url = HttpUrlUtils.getHost() + this.INTERACT_DATA_PATH; 52 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH;
40 return url; 53 return url;
41 } 54 }
42 55
@@ -46,6 +59,21 @@ export class PageRepository { @@ -46,6 +59,21 @@ export class PageRepository {
46 return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url, headers) 59 return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url, headers)
47 }; 60 };
48 61
  62 + /**
  63 + * 获取早晚报数据
  64 + * @param pageId
  65 + * @param groupId
  66 + * @param channelId
  67 + * @param currentPage
  68 + * @param pageSize
  69 + * @returns
  70 + */
  71 + static fetchMorningEveningPaperData(pageId: string) {
  72 + let url = PageRepository.getPageInfoUrl(pageId)
  73 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  74 + return WDHttp.get<ResponseDTO<MorningEveningPaperDTO>>(url, headers)
  75 + };
  76 +
49 static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { 77 static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
50 let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize) 78 let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize)
51 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 79 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
@@ -59,7 +87,7 @@ export class PageRepository { @@ -59,7 +87,7 @@ export class PageRepository {
59 }; 87 };
60 88
61 static fetchInteractData(param: object) { 89 static fetchInteractData(param: object) {
62 - let url = HttpUrlUtils.getInteractDataUrl() 90 + let url = PageRepository.getInteractDataUrl()
63 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 91 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
64 return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url, param, headers) 92 return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url, param, headers)
65 }; 93 };
1 -import { NavigationBodyDTO, PageDTO,InteractDataDTO,ContentBean, InteractParam,CompDTO } from 'wdBean'; 1 +import { NavigationBodyDTO, PageDTO,InteractDataDTO,ContentBean, InteractParam,CompDTO,
  2 + MorningEveningPaperDTO } from 'wdBean';
2 import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; 3 import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit';
3 import { ResponseDTO, } from 'wdNetwork'; 4 import { ResponseDTO, } from 'wdNetwork';
4 import { PageRepository } from '../repository/PageRepository'; 5 import { PageRepository } from '../repository/PageRepository';
@@ -14,7 +15,7 @@ const mock_switch = false; @@ -14,7 +15,7 @@ const mock_switch = false;
14 * 互动数据获取开关开关,默认开。 15 * 互动数据获取开关开关,默认开。
15 * TODO 后续需要优化掉,变为二次请求异步刷新 16 * TODO 后续需要优化掉,变为二次请求异步刷新
16 */ 17 */
17 -const interact_sync_switch = true; 18 +const interact_sync_switch = false;
18 /** 19 /**
19 * 处理返回后的数据 20 * 处理返回后的数据
20 */ 21 */
@@ -91,11 +92,48 @@ export class PageViewModel extends BaseViewModel { @@ -91,11 +92,48 @@ export class PageViewModel extends BaseViewModel {
91 } 92 }
92 93
93 /** 94 /**
94 - * Get Group data.  
95 - *  
96 - * @return {GroupDTO} compRes.data  
97 - * @deprecated 95 + * 获取【早晚报】数据
98 */ 96 */
  97 + async getMorningEveningPaperData(pageId: string): Promise<MorningEveningPaperDTO> {
  98 + Logger.debug(TAG, 'getPageData pageId: ' + pageId);
  99 + // if (mock_switch) {
  100 + // return this.getPageData3(currentPage, context);
  101 + // }
  102 +
  103 + return new Promise<MorningEveningPaperDTO>((success, error) => {
  104 + PageRepository.fetchMorningEveningPaperData(pageId)
  105 + .then((resDTO: ResponseDTO<MorningEveningPaperDTO>) => {
  106 + if (!resDTO || !resDTO.data) {
  107 + Logger.error(TAG, 'getNavData then resDTO is empty');
  108 + error('resDTO is empty');
  109 + return
  110 + }
  111 + if (resDTO.code != 0) {
  112 + Logger.error(TAG, `getNavData then code:${resDTO.code}, message:${resDTO.message}`);
  113 + error('resDTO Response Code is failure');
  114 + return
  115 + }
  116 + Logger.info(TAG, "getNavData then,resDTO.timestamp:" + resDTO.timestamp);
  117 + if (!interact_sync_switch) {
  118 + success(resDTO.data);
  119 + return;
  120 + }
  121 + // TODO 打开同步请求互动数据,待优化为异步加载
  122 + // if (CollectionUtils.isEmpty(resDTO.data.compList)) {
  123 + // success(resDTO.data);
  124 + // } else {
  125 + // this.getInteractData(resDTO.data.compList).then(() => {
  126 + // success(resDTO.data);
  127 + // })
  128 + // }
  129 + })
  130 + .catch((err: Error) => {
  131 + Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`);
  132 + error(err);
  133 + })
  134 + })
  135 + }
  136 +
99 private async getPageData2(context: Context): Promise<PageDTO> { 137 private async getPageData2(context: Context): Promise<PageDTO> {
100 let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context, 'comp_list2.json'); 138 let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context, 'comp_list2.json');
101 if (!compRes || !compRes.data) { 139 if (!compRes || !compRes.data) {
@@ -132,13 +170,13 @@ export class PageViewModel extends BaseViewModel { @@ -132,13 +170,13 @@ export class PageViewModel extends BaseViewModel {
132 return; 170 return;
133 } 171 }
134 // TODO 打开同步请求互动数据,待优化为异步加载 172 // TODO 打开同步请求互动数据,待优化为异步加载
135 - if (CollectionUtils.isEmpty(resDTO.data.compList)) {  
136 - success(resDTO.data);  
137 - } else {  
138 - this.getInteractData(resDTO.data.compList).then(() => {  
139 - success(resDTO.data);  
140 - })  
141 - } 173 + // if (CollectionUtils.isEmpty(resDTO.data.compList)) {
  174 + // success(resDTO.data);
  175 + // } else {
  176 + // this.getInteractData(resDTO.data.compList).then(() => {
  177 + // success(resDTO.data);
  178 + // })
  179 + // }
142 }) 180 })
143 .catch((err: Error) => { 181 .catch((err: Error) => {
144 Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`); 182 Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`);
@@ -147,121 +185,120 @@ export class PageViewModel extends BaseViewModel { @@ -147,121 +185,120 @@ export class PageViewModel extends BaseViewModel {
147 }) 185 })
148 } 186 }
149 187
150 - async getInteractData(compList: CompDTO[]) {  
151 - let param: InteractParam = this.getInteractParams(compList);  
152 - const SIZE = 20;  
153 - // 批查接口,参数size限制20,这里截断分批查询,0,20;20,40...  
154 - let count = Math.ceil(param.contentList.length / SIZE);  
155 - let promises = new Array;  
156 - if (count == 1) {  
157 - let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(param);  
158 - promises.push(promise);  
159 - } else {  
160 - for (let i = 1;i <= count; i++) {  
161 - // 将查询参数截断(参数限制20个),分批请求接口  
162 - let subList = new Array<ContentBean>();  
163 - let start = 0;  
164 - let end = 0;  
165 - if (i == count) {  
166 - start = (i - 1) * SIZE;  
167 - end = param.contentList.length;  
168 - subList = CollectionUtils.getSubElements(param.contentList, start, end)  
169 - } else {  
170 - start = (i - 1) * SIZE;  
171 - end = start + SIZE;  
172 - subList = CollectionUtils.getSubElements(param.contentList, start, end)  
173 - }  
174 - let subParam: InteractParam = {} as InteractParam;  
175 - subParam.contentList = subList;  
176 - let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(subParam);  
177 - promises.push(promise);  
178 - }  
179 - }  
180 -  
181 - return new Promise<CompDTO[]>((success, error) => {  
182 - Promise.all(promises).then((result) => {  
183 - if (!CollectionUtils.isArray(result)) {  
184 - success(compList);  
185 - return;  
186 - }  
187 -  
188 - let allInteractDataList = new Array();  
189 - result.forEach((value: InteractDataDTO[]) => {  
190 - if (value != null && value.length > 0) {  
191 - allInteractDataList.push(...value);  
192 - }  
193 - })  
194 - // 批查全部完成,统一设置到comp里  
195 - this.resetInteract(allInteractDataList, compList);  
196 - success(compList);  
197 - })  
198 - })  
199 - }  
200 -  
201 - private createInteractDataPromise(param: InteractParam) {  
202 - return new Promise<InteractDataDTO[]>((success, error) => {  
203 - PageRepository.fetchInteractData(param).then((resDTO: ResponseDTO<InteractDataDTO[]>) => {  
204 - if (this.isRespondsInvalid(resDTO, 'getInteractData')) {  
205 - Logger.info(TAG, "getInteractData then,resDTO.timeStamp:" + resDTO.timestamp);  
206 - success(null);  
207 - return;  
208 - }  
209 - success(resDTO.data);  
210 - }).catch((err: Error) => {  
211 - Logger.error(TAG, `getInteractData catch, error.name : ${err.name}, error.message:${err.message}`);  
212 - // 无论是否成功(暂不做重试),都回调结果,通知刷新数据  
213 - success(null);  
214 - })  
215 - });  
216 - }  
217 -  
218 - private resetInteract(interact: InteractDataDTO[], compList: CompDTO[]) {  
219 - if (interact == null || interact.length == 0) {  
220 - return  
221 - }  
222 - interact.forEach((interactData) => {  
223 - let id = interactData.contentId;  
224 - outer: for (let i = 0;i < compList.length; i++) {  
225 - let comp = compList[i];  
226 - if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) {  
227 - continue;  
228 - }  
229 - for (let j = 0;j < comp.operDataList.length; j++) {  
230 - let content = comp.operDataList[j];  
231 - if (content == null) {  
232 - continue;  
233 - }  
234 - if (id == content.objectId) {  
235 - content.interactData = interactData;  
236 - break outer;  
237 - }  
238 - }  
239 - }  
240 - })  
241 - }  
242 -  
243 - private getInteractParams(compList: CompDTO[]): InteractParam {  
244 - if (compList == null || compList.length == 0) {  
245 - return null;  
246 - }  
247 -  
248 - let param: InteractParam = {} as InteractParam;  
249 - param.contentList = new Array<ContentBean>();  
250 - compList.forEach((value) => {  
251 - let contentList = value.operDataList;  
252 - if (contentList != null && contentList.length > 0) {  
253 - contentList.forEach((v) => {  
254 - if (StringUtils.isNotEmpty(v.objectId)) {  
255 - let bean = {} as ContentBean;  
256 - bean.contentId = v.objectId;  
257 - bean.contentType = v.objectType;  
258 - param.contentList.push(bean);  
259 - }  
260 - })  
261 - }  
262 - })  
263 - return param;  
264 - } 188 + // async getInteractData(compList: CompDTO[]) {
  189 + // let param: InteractParam = this.getInteractParams(compList);
  190 + // const SIZE = 20;
  191 + // // 批查接口,参数size限制20,这里截断分批查询,0,20;20,40...
  192 + // let count = Math.ceil(param.contentList.length / SIZE);
  193 + // if (count == 1) {
  194 + // let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(param);
  195 + // promises.push(promise);
  196 + // } else {
  197 + // for (let i = 1;i <= count; i++) {
  198 + // // 将查询参数截断(参数限制20个),分批请求接口
  199 + // let subList = new Array<ContentBean>();
  200 + // let start = 0;
  201 + // let end = 0;
  202 + // if (i == count) {
  203 + // start = (i - 1) * SIZE;
  204 + // end = param.contentList.length;
  205 + // subList = CollectionUtils.getSubElements(param.contentList, start, end)
  206 + // } else {
  207 + // start = (i - 1) * SIZE;
  208 + // end = start + SIZE;
  209 + // subList = CollectionUtils.getSubElements(param.contentList, start, end)
  210 + // }
  211 + // let subParam: InteractParam = {} as InteractParam;
  212 + // subParam.contentList = subList;
  213 + // let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(subParam);
  214 + // promises.push(promise);
  215 + // }
  216 + // }
  217 + //
  218 + // return new Promise<CompDTO[]>((success, error) => {
  219 + // Promise.all(promises).then((result) => {
  220 + // if (!CollectionUtils.isArray(result)) {
  221 + // success(compList);
  222 + // return;
  223 + // }
  224 + //
  225 + // let allInteractDataList = new Array();
  226 + // result.forEach((value: InteractDataDTO[]) => {
  227 + // if (value != null && value.length > 0) {
  228 + // allInteractDataList.push(...value);
  229 + // }
  230 + // })
  231 + // // 批查全部完成,统一设置到comp里
  232 + // this.resetInteract(allInteractDataList, compList);
  233 + // success(compList);
  234 + // })
  235 + // })
  236 + // }
  237 + //
  238 + // private createInteractDataPromise(param: InteractParam) {
  239 + // return new Promise<InteractDataDTO[]>((success, error) => {
  240 + // PageRepository.fetchInteractData(param).then((resDTO: ResponseDTO<InteractDataDTO[]>) => {
  241 + // if (this.isRespondsInvalid(resDTO, 'getInteractData')) {
  242 + // Logger.info(TAG, "getInteractData then,resDTO.timeStamp:" + resDTO.timestamp);
  243 + // success(null);
  244 + // return;
  245 + // }
  246 + // success(resDTO.data);
  247 + // }).catch((err: Error) => {
  248 + // Logger.error(TAG, `getInteractData catch, error.name : ${err.name}, error.message:${err.message}`);
  249 + // // 无论是否成功(暂不做重试),都回调结果,通知刷新数据
  250 + // success(null);
  251 + // })
  252 + // });
  253 + // }
  254 + //
  255 + // private resetInteract(interact: InteractDataDTO[], compList: CompDTO[]) {
  256 + // if (interact == null || interact.length == 0) {
  257 + // return
  258 + // }
  259 + // interact.forEach((interactData) => {
  260 + // let id = interactData.contentId;
  261 + // outer: for (let i = 0;i < compList.length; i++) {
  262 + // let comp = compList[i];
  263 + // if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) {
  264 + // continue;
  265 + // }
  266 + // for (let j = 0;j < comp.operDataList.length; j++) {
  267 + // let content = comp.operDataList[j];
  268 + // if (content == null) {
  269 + // continue;
  270 + // }
  271 + // if (id == content.objectId) {
  272 + // content.interactData = interactData;
  273 + // break outer;
  274 + // }
  275 + // }
  276 + // }
  277 + // })
  278 + // }
  279 + //
  280 + // private getInteractParams(compList: CompDTO[]): InteractParam {
  281 + // if (compList == null || compList.length == 0) {
  282 + // return null;
  283 + // }
  284 + //
  285 + // let param: InteractParam = {} as InteractParam;
  286 + // param.contentList = new Array<ContentBean>();
  287 + // compList.forEach((value) => {
  288 + // let contentList = value.operDataList;
  289 + // if (contentList != null && contentList.length > 0) {
  290 + // contentList.forEach((v) => {
  291 + // if (StringUtils.isNotEmpty(v.objectId)) {
  292 + // let bean = {} as ContentBean;
  293 + // bean.contentId = v.objectId;
  294 + // bean.contentType = v.objectType;
  295 + // param.contentList.push(bean);
  296 + // }
  297 + // })
  298 + // }
  299 + // })
  300 + // return param;
  301 + // }
265 } 302 }
266 303
267 304
  1 +{
  2 + "src": [
  3 + "components/MorningEveningPaperComponent"
  4 + ]
  5 +}
  6 +
@@ -63,7 +63,7 @@ export class HttpRequest { @@ -63,7 +63,7 @@ export class HttpRequest {
63 return service.post(url, data, config) 63 return service.post(url, data, config)
64 } 64 }
65 65
66 - static post<T = any>(url: string, data1?: any, headers?: HashMap<string, string>): Promise<T> { 66 + static post<T = object>(url: string, data1?: object, headers?: HashMap<string, string>): Promise<T> {
67 let requestHeaders: AxiosHeaders = new AxiosHeaders() 67 let requestHeaders: AxiosHeaders = new AxiosHeaders()
68 headers?.forEach((v, k) => { 68 headers?.forEach((v, k) => {
69 requestHeaders.set(k, v); 69 requestHeaders.set(k, v);
@@ -26,6 +26,11 @@ export class HttpUrlUtils { @@ -26,6 +26,11 @@ export class HttpUrlUtils {
26 * 启动接口(底导接口) 26 * 启动接口(底导接口)
27 */ 27 */
28 static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup"; 28 static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup";
  29 +
  30 + /**
  31 + * 展现pageInfo接口
  32 + */
  33 + static readonly PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo";
29 /** 34 /**
30 * 展现comp接口 35 * 展现comp接口
31 */ 36 */
@@ -58,7 +63,7 @@ export class HttpUrlUtils { @@ -58,7 +63,7 @@ export class HttpUrlUtils {
58 //headers.set('X-Ca-Stage', 'PRE') 63 //headers.set('X-Ca-Stage', 'PRE')
59 headers.set('versionCode', HttpUrlUtils.getVersionCode()) 64 headers.set('versionCode', HttpUrlUtils.getVersionCode())
60 headers.set('system', HttpUrlUtils.getTerminalId()) 65 headers.set('system', HttpUrlUtils.getTerminalId())
61 - headers.set('version_name', this.getVersionName()) 66 + headers.set('version_name', HttpUrlUtils.getVersionName())
62 headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A') 67 headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A')
63 headers.set('imei', HttpUrlUtils.getImei()) 68 headers.set('imei', HttpUrlUtils.getImei())
64 headers.set('Accept-Language', 'zh') 69 headers.set('Accept-Language', 'zh')
@@ -65,6 +65,8 @@ export function registerRouter() { @@ -65,6 +65,8 @@ export function registerRouter() {
65 Action2Page.register("JUMP_INNER_NEW_PAGE", (action) => { 65 Action2Page.register("JUMP_INNER_NEW_PAGE", (action) => {
66 if (action.params?.pageID == "E_NEWSPAPER") { 66 if (action.params?.pageID == "E_NEWSPAPER") {
67 return WDRouterPage.eNewspaper 67 return WDRouterPage.eNewspaper
  68 + } else if (action.params?.pageID == "MorningEveningPaper"){
  69 + return WDRouterPage.morningEveningPaperPage
68 } else if (action.params?.pageID == "IMAGE_TEXT_DETAIL"){ 70 } else if (action.params?.pageID == "IMAGE_TEXT_DETAIL"){
69 return WDRouterPage.imageTextDetailPage 71 return WDRouterPage.imageTextDetailPage
70 } 72 }
@@ -22,6 +22,8 @@ export class WDRouterPage { @@ -22,6 +22,8 @@ export class WDRouterPage {
22 static defaultWebPage = new WDRouterPage("entry", "ets/pages/web/DefaultWebPage"); 22 static defaultWebPage = new WDRouterPage("entry", "ets/pages/web/DefaultWebPage");
23 // 电子报页面 23 // 电子报页面
24 static eNewspaper = new WDRouterPage("entry", "ets/pages/ENewspaper") 24 static eNewspaper = new WDRouterPage("entry", "ets/pages/ENewspaper")
  25 + // 早晚报页面
  26 + static morningEveningPaperPage = new WDRouterPage("entry", "ets/pages/MorningEveningPaperPage")
25 // 图文详情页 27 // 图文详情页
26 static imageTextDetailPage = new WDRouterPage("entry", "ets/pages/ImageAndTextDetailPage"); 28 static imageTextDetailPage = new WDRouterPage("entry", "ets/pages/ImageAndTextDetailPage");
27 // 短视频详情页 29 // 短视频详情页