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
douaojie
2024-05-11 11:06:55 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
350b81bb0102133eb0f2f9414fb15e8688c36ba6
350b81bb
2 parents
347fc0aa
0b90b08d
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/RmhTitle.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/RmhTitle.ets
View file @
350b81b
...
...
@@ -3,12 +3,40 @@
*/
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit';
import { DateTimeUtils, SPHelper } from 'wdKit';
import { SpConstants } from 'wdConstant/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import router from '@ohos.router'
@Component
export struct RmhTitle {
@Prop rmhInfo: RmhInfoDTO
@Prop publishTime: string | undefined
@Prop hideTime: boolean
async appointReq() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
}
aboutToAppear(): void {
let page = router.getState();
if (page.path.includes('/page/PeopleShipHomePage')) {
this.hideTime = true;
}
}
getDaysBetweenDates(date: number) {
const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数
const time1 = new Date().getTime(); // 今天日期的时间戳
const time2 = new Date(date).getTime(); // 要比较日期的时间戳
const diffDays = Math.round(Math.abs((time1 - time2) / oneDay)); // 两个日期时间戳差值除以一天的毫秒数得到天数,取绝对值并四舍五入
return Math.ceil(diffDays);
}
build() {
Flex() {
...
...
@@ -33,6 +61,7 @@ export struct RmhTitle {
.alignSelf(ItemAlign.Start)
Flex({alignContent: FlexAlign.Start, wrap: FlexWrap.NoWrap}) {
Row() {
if (!(this.hideTime && this.getDaysBetweenDates(Number(this.publishTime)) > 2)) {
if (this.publishTime) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime)))
.fontSize($r("app.float.font_size_12"))
...
...
@@ -43,6 +72,7 @@ export struct RmhTitle {
.width(16)
.height(16)
}
}
Text(this.rmhInfo.rmhDesc)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
...
...
@@ -68,7 +98,7 @@ export struct RmhTitle {
.flexShrink(0)
.alignSelf(ItemAlign.Center)
.onClick(() => {
// TODO 调用关注接口
this.appointReq();
})
}
}
...
...
Please
register
or
login
to post a comment