wangyong_wd

组件样式优化

... ... @@ -77,11 +77,6 @@ export struct CardMediaInfo {
.width(14)
.height(14)
.margin({ right: 3 })
.shadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
}
}
... ...
... ... @@ -5,32 +5,30 @@ import { DateTimeUtils } from 'wdKit/Index';
@Component
export struct CardSourceInfo {
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Flex() {
if(this.contentDTO.corner) {
if (this.contentDTO.corner) {
Text(this.contentDTO.corner)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_ED2800"))
.margin({right: 2})
.margin({ right: 2 })
}
if(this.contentDTO.rmhPlatform === 1) {
if (this.contentDTO.rmhPlatform === 1) {
Text(this.contentDTO.rmhInfo.rmhName)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
Image($r("app.media.point"))
.width(16)
.height(16)
} else if(this.contentDTO.source) {
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (this.contentDTO.source) {
Text(`${this.contentDTO.source}`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
// 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
if(this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime
if (this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
... ... @@ -42,14 +40,14 @@ export struct CardSourceInfo {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ right: 6 })
.flexShrink(0)
}
if(this.contentDTO?.interactData?.commentNum) {
if (this.contentDTO?.interactData?.commentNum) {
Text(`${this.contentDTO.interactData.commentNum}评`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
.margin({ left: 6 })
}
}
.width(CommonConstants.FULL_WIDTH)
... ...
// 视频直播横划卡16:9
import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent'
import { Action, CompDTO, ContentDTO, Params } from 'wdBean'
import { CommonConstants } from 'wdConstant'
import { WDRouterRule } from 'wdRouter/Index'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
@Component
export struct LiveHorizontalCardComponent {
@State compDTO: CompDTO = {} as CompDTO
... ... @@ -60,19 +59,9 @@ export struct LiveHorizontalCardComponent {
.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
CardMediaInfo({
contentDTO: item
})
} else if (item.objectType === '1' && item.videoInfo) {
LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration + "" })
.padding({
bottom: 4,
right: 4
})
}
}
Text(item.newsTitle)
... ...
// 视频直播横划卡16:9/1个
import { CommonConstants } from 'wdConstant'
import { ContentDTO } from 'wdBean'
import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
@Component
export struct LiveHorizontalCardForOneComponent {
@State contentDTO: ContentDTO = {} as ContentDTO
... ... @@ -15,21 +14,9 @@ export struct LiveHorizontalCardForOneComponent {
.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
CardMediaInfo({
contentDTO: this.contentDTO
})
} 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)
... ...
// 视频直播直播预约
import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent'
import { CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant'
import { StringUtils } from 'wdKit/Index'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
@Component
export struct LiveHorizontalReservationComponent {
@State compDTO: CompDTO = {} as CompDTO
... ... @@ -51,19 +50,9 @@ export struct LiveHorizontalReservationComponent {
.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
CardMediaInfo({
contentDTO: item
})
} else if (item.objectType === '1' && item.videoInfo) {
LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration + "" })
.padding({
bottom: 4,
right: 4
})
}
}
Text(item.newsTitle)
... ...