Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-05-22 11:17:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ae16d936b37cae2a1dce31e246585a28c5afb9f
3ae16d93
1 parent
9f67ef10
feat: 17910 【全域规则】频道-外部卡片日期展示规则与需求不一致
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
4 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
View file @
3ae16d9
import { CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { JSON } from '@kit.ArkTS';
import router from '@ohos.router'
@Component
export struct CardSourceInfo {
@State contentDTO: ContentDTO = new ContentDTO();
@ObjectLink compDTO: CompDTO
handleTimeStr() {
return DateTimeUtils.getCommentTime(
this.contentDTO.publishTime.includes(' ')
? Number.parseFloat(new Date(this.contentDTO.publishTime).getTime().toString())
: Number.parseFloat(this.contentDTO.publishTime)
)
}
showTime() {
console.log('curRouter', this.contentDTO.publishTime)
const curRouter = router.getState().name;
const publishTime = this.contentDTO.publishTime.includes(' ')
? new Date(this.contentDTO.publishTime).getTime().toString()
: this.contentDTO.publishTime
let flag: boolean = false;
if (curRouter === 'MainPage') {
if (this.isTwoDaysAgo(publishTime)) {
console.log('curRouter 01')
flag = false
} else {
console.log('curRouter 02')
flag = true;
}
} else {
console.log('curRouter 03')
flag = true;
}
return flag;
}
isTwoDaysAgo(date: string) {
const twoDaysAgo = new Date();
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
console.log('curRouter', date)
return parseInt(date) < twoDaysAgo.getTime()
}
build() {
Flex({ alignItems: ItemAlign.Center }) {
if (this.contentDTO.corner) {
...
...
@@ -52,11 +91,12 @@ export struct CardSourceInfo {
// .fontColor($r("app.color.color_B0B0B0"))
// .flexShrink(0);
// }
if (this.contentDTO.source) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(new Date(this.contentDTO.publishTime).getTime().toString())))
if (this.contentDTO.source && this.showTime()) {
Text(this.handleTimeStr())
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0);
.flexShrink(0)
.margin({right: 4})
}
if (this.getContentDtoBean()?.interactData?.commentNum && this.contentDTO.source) {
...
...
@@ -64,7 +104,6 @@ export struct CardSourceInfo {
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
.margin({ left: 6 })
.visibility(Number(this.getContentDtoBean()?.interactData?.commentNum) === 0 ? Visibility.None :
Visibility.Visible)
}
...
...
Please
register
or
login
to post a comment