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
yanlu
2024-05-08 18:11:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
06a3876a7621bd891bd97399a3ab0e2e39a405cc
06a3876a
1 parent
55d218b1
fix:16962 电子报-选择日期交互问题
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendar.ets
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendarBean.ets
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendarCell.ets
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
View file @
06a3876
...
...
@@ -9,6 +9,7 @@ import font from '@ohos.font';
import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog';
import { RMCalendarBean } from './calendar/RMCalendarBean';
import { newsSkeleton } from './skeleton/newsSkeleton';
import { Logger } from 'wdKit/Index';
@Component
export struct ENewspaperPageComponent {
...
...
@@ -310,6 +311,8 @@ export struct ENewspaperPageComponent {
let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate)
if (newspaperTimes && newspaperTimes.length > 0) {
this.calendarDate = newspaperTimes[0].date
this.selectDate = new Date(this.calendarDate)
Logger.debug('ENewspaperPageComponent', this.calendarDate)
this.currentPageNum = '01'
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendar.ets
View file @
06a3876
import { RMCalendarBean } from './RMCalendarBean'
import { RMCalenderCell } from './RMCalendarCell'
const TAG = "RMCalendar"
@Component
export struct RMCalendar {
@State selectItem: RMCalendarBean = new RMCalendarBean()
...
...
@@ -12,6 +10,9 @@ export struct RMCalendar {
startDate: Date = new Date()
// 截止日期
endDate: Date = new Date()
// 当前时间
private nowDate: Date = new Date()
//当前日期-当前显示的月份的第一天
// private startDay: Date = new Date(
// this.selectDay.getFullYear(),
...
...
@@ -50,6 +51,8 @@ export struct RMCalendar {
selectFontColor: ResourceColor = "#FFFFFF"
// 选中日期背景颜色, 默认与selectDayFontColor一致
selectItemBgColor: ResourceColor = "#ED2800"
// 当前日期未选中颜色
nowFontColor: ResourceColor = "#ED2800"
@State private title: string = ''
// 计算的总加载
@State dates: Array<RMCalendarBean> = new Array()
...
...
@@ -96,6 +99,7 @@ export struct RMCalendar {
disabledFontColor: this.disabledFontColor,
hasPre: this.hasPre,
hasNext: this.hasNext,
nowFontColor: this.nowFontColor,
disableClick: (item: RMCalendarBean) => {
if (this.disableCellClick) {
this.disableCellClick(item)
...
...
@@ -229,6 +233,8 @@ export struct RMCalendar {
// 补齐上一个月差的天数,需要在当月展示的部分,下面计算日期循环加1天
tempDate.setDate(this.selectDay.getDate() - preCount)
// 当前时间除去时分秒
this.nowDate.setHours(0,0,0,0)
// 添加当月需要展示的日期
for (let index = 0; index < totalCount; index++) {
let item = new RMCalendarBean(
...
...
@@ -241,6 +247,7 @@ export struct RMCalendar {
// LunarCalendar.convertSolarToLunar(tempDate),
(index < preCount ? true : false) || this.startDate.getTime() > tempDate.getTime(),
(index >= preCount + count ? true : false) || this.endDate.getTime() < tempDate.getTime(),
tempDate.getTime() == this.nowDate.getTime()
)
if (this.reBuildDateItem) {
this.reBuildDateItem(item)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendarBean.ets
View file @
06a3876
...
...
@@ -7,12 +7,14 @@ export class RMCalendarBean {
time?: number
isPre?: boolean // 是否是上一个月的 / 在startDate 之前
isNext?: boolean // 是否是下一个月的 / 在endDate 之后
isNow?: boolean // 是否是当前时间
constructor(fullYear?: number, month?: number,
date?: number, day?: number,
time?: number,
isPre?: boolean,
isNext?: boolean) {
date?: number, day?: number,
time?: number,
isPre?: boolean,
isNext?: boolean,
isNow?: boolean) {
this.fullYear = fullYear
this.month = month
this.date = date
...
...
@@ -20,5 +22,6 @@ export class RMCalendarBean {
this.time = time
this.isPre = isPre
this.isNext = isNext
this.isNow = isNow
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/calendar/RMCalendarCell.ets
View file @
06a3876
...
...
@@ -11,6 +11,7 @@ export struct RMCalenderCell {
selectFontColor: ResourceColor = {} as ResourceColor
selectItemBgColor: ResourceColor = {} as ResourceColor
disabledFontColor: ResourceColor = {} as ResourceColor
nowFontColor: ResourceColor = {} as ResourceColor
// 今日时间戳
selectDay: number = 0
@Link selectItem: RMCalendarBean
...
...
@@ -37,7 +38,9 @@ export struct RMCalenderCell {
}
getItemColor() {
if (this.item.isPre) {
if (!this.isShowSelectBg() && this.item.isNow) {
return this.nowFontColor
} else if (this.item.isPre) {
return this.disabledFontColor
} else if (this.item.isNext) {
return this.disabledFontColor
...
...
Please
register
or
login
to post a comment