chenjun3_wd

早晚报非头版样式现网数据填充

// import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean';
import { PageInfoBean } from 'wdBean';
import { CompList, PageInfoBean } from 'wdBean';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel';
import { AudioBarView } from './AudioBarView';
... ... @@ -15,6 +15,9 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年\nMM月dd日'; // 日期中包含包
@Component
export struct MorningEveningPaperComponent {
@State pageInfoBean: PageInfoBean = {} as PageInfoBean
// @State compInfoBean: CompInfoBean = {} as CompInfoBean
@State compListItem: CompList = {} as CompList
// @Provide compListItem: CompList = {} as CompList
// @State morningEveningPaperDTO: MorningEveningPaperDTO = {
// name: "新闻夜读",
// topicInfo: {
... ... @@ -41,7 +44,7 @@ export struct MorningEveningPaperComponent {
Logger.info(TAG, "currentTime = " + currentTime)
Logger.info(TAG, `currentTime = ${currentTime}`)
try {
let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("28927")
let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("28949")
this.pageInfoBean = pageInfoBean;
this.title = this.pageInfoBean?.topicInfo?.title
let dateTime = DateTimeUtils.parseDate(this.pageInfoBean?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN);
... ... @@ -52,7 +55,12 @@ export struct MorningEveningPaperComponent {
Logger.info(TAG, "pageInfoBean dateTime = " + dateTime)
Logger.info(TAG, "pageInfoBean subTitle = " + this.subTitle)
let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "")
let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "", pageInfoBean?.topicInfo?.topicId)
// this.compInfoBean = compInfoBean
if (compInfoBean?.compList[0]) {
this.compListItem = compInfoBean?.compList[0]
}
Logger.info(TAG, "compInfoBean compStyle = " + compInfoBean.compList[0].compStyle)
} catch (exception) {
... ... @@ -67,14 +75,14 @@ export struct MorningEveningPaperComponent {
ListItem() {
topicInfoView({ frontLinkObject: this.pageInfoBean?.topicInfo?.frontLinkObject })
}
}
ListItem() {
AudioBarView()
ListItem() {
AudioBarView()
}
}
ListItem() {
SingleColumn999Component()
SingleColumn999Component({ compListItem: this.compListItem }).margin({ top: $r('app.float.top_bar_height') })
}
}
// .backgroundColor('#FFF1F3F5')
... ... @@ -82,13 +90,12 @@ export struct MorningEveningPaperComponent {
.height('100%')
.margin({ left: 14, right: 14 })
PaperTitleComponent()
// PaperTitleComponent({
// // title: this.morningEveningPaperDTO?.topicInfo?.title ?? "",
// title: this.title ?? "",
// // subtitle: this.morningEveningPaperDTO?.topicInfo?.topicDate ?? ''
// subtitle: this.subTitle
// })
PaperTitleComponent()// PaperTitleComponent({
// // title: this.morningEveningPaperDTO?.topicInfo?.title ?? "",
// title: this.title ?? "",
// // subtitle: this.morningEveningPaperDTO?.topicInfo?.topicDate ?? ''
// subtitle: this.subTitle
// })
.margin({ left: 14, right: 14 })
}
.width('100%')
... ...
import { CompDTO, ContentDTO, VideoInfoDTO, } from 'wdBean';
import { CompList, ContentDTO } from 'wdBean';
import { BreakpointConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { PaperSingleColumn999CardView } from '../page/CardView';
... ... @@ -11,67 +11,71 @@ const TAG = 'SingleColumn999Component';
*/
@Component
export struct SingleColumn999Component {
// @Consume compListItem?: CompList
@Prop compListItem?: CompList
@StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
@State compDTO: CompDTO = {
compStyle: 'compStyle3',
operDataList: [
{
newsTitle: '时政微观察丨从外贸“成绩单”看中国经济新亮色',
description: "description0",
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/a9028e7011bb440e94ba7c63d80b39b7.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
} as ContentDTO,
{
newsTitle: '画好强国建设、民族复兴的最大同心圆',
description: "description1",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/80351784d4da4fc08b8987ba45a7647f.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
newsTitle: '绿色“一带一路”十周年创新理念与实践案例',
description: "description2",
newsSummary: "共建“一带一路”倡议提出10年多来,在各方共同努力下,共建“一带一路”绿色发展取得积极进展,理念引领不断增强,交流机制不断完善,务实合作不断深化。",
coverUrl: "",
} as ContentDTO,
{
newsTitle: '瞭望 | 在深海聆听“幽灵粒子”',
description: "description3",
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/b77a3577594d4d24b84e7b2b20e38e41.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
} as ContentDTO,
{
newsTitle: '一图读懂|未来三年,长三角示范区安排了这些重大项目',
description: "description4",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/8d54ef1cbbe14ef08d6ab38f07867e4c.jpeg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
newsTitle: '一头江豚的自述',
description: "description5",
newsSummary: "我是生活在长江里的一头江豚,是长江中唯一的水生哺乳动物,更是国家一级保护动物。但曾几何时,我和我的江中小伙伴出现了生存危机……直到有一天,我突然发现,打渔人变成护渔人,江水变清澈了,长江逐渐恢复了生机,我的家族数量上升到了1249头。当长江之水再一次悠悠流淌,我们相拥在清澈波光中起舞。长江,我的家园。",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/2ec7bccff2324b05ac4b6503d868a381.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
visitorComment: 10,
videoInfo: {
// clarity: 0,
// resolutionHeight: 0,
// resolutionWidth: 0,
videoDuration: 229,
videoLandScape: 1,
// videoType: 0,
videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4",
firstFrameImageUri: ""
} as VideoInfoDTO
} as ContentDTO,
{
newsTitle: '遇见习近平丨北京正在书写历史',
description: "description6",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/7c54d59b63844464a261dcbba82c7aed.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO
]
} as CompDTO
// @State compDTO: CompDTO = {
// compStyle: 'compStyle3',
// operDataList: [
// {
// newsTitle: '时政微观察丨从外贸“成绩单”看中国经济新亮色',
// description: "description0",
// coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/a9028e7011bb440e94ba7c63d80b39b7.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
// } as ContentDTO,
// {
// newsTitle: '画好强国建设、民族复兴的最大同心圆',
// description: "description1",
// coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/80351784d4da4fc08b8987ba45a7647f.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
// } as ContentDTO,
// {
// newsTitle: '绿色“一带一路”十周年创新理念与实践案例',
// description: "description2",
// newsSummary: "共建“一带一路”倡议提出10年多来,在各方共同努力下,共建“一带一路”绿色发展取得积极进展,理念引领不断增强,交流机制不断完善,务实合作不断深化。",
// coverUrl: "",
// } as ContentDTO,
// {
// newsTitle: '瞭望 | 在深海聆听“幽灵粒子”',
// description: "description3",
// coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/b77a3577594d4d24b84e7b2b20e38e41.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
// } as ContentDTO,
// {
// newsTitle: '一图读懂|未来三年,长三角示范区安排了这些重大项目',
// description: "description4",
// coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/8d54ef1cbbe14ef08d6ab38f07867e4c.jpeg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
// } as ContentDTO,
// {
// newsTitle: '一头江豚的自述',
// description: "description5",
// newsSummary: "我是生活在长江里的一头江豚,是长江中唯一的水生哺乳动物,更是国家一级保护动物。但曾几何时,我和我的江中小伙伴出现了生存危机……直到有一天,我突然发现,打渔人变成护渔人,江水变清澈了,长江逐渐恢复了生机,我的家族数量上升到了1249头。当长江之水再一次悠悠流淌,我们相拥在清澈波光中起舞。长江,我的家园。",
// coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/2ec7bccff2324b05ac4b6503d868a381.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
// visitorComment: 10,
// videoInfo: {
// // clarity: 0,
// // resolutionHeight: 0,
// // resolutionWidth: 0,
// videoDuration: 229,
// videoLandScape: 1,
// // videoType: 0,
// videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4",
// firstFrameImageUri: ""
// } as VideoInfoDTO
// } as ContentDTO,
// {
// newsTitle: '遇见习近平丨北京正在书写历史',
// description: "description6",
// coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/7c54d59b63844464a261dcbba82c7aed.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
// } as ContentDTO
// ]
// } as CompDTO
watchCurrentBreakpoint() {
Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`);
}
aboutToAppear() {
Logger.info(TAG, `aboutToAppear, beanList:${this.compDTO?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`);
// Logger.info(TAG, `aboutToAppear, beanList:${this.compDTO?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`);
Logger.info(TAG, `aboutToAppear, beanList:${this.compListItem?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`);
}
aboutToDisappear() {
... ... @@ -106,16 +110,18 @@ export struct SingleColumn999Component {
}
build() {
if (this.compDTO && this.compDTO?.operDataList?.length > 0) {
// if (this.compDTO && this.compDTO?.operDataList?.length > 0) {
if (this.compListItem && this.compListItem?.operDataList?.length > 0) {
List({ space: 2, initialIndex: 0 }) {
// ListItemGroup({
// // footer: this.itemFooter("")
// }) {
ForEach(this.compDTO?.operDataList, (item: ContentDTO, index: number) => {
ListItem() {
this.buildPaperItem(item, index)
}
}, (item: ContentDTO, index: number) => JSON.stringify(item))
// ForEach(this.compDTO?.operDataList, (item: ContentDTO, index: number) => {
ForEach(this.compListItem?.operDataList, (item: ContentDTO, index: number) => {
ListItem() {
this.buildPaperItem(item, index)
}
}, (item: ContentDTO, index: number) => JSON.stringify(item))
// }
// .divider({ strokeWidth: 1, color: '#EFEFEF' }) // 每行之间的分界线
... ...
... ... @@ -14,6 +14,7 @@ import {
} from 'wdBean';
const TAG = 'HttpRequest';
export class PageRepository {
static getBottomNavGroupUrl() {
// https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
... ... @@ -30,7 +31,7 @@ export class PageRepository {
+ "&refreshTime=" + DateTimeUtils.getTimeStamp()
+ "&pageId=" + pageId
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getPageInfoUrl url = "+url)
Logger.info(TAG, "getPageInfoUrl url = " + url)
return url;
}
... ... @@ -48,29 +49,29 @@ export class PageRepository {
+ "&pageSize=" + pageSize
+ "&pageNum=" + currentPage;
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getCompInfoUrl url = "+url)
Logger.info(TAG, "getCompInfoUrl url = " + url)
return url;
}
static getDetailInfoUrl(relId: string, contentId: string, relType: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH;
url = url + "?relId=" + relId
+ "&contentId=" + contentId
+ "&relType=" + relType;
+ "&contentId=" + contentId
+ "&relType=" + relType;
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG,"getDetailInfoUrl url = "+url)
Logger.info(TAG, "getDetailInfoUrl url = " + url)
return url;
}
static getInteractDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH;
Logger.info(TAG,"getInteractDataUrl url = "+url)
Logger.info(TAG, "getInteractDataUrl url = " + url)
return url;
}
static getNewspaperInfoUrl(date: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH + "?date=" + date;
Logger.info(TAG,"getNewspaperInfoUrl url = "+url)
Logger.info(TAG, "getNewspaperInfoUrl url = " + url)
return url;
}
... ... @@ -78,7 +79,7 @@ export class PageRepository {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_LIST_PATH;
url = url + "?date=" + date
+ "&pagesSize=" + pageSize;
Logger.info(TAG,"getNewspaperListUrl url = "+url)
Logger.info(TAG, "getNewspaperListUrl url = " + url)
return url;
}
... ... @@ -88,7 +89,7 @@ export class PageRepository {
static getMorningEveningPageInfoUrl(pageId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_PAGE_INFO_PATH;
url = url + "?pageId=" + pageId;
Logger.info(TAG,"getMorningEveningPageInfoUrl url = "+url)
Logger.info(TAG, "getMorningEveningPageInfoUrl url = " + url)
return url;
}
... ... @@ -105,11 +106,11 @@ export class PageRepository {
* channelStrategy:频道策略
* topicId:专题id
* */
static getMorningEveningCompInfoUrl(pageId: number,groupId:number,refreshTime:string,pageNum:number,pageSize:number) {
static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_COMP_INFO_PATH;
url = url + "?loadStrategy=first_load&pageNum="+pageNum+"&refreshTime="+refreshTime+"&pageId="
+pageId+"&channelStrategy=2&groupId="+groupId+"&topicId=10000009445&pageSize="+pageSize;
Logger.info(TAG,"getMorningEveningCompInfoUrl url = "+url)
url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId="
+ pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize;
Logger.info(TAG, "getMorningEveningCompInfoUrl url = " + url)
return url;
}
... ... @@ -176,8 +177,8 @@ export class PageRepository {
/**
* 获取早晚报compInfo
* */
static fetchMorningEveningCompInfo(pageId: number,groupId:number,refreshTime:string,pageNum:number,pageSize:number) {
let url = PageRepository.getMorningEveningCompInfoUrl(pageId,groupId,refreshTime,pageNum,pageSize)
static fetchMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) {
let url = PageRepository.getMorningEveningCompInfoUrl(pageId, groupId, refreshTime, topicId, pageNum, pageSize)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<CompInfoBean>>(url, headers)
};
... ...
... ... @@ -6,7 +6,6 @@ import { PageRepository } from '../repository/PageRepository';
const TAG = 'MorningEveningViewModel'
export class MorningEveningViewModel {
static async getMorningEveningPageInfo(pageId: string): Promise<PageInfoBean> {
return new Promise<PageInfoBean>((success, error) => {
Logger.info(TAG, `getMorningEveningPageInfo pageInfo start`);
... ... @@ -31,27 +30,29 @@ export class MorningEveningViewModel {
})
}
static async getMorningEveningCompInfo(pageId: number,groupId:number,refreshTime:string,pageNum:number = 1,pageSize:number = 20): Promise<CompInfoBean> {
static async getMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number = 1, pageSize: number = 20): Promise<CompInfoBean> {
return new Promise<CompInfoBean>((success, error) => {
Logger.info(TAG, `getMorningEveningCompInfo pageInfo start`);
PageRepository.fetchMorningEveningCompInfo(pageId,groupId,refreshTime,pageNum,pageSize).then((resDTO: ResponseDTO<CompInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
PageRepository.fetchMorningEveningCompInfo(pageId, groupId, refreshTime, topicId, pageNum, pageSize)
.then((resDTO: ResponseDTO<CompInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
\ No newline at end of file
... ...