wanglei

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

Showing 23 changed files with 539 additions and 25 deletions
... ... @@ -10,12 +10,13 @@ export { ItemDTO } from './src/main/ets/bean/ItemDTO';
export { ItemBean } from './src/main/ets/bean/ItemBean';
// component
export { Action } from './src/main/ets/bean/programme/Action'
// Content
export { ContentDTO } from './src/main/ets/bean/content/ContentDTO';
export { Action } from './src/main/ets/bean/content/Action'
export { Params } from './src/main/ets/bean/programme/Params'
export { Params } from './src/main/ets/bean/content/Params'
export { Pic } from './src/main/ets/bean/programme/Pic'
export { Pic } from './src/main/ets/bean/content/Pic'
export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean';
... ... @@ -27,7 +28,6 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO';
export { CompDTO } from './src/main/ets/bean/component/CompDTO';
export { ContentDTO } from './src/main/ets/bean/component/ContentDTO';
export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean';
... ...
import { ItemDTO } from './ItemDTO';
import { Action } from './programme/Action';
import { Pic } from './programme/Pic';
import { Action } from './content/Action';
import { Pic } from './content/Pic';
/**
* 绑定到组件comp/view的数据Bean
... ...
import { Action } from './programme/Action';
import { Pic } from './programme/Pic';
import { Action } from './content/Action';
import { Pic } from './content/Pic';
/**
* 组件comp/view对应的服务端数据
... ...
import { ContentDTO } from './ContentDTO';
import { ContentDTO } from '../content/ContentDTO';
export interface CompDTO {
backgroundColor: string;
... ... @@ -26,4 +26,5 @@ export interface CompDTO {
provinceCode: string;
sortValue: number;
subType: string;
imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2
}
\ No newline at end of file
... ...
import { FullColumnImgUrlDTO } from '../detail/FullColumnImgUrlDTO';
import { LiveInfoDTO } from '../detail/LiveInfoDTO';
import { VideoInfoDTO } from '../detail/VideoInfoDTO';
export interface ContentDTO {
cityCode: string;
coverSize: string;
... ... @@ -45,4 +49,7 @@ export interface ContentDTO {
newsTitle:string;
publishTime:string;
visitorComment:number;
fullColumnImgUrls:FullColumnImgUrlDTO[];
liveInfo?: LiveInfoDTO; // 直播新闻信息【BFF聚合】
videoInfo?: VideoInfoDTO; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的
}
\ No newline at end of file
... ...
export interface LiveInfoDTO {
liveState: string; // 直播新闻-直播状态
liveUrl: string; //【暂时未使用,默认取第一个】直播新闻-直播地址
liveStartTime: string;
liveLandscape: string;
vrType: number; // 【迭代三】是否Vr,0:否,1:是
replayUri: string; // 直播回放地址【判断是否有回放;BFF: 允许展示回放+存在回放地址;默认取第一条】
}
\ No newline at end of file
... ...
... ... @@ -2,8 +2,9 @@ export interface VideoInfoDTO {
clarity: number;
resolutionHeight: number;
resolutionWidth: number;
videoDuration: number;
videoLandScape: number;
videoDuration: string; // 视频时长
videoLandScape: number; // 1横屏 2竖屏
videoType: number;
videoUrl: string;
videoUrl: string; //视频播放地址
firstFrameImageUri: string; // 首帧图;【视频内容,contentPictures中】
}
\ No newline at end of file
... ...
... ... @@ -41,3 +41,9 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText
export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel"
export { SingleImageCardComponent } from "./src/main/ets/components/view/SingleImageCardComponent"
export { TriPicCardComponent } from "./src/main/ets/components/view/TriPicCardComponent"
export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardComponent"
export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent"
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants, CompStyle } from 'wdConstant';
import { BannerComponent } from './view/BannerComponent';
import { LabelComponent } from './view/LabelComponent';
import { TitleAbbrComponent } from './view/TitleAbbrComponent';
import { TitleAllComponent } from './view/TitleAllComponent';
import { HorizontalStrokeCardThreeTwoRadioForOneComponent } from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent';
import { HorizontalStrokeCardThreeTwoRadioForTwoComponent } from './view/HorizontalStrokeCardThreeTwoRadioForTwoComponent';
import { HorizontalStrokeCardThreeTwoRadioForMoreComponent } from './view/HorizontalStrokeCardThreeTwoRadioForMoreComponent';
import { CompDTO } from 'wdBean';
import { SingleImageCardComponent } from './view/SingleImageCardComponent';
import { BigPicCardComponent } from './view/BigPicCardComponent';
import { TriPicCardComponent } from './view/TriPicCardComponent';
import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
import { HeadPictureCardComponent } from './view/HeadPictureCardComponent';
/**
* comp适配器.
... ... @@ -33,6 +34,14 @@ export struct CompParser {
BannerComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Single_Imagecard_02 || compDTO.compStyle === CompStyle.Single_Imagecard_03) {
SingleImageCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "2") {
BigPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "4") {
TriPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) {
LiveHorizontalCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
HeadPictureCardComponent({ compDTO: compDTO })
} else {
// todo:组件未实现 / Component Not Implemented
Text(compDTO.compStyle)
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant'
const TAG: string = 'BigPicCardComponent';
/**
* 大图卡:
* compstyle:2
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
*/
// @Entry
@Component
export struct BigPicCardComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column() {
Column() {
//新闻标题
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize(17)
.fontColor('#222222')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
//大图
Stack() {
Image(this.compDTO.operDataList[0].coverUrl)
.borderRadius(4)
//播放状态+时长
Row() {
Image($r('app.media.icon_live'))
.width(22)
.height(18)
Stack() {
Text('直播中')
.fontColor('#FFFFFF')
.fontSize(11)
}
.width(44)
.height(18)
.backgroundColor('#4d000000')
}.margin({ right: 8, bottom: 8 })
}
.width('100%')
.height(192)
.alignContent(Alignment.BottomEnd)
.margin({ top: 8 })
}
.width('100%')
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Start)
.padding({ top: 14 })
//bottom
Row() {
Text(this.compDTO.operDataList[0].source)
.bottomTextStyle()
//间隔点
Image($r('app.media.point'))
.width(12)
.height(12)
Text(this.compDTO.operDataList[0].source)
.bottomTextStyle()
Text(' ')
Text(this.compDTO.operDataList[0].subtitle)
.bottomTextStyle()
}
.width('100%')
.height(18)
.justifyContent(FlexAlign.Start)
// .padding({bottom:14})
.margin({ top: 8 })
}
.width('100%')
.padding({ left: 16, right: 16 })
}
}
/**
* 大图卡 中部
* 包括:视频图、视频时长
*/
@Component
export struct myBigCard_body {
private newsSrc: string = "https://k.sinaimg.cn/n/default/crawl/190/w550h440/20240118/6772-7c2385bb2741c6f88906af3514d27343.png/w700d1q75cms.jpg";
private newsTitle: string = "时政微观察丨新征程金融工作怎么干?“新年第一课”这样讲";
build() {
Column() {
//新闻标题
Text(this.newsTitle)
.fontSize(17)
.fontColor('#222222')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
//大图
Stack() {
Image(this.newsSrc)
.borderRadius(4)
//播放状态+时长
Row() {
Image($r('app.media.icon_live'))
.width(22)
.height(18)
Stack() {
Text('直播中')
.fontColor('#FFFFFF')
.fontSize(11)
}
.width(44)
.height(18)
.backgroundColor('#4d000000')
}.margin({ right: 8, bottom: 8 })
}
.width('100%')
.height(192)
.alignContent(Alignment.BottomEnd)
.margin({ top: 8 })
}
.width('100%')
.justifyContent(FlexAlign.Start)
}
}
/**
* 大图卡 底部
* 包括:分享、评论、点赞 三个按钮
*/
@Component
export struct myBigCard_bottom {
private bottom_height: number = 18
private itemSubtitle1: string = "人民日报"
private itemSubtitle2: string = "25分钟前"
private itemSubtitle3: string = "786条评论"
build() {
//子标题
Row() {
Text(this.itemSubtitle1)
.bottomTextStyle()
//间隔点
Image($r('app.media.point'))
.width(12)
.height(12)
Text(this.itemSubtitle2)
.bottomTextStyle()
Text(' ')
Text(this.itemSubtitle3)
.bottomTextStyle()
}
.width('100%')
.height(this.bottom_height)
.justifyContent(FlexAlign.Start)
}
}
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
}
\ No newline at end of file
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { CompUtils } from '../utils/CompUtils';
import { CompUtils } from '../../utils/CompUtils';
@Component
export struct HeadPictureCardComponent {
... ... @@ -11,11 +11,13 @@ export struct HeadPictureCardComponent {
Image(this.compDTO.backgroundImgUrl)
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
if (this.compDTO.extraData) {
Row()
.width(CommonConstants.FULL_WIDTH)
.height(59)
.linearGradient({
colors:[
colors: [
['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0]
]
})
... ... @@ -26,10 +28,14 @@ export struct HeadPictureCardComponent {
.fontColor(Color.White)
.fontSize($r('app.float.normal_text_size'))
.fontWeight(FontWeight.Bold)
.maxLines(2)
}
.height(25)
.margin({left: 12, bottom: 10, right: 12})
.margin({ left: 12, bottom: 10, right: 12 })
}
}
.alignContent(Alignment.Bottom)
.width(CommonConstants.FULL_WIDTH)
.height(200)
}
}
... ...
import { CommonConstants } from 'wdConstant'
import { CompDTO, ContentDTO } from 'wdBean'
import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent'
/**
* 视频直播横划卡16:9
*/
@Component
export struct LiveHorizontalCardComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column() {
Row() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
if (this.compDTO.operDataList.length > 10) {
Row() {
Text("更多")
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_999999"))
.margin({ right: 1 })
Image($r("app.media.more"))
.width(14)
.height(14)
}
}
}.justifyContent(FlexAlign.SpaceBetween)
.padding({ left: 16, right: 16 })
.margin({ top: 8, bottom: 8 })
.width(CommonConstants.FULL_WIDTH)
// 多个
if (this.compDTO.operDataList.length >= 2) {
List({ space: 12 }) {
ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
ListItem() {
Column() {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(item.coverUrl)
.aspectRatio(16 / 9)
.width(this.compDTO.operDataList.length == 2 ? 210 : 150)
.borderRadius(4)
.objectFit(ImageFit.Cover)
if (item.objectType === '2' && item.liveInfo && item.liveInfo.liveState === 'running') {
LiveVideoTypeComponent({ nType: 0, name: '直播中' })
.padding({
bottom: 4,
right: 4
})
} else if (item.objectType === '1' && item.videoInfo) {
LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration })
.padding({
bottom: 4,
right: 4
})
}
}
Text(item.newsTitle)
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_212228"))
.fontWeight(400)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textAlign(TextAlign.Start)
.margin({ top: 8 })
.width(this.compDTO.operDataList.length == 2 ? 210 : 150)
}
}
.padding({ left: (index == 0) ? 16 : 0, right: (index == this.compDTO.operDataList.length - 1) ? 16 : 0 })
.onClick(() => {
if (item.objectType != '0') {
console.log(item.objectId)
}
})
}, (item: ContentDTO, index: number) => JSON.stringify(item))
}.listDirection(Axis.Horizontal)
.width(CommonConstants.FULL_WIDTH)
.height(this.compDTO.operDataList.length == 2 ? 180 : 136)
} else if (this.compDTO.operDataList.length) {
// 一个
LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] })
}
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
})
.backgroundColor($r("app.color.white"))
}
}
... ...
import { ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant'
import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
/**
* 视频直播横划卡16:9/1个
*/
@Component
export struct LiveHorizontalCardForOneComponent {
@State contentDTO: ContentDTO = {} as ContentDTO
build() {
Column() {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.contentDTO.coverUrl)
.aspectRatio(16 / 9)
.width(CommonConstants.FULL_WIDTH)
.borderRadius(4)
.objectFit(ImageFit.Cover)
if (this.contentDTO.objectType === '2'
&& this.contentDTO.liveInfo
&& this.contentDTO.liveInfo.liveState === 'running') {
LiveVideoTypeComponent({ nType: 0, name: '直播中' })
.padding({
bottom: 2,
right: 2
})
} else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) {
LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration ?? '00:00' })
.padding({
bottom: 2,
right: 2
})
}
}
Text(this.contentDTO.newsTitle)
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_212228"))
.fontWeight(400)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textAlign(TextAlign.Start)
.margin({ top: 8 })
.width(CommonConstants.FULL_WIDTH)
}
.padding({
left: 16,
right: 16
})
}
}
\ No newline at end of file
... ...
/**
* 视频直播横划卡标签
*/
@Component
export struct LiveVideoTypeComponent {
@State nType: number = 0
@State name: string = '直播中'
build() {
Row() {
Image(this.nType == 0 ? $r('app.media.videoTypeIcon') : $r('app.media.iv_card_play_yellow_flag'))
.width(22)
.height(18)
.padding({
left: 1,
top: 1,
bottom: 1,
})
Text(this.name)
.fontColor($r('app.color.white'))
.fontSize(this.nType == 0 ? $r('app.float.font_size_11') : $r('app.float.font_size_13'))
.align(Alignment.Center)
.padding({
top: 1,
bottom: 1,
})
}
.width(60)
.height(20)
.backgroundColor($r('app.color.color_80000000'))
}
}
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant'
const TAG: string = 'TriPicCardComponent';
/**
* 三图卡:
* compstyle:4
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
*/
// @Entry
@Component
export struct TriPicCardComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column() {
//body
Column() {
//新闻标题
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize(17)
.fontColor('#222222')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
//三图
Row() {
Image(this.compDTO.operDataList[0].fullColumnImgUrls[0]?.url)
.width('32%')
.height(75)
.borderRadius({ topLeft:4,bottomLeft:4 })
Image(this.compDTO.operDataList[0].fullColumnImgUrls[1]?.url)
.width('32%')
.height(75)
Image(this.compDTO.operDataList[0].fullColumnImgUrls[2]?.url)
.width('32%')
.height(75)
.borderRadius({ topRight:4,bottomRight:4 })
}
.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
.height(75)
.margin({top:8})
.borderRadius(8)
}
.width('100%')
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Start)
.padding({top:14})
//bottom
Row() {
Text(this.compDTO.operDataList[0].source)
.bottomTextStyle()
//间隔点
Image($r('app.media.point'))
.width(12)
.height(12)
Text(this.compDTO.operDataList[0].publishTime)
.bottomTextStyle()
Text(' ')
Text('518条评论')
.bottomTextStyle()
}
.width('100%')
.justifyContent(FlexAlign.Start)
// .padding({bottom:14})
.margin({top:8})
.padding({bottom:14})
}
.width('100%')
.padding({top:8,left:16,right:16})
}
}
@Extend(Text) function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
}
\ No newline at end of file
... ...
... ... @@ -9,7 +9,7 @@ const TAG = 'PageViewModel';
* mock数据开关,默认关。
* mock数据是本地json数据,可自行修改内容(‘entry\src\main\resources\rawfile\’目录)
*/
const mock_switch = true;
const mock_switch = false;
/**
* 处理返回后的数据
... ...
... ... @@ -6,6 +6,7 @@ export const enum CompStyle {
Carousel_Layout_01 = 'Zh_Carousel_Layout-01', // 通用轮播卡:视频、直播、活动、专题、榜单、外链
Carousel_Layout_02 = 'Carousel_Layout-02', // 直播轮播卡:直播
Single_Row_01 = 'Zh_Single_Row-01', // 三格方形小卡(排名):专题、活动
Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡
Single_Row_02 = 'Zh_Single_Row-02', // 通用横划卡:视频、直播、专题
Single_Row_03 = 'Single_Row-03', // 直播横划卡:直播
Single_Row_04 = 'Single_Row-04', // 三格方形小卡:专题、活动
... ... @@ -16,6 +17,7 @@ export const enum CompStyle {
Single_Column_04 = 'Single_Column-04', // 大卡横屏(带背景):视频、直播
Single_Column_05 = 'Single_Column-05', // 海报图卡:/
Single_Column_06 = 'Single_Column-06', // 留言板卡:/
Zh_Single_Column_02 = 'Zh_Single_Column-02', // 头图卡
Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播
Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单
Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动
... ...
import { Logger, ResourcesUtils } from 'wdKit';
import { ResponseDTO, WDHttp } from 'wdNetwork'
import { ContentDetailDTO } from '../../../../../wdBean/src/main/ets/bean/detail/ContentDetailDTO'
import { ContentDetailDTO } from 'wdBean'
const TAG = 'ContentDetailRequest';
const mock_switch = true;
const mock_switch = false;
export interface ContentDetailRequestParams {
contentId: string
... ...
import { BusinessError } from '@ohos.base'
import { Logger } from 'wdKit'
import { Logger, ToastUtils } from 'wdKit'
import { ResponseDTO} from 'wdNetwork'
import { ContentDetailRequest } from 'wdDetailPlayApi'
import { ContentDetailDTO } from 'wdBean'
... ... @@ -56,7 +56,8 @@ export class PlayViewModel {
// this.title = '旅途平安!这首歌送给即将启程回家的你'
// this.url = 'https://cdnjdout.aikan.pdnews.cn/zhbj-20240127/vod/content/output/f45ef51bb33f4ffd9458f8b386aa3227_opt.mp4'
this.canStart = false;
this.message = '获取播放地址错误';
this.message = '获取播放地址异常';
ToastUtils.showToast(this.message, 1000);
})
.finally(() => {
Logger.debug(TAG, `getContentDetailData finally`);
... ...