|
|
@@ -1,4 +1,4 @@
|
|
|
-import { IBestToast, YTAvoid, yTRouter, yTToast } from 'basic'
|
|
|
+import { IBestToast, YTAvoid, yTRouter, yTToast } from 'basic';
|
|
|
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
|
import { DiaryDatePicker } from '../components/DiaryDatePicker';
|
|
|
import { DiaryData, PageStatus, Variable } from '../models';
|
|
|
@@ -8,8 +8,6 @@ import { DiaryTimePicker } from '../components/DiaryTimePicker';
|
|
|
import { RecodeViewModel } from '../viewModels/RecodeViewModel';
|
|
|
import { DoubleConfirm } from '../components/DoubleConfirm';
|
|
|
import { Context } from '@ohos.abilityAccessCtrl';
|
|
|
-import { common } from '@kit.AbilityKit';
|
|
|
-import image from '@ohos.multimedia.image';
|
|
|
|
|
|
/**
|
|
|
* 新增/编辑 日记
|
|
|
@@ -194,6 +192,13 @@ struct IncreaseDiaryPage {
|
|
|
// 获取参数
|
|
|
this.pageStatus = (params?.PageStatus ?? PageStatus.DIARY) as PageStatus
|
|
|
|
|
|
+ let date = (params?.nowDate ?? -1)as number
|
|
|
+
|
|
|
+ if(date != -1){
|
|
|
+ this.diaryData.diaryDate = DateUtils.formatDateToCustomString(new Date(date), true, false)
|
|
|
+ console.log("参数" + this.diaryData.diaryDate)
|
|
|
+ }
|
|
|
+
|
|
|
// 获取参数
|
|
|
let id = (params?.id ?? -1) as number;
|
|
|
if (id != -1) {
|
|
|
@@ -219,8 +224,6 @@ struct IncreaseDiaryPage {
|
|
|
async aboutToAppear(): Promise<void> {
|
|
|
this.diaryData.diaryDate = DateUtils.formatDateToCustomString(new Date(), true, false)
|
|
|
this.getRouterParams()
|
|
|
-
|
|
|
- // TODO 在没有数据的时候 时间选择器的回显为 undefined
|
|
|
}
|
|
|
|
|
|
build() {
|
|
|
@@ -271,7 +274,9 @@ struct IncreaseDiaryPage {
|
|
|
.height(8)
|
|
|
}
|
|
|
.onClick(() => {
|
|
|
- this.showDatePicker = true
|
|
|
+ if(!this.pageReadOnly){
|
|
|
+ this.showDatePicker = true
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
// 时间选择
|
|
|
@@ -287,7 +292,9 @@ struct IncreaseDiaryPage {
|
|
|
}
|
|
|
}
|
|
|
.onClick(() => {
|
|
|
- this.showTimePicker = true
|
|
|
+ if(!this.pageReadOnly) {
|
|
|
+ this.showTimePicker = true
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
.width("100%")
|
|
|
@@ -296,18 +303,26 @@ struct IncreaseDiaryPage {
|
|
|
|
|
|
// 标题栏
|
|
|
Row() {
|
|
|
- TextInput({ text: $$this.diaryData.title, placeholder: "输入标题会更受欢迎!" })
|
|
|
- .padding(0)
|
|
|
- .fontSize(16)
|
|
|
- .fontWeight(500)
|
|
|
- .maxLength(20)
|
|
|
- .height('100%')
|
|
|
- .layoutWeight(1)
|
|
|
- .borderRadius(0)
|
|
|
- .placeholderColor("#BFBFBF")
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .caretColor('app.color.main_ac_color_dark')
|
|
|
- .placeholderFont({ size: 16, weight: FontWeight.Bold })
|
|
|
+ if(!this.pageReadOnly) {
|
|
|
+ TextInput({ text: $$this.diaryData.title, placeholder: "输入标题会更受欢迎!" })
|
|
|
+ .padding(0)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(500)
|
|
|
+ .maxLength(20)
|
|
|
+ .height('100%')
|
|
|
+ .layoutWeight(1)
|
|
|
+ .borderRadius(0)
|
|
|
+ .placeholderColor("#BFBFBF")
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .caretColor('app.color.main_ac_color_dark')
|
|
|
+ .placeholderFont({ size: 16, weight: FontWeight.Bold })
|
|
|
+ } else {
|
|
|
+ Text(this.diaryData.title)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(500)
|
|
|
+ .layoutWeight(1)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Row(){
|
|
|
if(this.diaryData.title && !this.pageReadOnly){
|
|
|
@@ -337,17 +352,24 @@ struct IncreaseDiaryPage {
|
|
|
// 内容栏
|
|
|
List(){
|
|
|
ListItem(){
|
|
|
- TextArea({ text: $$this.diaryData.content, placeholder: "记录此刻" })
|
|
|
- .padding(0)
|
|
|
- .fontSize(14)
|
|
|
- .width("100%")
|
|
|
- .height("100%")
|
|
|
- .borderRadius(0)
|
|
|
- .fontWeight(400)
|
|
|
- .placeholderColor("#BFBFBF")
|
|
|
- .placeholderFont({ size: 16 })
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .caretColor('app.color.main_ac_color_dark')
|
|
|
+ if(!this.pageReadOnly) {
|
|
|
+ TextArea({ text: $$this.diaryData.content, placeholder: "记录此刻" })
|
|
|
+ .padding(0)
|
|
|
+ .fontSize(14)
|
|
|
+ .width("100%")
|
|
|
+ .height("100%")
|
|
|
+ .borderRadius(0)
|
|
|
+ .fontWeight(400)
|
|
|
+ .placeholderColor("#BFBFBF")
|
|
|
+ .placeholderFont({ size: 16 })
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .caretColor('app.color.main_ac_color_dark')
|
|
|
+ } else {
|
|
|
+ Text(this.diaryData.content)
|
|
|
+ .width("100%")
|
|
|
+ .fontSize(14)
|
|
|
+ .fontWeight(400)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.padding({top: 12})
|
|
|
@@ -400,7 +422,6 @@ struct IncreaseDiaryPage {
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.padding({ top: 6, right: 18, bottom: 6, left: 18})
|
|
|
.onClick(() => {
|
|
|
- // this.clearPhoto()
|
|
|
this.diaryData.content = ''
|
|
|
})
|
|
|
|
|
|
@@ -418,7 +439,9 @@ struct IncreaseDiaryPage {
|
|
|
.linearGradient(this.linearInfo)
|
|
|
.padding({ top: 12, right: 16, bottom: 12, left: 16})
|
|
|
.onClick(()=>{
|
|
|
- this.photoSelect()
|
|
|
+ if(!this.pageReadOnly) {
|
|
|
+ this.photoSelect()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
.width("100%")
|
|
|
@@ -430,17 +453,6 @@ struct IncreaseDiaryPage {
|
|
|
.width("100%")
|
|
|
.height("100%")
|
|
|
|
|
|
- // 当页面不可编辑时添加覆盖层
|
|
|
- if(this.pageReadOnly) {
|
|
|
- Row()
|
|
|
- .width('100%')
|
|
|
- .height('100%')
|
|
|
- .backgroundColor(Color.Transparent) // 透明覆盖层
|
|
|
- .onTouch((event: TouchEvent) => {
|
|
|
- event.stopPropagation() // 阻止触摸事件
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
// 开启时间选择器
|
|
|
if(this.showTimePicker){
|
|
|
Column(){
|