|
|
@@ -1,9 +1,15 @@
|
|
|
-import { YTAvoid, yTRouter } from 'basic'
|
|
|
+import { IBestToast, YTAvoid, yTRouter, yTToast } from 'basic'
|
|
|
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
|
import { DiaryDatePicker } from '../components/DiaryDatePicker';
|
|
|
-import { DiaryData } from '../models';
|
|
|
+import { DiaryData, PageStatus } from '../models';
|
|
|
import { DiaryViewModel } from '../viewModels/DiaryViewModel';
|
|
|
import { DateUtils } from '../utils/DateUtils';
|
|
|
+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';
|
|
|
|
|
|
/**
|
|
|
* 新增/编辑 日记
|
|
|
@@ -11,19 +17,29 @@ import { DateUtils } from '../utils/DateUtils';
|
|
|
@Component
|
|
|
struct IncreaseDiaryPage {
|
|
|
@StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
|
|
|
- @State imageList: string[] = []
|
|
|
// 页面编辑中的状态 - 默认为可编辑
|
|
|
@State pageReadOnly: boolean = false
|
|
|
// 时间选择器 开启控制
|
|
|
@State showTimePicker: boolean = false
|
|
|
+ // 日期选择器 开启控制
|
|
|
+ @State showDatePicker: boolean = false
|
|
|
// 日记详细数据
|
|
|
- @State diaryData: DiaryData = new DiaryData();
|
|
|
+ @State diaryData: DiaryData = {};
|
|
|
+ // 页面状态, 默认为日记
|
|
|
+ @State pageStatus: PageStatus = PageStatus.DIARY
|
|
|
+
|
|
|
+ private linearInfo: LinearGradientOptions = {
|
|
|
+ colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
|
|
|
+ angle: 150
|
|
|
+ }
|
|
|
+ private conText: Context = this.getUIContext().getHostContext() as Context
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 选择图片
|
|
|
*/
|
|
|
async photoSelect(){
|
|
|
- let uris: Array<string> = [];
|
|
|
let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
|
|
|
PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
|
|
|
PhotoSelectOptions.maxSelectNumber = 1;
|
|
|
@@ -32,7 +48,8 @@ struct IncreaseDiaryPage {
|
|
|
let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoPicker.select(PhotoSelectOptions);
|
|
|
let photoList = photoSelectResult.photoUris;
|
|
|
if (photoList.length > 0) {
|
|
|
- this.imageList.push(...photoList);
|
|
|
+ if(!this.diaryData.imageUrls) this.diaryData.imageUrls = [];
|
|
|
+ this.diaryData.imageUrls = [...this.diaryData.imageUrls, ...photoList];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -45,82 +62,238 @@ struct IncreaseDiaryPage {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 浅拷贝
|
|
|
+ let diaryData = JSON.parse(JSON.stringify(this.diaryData)) as DiaryData
|
|
|
+ // 统一时间格式
|
|
|
+
|
|
|
+
|
|
|
+ // 图片上传逻辑
|
|
|
+ if (diaryData.imageUrls && diaryData.imageUrls.length != 0) {
|
|
|
+ console.log("图片上传中" + JSON.stringify(diaryData.imageUrls))
|
|
|
+
|
|
|
+ // 使用map创建Promise数组,然后用Promise.all等待所有上传完成
|
|
|
+ const uploadPromises = diaryData.imageUrls?.map(async (url: string) => {
|
|
|
+ if(url?.split(':')?.[0] === 'file') {
|
|
|
+ console.log("开始上传图片 " + url)
|
|
|
+ let _url = await DiaryViewModel.uploadImage(this.conText, url)
|
|
|
+ return _url
|
|
|
+ }
|
|
|
+ return url
|
|
|
+ })
|
|
|
+
|
|
|
+ // 等待所有上传完成
|
|
|
+ const imageUrl = await Promise.all(uploadPromises)
|
|
|
+ console.log("图片上传结果" + JSON.stringify(imageUrl))
|
|
|
+
|
|
|
+ // 将处理后的URL赋值回diaryData
|
|
|
+ diaryData.imageUrls = imageUrl
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 判断是否是新增日记 - 有 id 时为 修改日记
|
|
|
if(!this.diaryData.id) {
|
|
|
- console.log("保存")
|
|
|
- const ans = await DiaryViewModel.saveDiaryLog(this.diaryData)
|
|
|
- console.log("保存结果" + JSON.stringify(ans))
|
|
|
+ diaryData.diaryDate += ':00'
|
|
|
+ this.onSubmit(diaryData)
|
|
|
+ } else {
|
|
|
+ this.onUpdate(diaryData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新建 日记、小记录
|
|
|
+ async onSubmit(data: DiaryData) {
|
|
|
+ let ans: boolean = false
|
|
|
+ console.log("保存")
|
|
|
+
|
|
|
+ if(this.pageStatus === PageStatus.DIARY) {
|
|
|
+ ans = await DiaryViewModel.saveDiaryLog(data)
|
|
|
+ console.log("日记-保存结果" + JSON.stringify(ans))
|
|
|
+ } else {
|
|
|
+ data.noteTime = data.diaryDate
|
|
|
+ ans = await RecodeViewModel.saveNote(data)
|
|
|
+ console.log("小记录-保存结果" + JSON.stringify(ans))
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ans) {
|
|
|
+ IBestToast.show({ message: '保存成功' })
|
|
|
+ yTRouter.routerBack()
|
|
|
+ } else {
|
|
|
+ IBestToast.show({ message: '保存失败' })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改日记、小记录
|
|
|
+ async onUpdate(data: DiaryData) {
|
|
|
+ let ans: boolean = false
|
|
|
+ console.log("修改")
|
|
|
+ if(this.pageStatus === PageStatus.DIARY) {
|
|
|
+ let time = DateUtils.formatDateToCustomString(new Date()).split(' ')[1]
|
|
|
+ data.diaryDate = data.diaryDate?.split(' ')[0] + ' ' +time
|
|
|
+ ans = await DiaryViewModel.updateDiaryLog(data)
|
|
|
+ console.log("日记-修改结果" + ans)
|
|
|
+ } else {
|
|
|
+ data.noteTime = data.diaryDate + ':00'
|
|
|
+ ans = await RecodeViewModel.updateNote(data)
|
|
|
+ console.log("小记录-修改结果" + JSON.stringify(ans))
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ans) {
|
|
|
+ IBestToast.show({ message: '保存成功' })
|
|
|
+ yTRouter.routerBack()
|
|
|
} else {
|
|
|
- console.log("修改")
|
|
|
- const ans = await DiaryViewModel.updateDiaryLog(this.diaryData)
|
|
|
- console.log("修改结果" + JSON.stringify(ans))
|
|
|
+ IBestToast.show({ message: '保存失败' })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 清空相册
|
|
|
+ */
|
|
|
+ clearPhoto() {
|
|
|
+ this.diaryData.imageUrls = []
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除图片
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+ delPhotoItem(index: number){
|
|
|
+ let temp = [...this.diaryData.imageUrls!]
|
|
|
+ temp?.splice(index, 1)
|
|
|
+ this.diaryData.imageUrls = temp
|
|
|
+ console.log("点击了删除" + JSON.stringify(this.diaryData.imageUrls))
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 重写返回逻辑 - 拦截返回手势
|
|
|
* @returns
|
|
|
*/
|
|
|
onRouterBack(): boolean {
|
|
|
- // this.openToast(wrapBuilder(agreePrivacy), item)
|
|
|
- yTRouter.routerBack()
|
|
|
+ // if(this.diaryData.id) {
|
|
|
+ yTToast.openToast(wrapBuilder(DoubleConfirm), {
|
|
|
+ text: "是否确认退出编辑",
|
|
|
+ click: async () => {
|
|
|
+ yTToast.hide()
|
|
|
+ yTRouter.routerBack()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // } else {
|
|
|
+ // yTRouter.routerBack()
|
|
|
+ // }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- async aboutToAppear(): Promise<void> {
|
|
|
+ // 路由参数解析
|
|
|
+ async getRouterParams(){
|
|
|
+ // 获取路由参数
|
|
|
const params = yTRouter.getParamByName("IncreaseDiaryPage").pop() as Record<string, boolean | number>;
|
|
|
- this.pageReadOnly = (params?.pageReadOnly ?? false) as boolean;
|
|
|
- console.log("pageEditing: " + !this.pageReadOnly)
|
|
|
|
|
|
+ // 获取参数
|
|
|
+ this.pageStatus = (params?.PageStatus ?? PageStatus.DIARY) as PageStatus
|
|
|
+
|
|
|
+ // 获取参数
|
|
|
let id = (params?.id ?? -1) as number;
|
|
|
if (id != -1) {
|
|
|
- this.diaryData = await DiaryViewModel.queryDiaryLogById(id)
|
|
|
- } else {
|
|
|
- this.diaryData.diaryDate = DateUtils.formatDateToCustomString(new Date())
|
|
|
+ this.pageReadOnly = true
|
|
|
+ if(this.pageStatus == PageStatus.DIARY) {
|
|
|
+ this.diaryData = await DiaryViewModel.queryDiaryLogById(id)
|
|
|
+ } else {
|
|
|
+ this.diaryData = await RecodeViewModel.queryNoteById(id)
|
|
|
+ this.diaryData.diaryDate = this.diaryData.noteTime
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ let time = this.diaryData.diaryDate?.split(' ')?.[1]
|
|
|
+ let time1 = time?.split(':')
|
|
|
+ time1?.pop()
|
|
|
+ this.diaryData.diaryDate = this.diaryData.diaryDate?.split(' ')?.[0] + ' ' + time1?.join(':')
|
|
|
+ } catch (e){
|
|
|
+ console.log("时间解析错误")
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // TODO 在没有数据的时候 时间选择器的回显为 undefined
|
|
|
+ async aboutToAppear(): Promise<void> {
|
|
|
+ this.diaryData.diaryDate = DateUtils.formatDateToCustomString(new Date())
|
|
|
+ this.getRouterParams()
|
|
|
|
|
|
- // 测试用
|
|
|
- // this.diaryData.imageUrls = [
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg',
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg',
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg',
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg',
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg',
|
|
|
- // 'https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg'
|
|
|
- // ]
|
|
|
+ // TODO 在没有数据的时候 时间选择器的回显为 undefined
|
|
|
}
|
|
|
|
|
|
build() {
|
|
|
NavDestination() {
|
|
|
Column({ space: 5 }) {
|
|
|
- Row() {
|
|
|
- Image($r("app.media.close"))
|
|
|
- .width(20)
|
|
|
- .aspectRatio(1)
|
|
|
- .onClick(this.onRouterBack)
|
|
|
+ // 标题区
|
|
|
+ Stack({alignContent: Alignment.Center}) {
|
|
|
+ Row(){
|
|
|
+ Image($r("app.media.close"))
|
|
|
+ .width(20)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .onClick(this.onRouterBack)
|
|
|
+
|
|
|
+ Text(this.pageReadOnly ? "编辑" : "完成")
|
|
|
+ .fontSize(14)
|
|
|
+ .fontWeight(500)
|
|
|
+ .borderRadius(16)
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ .padding({top: 5.5, left: 14, right: 14, bottom: 5.5})
|
|
|
+ .onClick(() => {
|
|
|
+ this.onComplete()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
|
Text("创作")
|
|
|
.fontSize(20)
|
|
|
.fontWeight(700)
|
|
|
-
|
|
|
- Text(this.pageReadOnly ? "编辑" : "完成")
|
|
|
- .onClick(() => {
|
|
|
- this.onComplete()
|
|
|
- })
|
|
|
}
|
|
|
.width("100%")
|
|
|
- .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ .padding({ top: this.safeTop + 5, left: 20, right: 20, bottom: 22 })
|
|
|
|
|
|
+ // 内容区
|
|
|
Column({space: 5}) {
|
|
|
- Stack(){
|
|
|
+ Stack({alignContent: Alignment.Bottom}){
|
|
|
+ // 主要内容
|
|
|
Column(){
|
|
|
+ // 时间选择
|
|
|
+ Row(){
|
|
|
+ Row({space: 8}){
|
|
|
+ Text(this.diaryData.diaryDate?.split(' ')[0])
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(600)
|
|
|
+
|
|
|
+ Image($r('app.media.Diary_DateOpen'))
|
|
|
+ .width(14)
|
|
|
+ .height(8)
|
|
|
+ }
|
|
|
+ .onClick(() => {
|
|
|
+ this.showDatePicker = true
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ Row({space: 8}){
|
|
|
+ if(this.pageStatus == PageStatus.RECODE) {
|
|
|
+ Text(this.diaryData.diaryDate?.split(' ')[1])
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(600)
|
|
|
+
|
|
|
+ Image($r('app.media.Diary_DateOpen'))
|
|
|
+ .width(14)
|
|
|
+ .height(8)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .onClick(() => {
|
|
|
+ this.showTimePicker = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ .padding({top: 16, bottom: 16}) // , left: 20, right: 20
|
|
|
+
|
|
|
// 标题栏
|
|
|
Row() {
|
|
|
TextInput({ text: $$this.diaryData.title, placeholder: "输入标题会更受欢迎(✪ω✪)" })
|
|
|
.padding(0)
|
|
|
- .fontSize(20)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(500)
|
|
|
.maxLength(20)
|
|
|
.height('100%')
|
|
|
.layoutWeight(1)
|
|
|
@@ -128,7 +301,7 @@ struct IncreaseDiaryPage {
|
|
|
.placeholderColor("#BFBFBF")
|
|
|
.backgroundColor(Color.Transparent)
|
|
|
.caretColor('app.color.main_ac_color_dark')
|
|
|
- .placeholderFont({ size: 20, weight: FontWeight.Bold })
|
|
|
+ .placeholderFont({ size: 16, weight: FontWeight.Bold })
|
|
|
|
|
|
Text(`${20 - (this.diaryData.title ? this.diaryData.title.length : 0) }`)
|
|
|
.fontColor("#BFBFBF")
|
|
|
@@ -142,17 +315,96 @@ struct IncreaseDiaryPage {
|
|
|
})
|
|
|
|
|
|
// 内容栏
|
|
|
- TextArea({ text: $$this.diaryData.content, placeholder: "记录此刻" })
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .padding(0)
|
|
|
- .height(450)
|
|
|
- .fontSize(16)
|
|
|
+ Row(){
|
|
|
+ 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')
|
|
|
+ }
|
|
|
+ .padding({top: 12})
|
|
|
+ .layoutWeight(1)
|
|
|
+ .width("100%")
|
|
|
+
|
|
|
+ Column({space: 32}){
|
|
|
+ // 图片显示器
|
|
|
+ Scroll(){
|
|
|
+ Row({space: 5}){
|
|
|
+ ForEach(this.diaryData.imageUrls, (item: string, index: number) => {
|
|
|
+ Stack({alignContent: Alignment.TopEnd}){
|
|
|
+ Image(item)
|
|
|
+ .width(100)
|
|
|
+ .height(108)
|
|
|
+ if(!this.pageReadOnly) {
|
|
|
+ Image($r('app.media.Diary_close'))
|
|
|
+ .width(24)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .offset({
|
|
|
+ x: -2, y: -2
|
|
|
+ })
|
|
|
+ .onClick(() => {
|
|
|
+ this.delPhotoItem(index)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .height(108)
|
|
|
+ .scrollable(ScrollDirection.Horizontal)
|
|
|
+ .align(Alignment.TopStart)
|
|
|
+
|
|
|
+ // 图片选择器
|
|
|
+ Row(){
|
|
|
+ // 清空
|
|
|
+ Row(){
|
|
|
+ if(!this.pageReadOnly){
|
|
|
+ Text('清空')
|
|
|
+ .fontSize(18)
|
|
|
+ .fontWeight(400)
|
|
|
+ .fontColor('#979797')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .borderRadius(20)
|
|
|
+ .backgroundColor('#F0F0F0')
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .padding({ top: 6, right: 18, bottom: 6, left: 18})
|
|
|
+ .onClick(() => {
|
|
|
+ this.clearPhoto()
|
|
|
+ })
|
|
|
+
|
|
|
+ // 相册
|
|
|
+ Row({space: 5}){
|
|
|
+ Image($r('app.media.photoAlbum'))
|
|
|
+ .width(20)
|
|
|
+ .aspectRatio(1)
|
|
|
+
|
|
|
+ Text("相册")
|
|
|
+ .fontSize(18)
|
|
|
+ .fontWeight(500)
|
|
|
+ }
|
|
|
+ .borderRadius(18)
|
|
|
+ .linearGradient(this.linearInfo)
|
|
|
+ .padding({ top: 12, right: 16, bottom: 12, left: 16})
|
|
|
+ .onClick(()=>{
|
|
|
+ this.photoSelect()
|
|
|
+ })
|
|
|
+ }
|
|
|
.width("100%")
|
|
|
- .borderRadius(0)
|
|
|
- .placeholderFont({ size: 16 })
|
|
|
- .placeholderColor("#BFBFBF")
|
|
|
- .caretColor('app.color.main_ac_color_dark')
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ }
|
|
|
+ .padding({bottom: 64})
|
|
|
}
|
|
|
+ .width("100%")
|
|
|
+ .height("100%")
|
|
|
|
|
|
// 当页面不可编辑时添加覆盖层
|
|
|
if(this.pageReadOnly) {
|
|
|
@@ -164,84 +416,80 @@ struct IncreaseDiaryPage {
|
|
|
event.stopPropagation() // 阻止触摸事件
|
|
|
})
|
|
|
}
|
|
|
- }
|
|
|
- .height(500)
|
|
|
- .onClick(() => {
|
|
|
- this.showTimePicker = false
|
|
|
- })
|
|
|
- Stack(){
|
|
|
- Column(){
|
|
|
- // 时间选择器
|
|
|
- Row(){
|
|
|
- Text("这是一个时间选择器" + this.diaryData.diaryDate?.split(' ')[0])
|
|
|
+
|
|
|
+ // 开启时间选择器
|
|
|
+ if(this.showTimePicker){
|
|
|
+ Column(){
|
|
|
+ DiaryTimePicker({
|
|
|
+ timeStr: (this.diaryData.diaryDate ?? DateUtils.formatDateToCustomString(new Date(), true)).split(' ')[1],
|
|
|
+ onConfirm: (time: string) => {
|
|
|
+ this.showTimePicker = false
|
|
|
+ console.log("选择的时间 " + time)
|
|
|
+ this.diaryData.diaryDate = this.diaryData.diaryDate?.split(' ')[0] + ' ' + time
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
+ .width("100%")
|
|
|
+ .height("100%")
|
|
|
+ .padding({ top: 53 })
|
|
|
+ .alignItems(HorizontalAlign.End)
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
.onClick(() => {
|
|
|
- this.showTimePicker = !this.showTimePicker
|
|
|
+ this.showTimePicker = false
|
|
|
})
|
|
|
+ }
|
|
|
|
|
|
- // 图片显示器
|
|
|
- Scroll(){
|
|
|
- Row({space: 5}){
|
|
|
- ForEach(this.diaryData.imageUrls, (item: string, index: number) => {
|
|
|
- Image(item)
|
|
|
- .width(100)
|
|
|
- .height(150)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- .scrollable(ScrollDirection.Horizontal)
|
|
|
+ // 开启日期选择器
|
|
|
+ if(this.showDatePicker) {
|
|
|
+ Column(){
|
|
|
+ DiaryDatePicker({
|
|
|
+ selectedDate: new Date(this.diaryData.diaryDate ?? new Date().toISOString()),
|
|
|
+ selectDateBack: (date: Date) => {
|
|
|
+ this.showDatePicker = false
|
|
|
+ let result = DateUtils.formatDateToCustomString(date, false)
|
|
|
+ console.log("选择的日期" + result)
|
|
|
+ try {
|
|
|
+ let temp = this.diaryData.diaryDate?.split(' ')[1]
|
|
|
+ this.diaryData.diaryDate = result + ' ' + temp
|
|
|
+ } catch (e) {
|
|
|
|
|
|
- // 图片选择器
|
|
|
- Row(){
|
|
|
- Row({space: 5}){
|
|
|
- Image($r('app.media.photoAlbum'))
|
|
|
- .width(20)
|
|
|
- .aspectRatio(1)
|
|
|
-
|
|
|
- Text("相册")
|
|
|
- .fontSize(16)
|
|
|
- .fontWeight(700)
|
|
|
- }
|
|
|
- .onClick(()=>{
|
|
|
- this.photoSelect()
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
+ .width("80%")
|
|
|
}
|
|
|
.width("100%")
|
|
|
- .alignItems(VerticalAlign.Center)
|
|
|
- .justifyContent(FlexAlign.End)
|
|
|
- }
|
|
|
- .width("100%")
|
|
|
- .height("100%")
|
|
|
- .onClick(() => {
|
|
|
- this.showTimePicker = false
|
|
|
- })
|
|
|
-
|
|
|
- if(this.showTimePicker) {
|
|
|
- DiaryDatePicker({
|
|
|
- selectedDate: new Date(this.diaryData.diaryDate ?? new Date().toISOString()),
|
|
|
- selectDateBack: (date: Date) => {
|
|
|
- this.showTimePicker = false
|
|
|
- let result = DateUtils.formatDateToCustomString(date)
|
|
|
- this.diaryData.diaryDate = result
|
|
|
- }
|
|
|
+ .height("100%")
|
|
|
+ .padding({ top: 53 })
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+ .onClick(() => {
|
|
|
+ this.showDatePicker = false
|
|
|
})
|
|
|
- .width("80%")
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
.width("100%")
|
|
|
- .layoutWeight(1)
|
|
|
+ .height("100%")
|
|
|
}
|
|
|
- .alignItems(HorizontalAlign.Start)
|
|
|
- .justifyContent(FlexAlign.Start)
|
|
|
.width("100%")
|
|
|
.layoutWeight(1)
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+ .padding({ left: 20, right: 20 })
|
|
|
+ .borderRadius({
|
|
|
+ topLeft: 28, topRight: 28
|
|
|
+ })
|
|
|
}
|
|
|
.width("100%")
|
|
|
.height("100%")
|
|
|
- .padding({ top: this.safeTop, left: 16, right: 16 })
|
|
|
+ .linearGradient(this.linearInfo)
|
|
|
}
|
|
|
.hideTitleBar(true)
|
|
|
- .onBackPressed(this.onRouterBack)
|
|
|
+ .onBackPressed(() => {
|
|
|
+ return this.onRouterBack()
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|