Quellcode durchsuchen

feat:
1. 完成 《记录》、《日记》 view下的基础功能和交互
2. 完成 《新增日记/记录》 page 下的基础功能和交互
3. 完成 《搜索日记》 page 下的基础功能和交互
4. 更新了部分UI

YuJing vor 2 Monaten
Ursprung
Commit
64643cd472
32 geänderte Dateien mit 1279 neuen und 439 gelöschten Zeilen
  1. 13 1
      commons/basic/src/main/ets/constants/index.ets
  2. 4 4
      features/feature/src/main/ets/apis/DiaryApi.ets
  3. 4 1
      features/feature/src/main/ets/components/DiaryDatePicker.ets
  4. 41 12
      features/feature/src/main/ets/components/DiaryTimePicker.ets
  5. 6 5
      features/feature/src/main/ets/components/DiaryTitleItem.ets
  6. 49 0
      features/feature/src/main/ets/components/DoubleConfirm.ets
  7. 14 49
      features/feature/src/main/ets/models/index.ets
  8. 189 54
      features/feature/src/main/ets/pages/DiarySearchPage.ets
  9. 359 111
      features/feature/src/main/ets/pages/IncreaseDiaryPage.ets
  10. 1 1
      features/feature/src/main/ets/utils/DateUtils.ets
  11. 55 19
      features/feature/src/main/ets/view/DiaryView.ets
  12. 284 154
      features/feature/src/main/ets/view/RecodView.ets
  13. 62 12
      features/feature/src/main/ets/viewModels/DiaryViewModel.ets
  14. 129 2
      features/feature/src/main/ets/viewModels/RecodeViewModel.ets
  15. 1 0
      features/feature/src/main/resources/base/media/Diary_DateOpen.svg
  16. 4 0
      features/feature/src/main/resources/base/media/Diary_close.svg
  17. 4 1
      features/feature/src/main/resources/base/media/Search.svg
  18. 12 1
      features/feature/src/main/resources/base/media/add.svg
  19. BIN
      features/feature/src/main/resources/base/media/add_Img.png
  20. 10 1
      features/feature/src/main/resources/base/media/calendar.svg
  21. BIN
      features/feature/src/main/resources/base/media/close.png
  22. 0 1
      features/feature/src/main/resources/base/media/close.svg
  23. 10 1
      features/feature/src/main/resources/base/media/del.svg
  24. 12 1
      features/feature/src/main/resources/base/media/photoAlbum.svg
  25. 8 0
      products/entry/src/main/ets/entryability/EntryAbility.ets
  26. 8 8
      products/entry/src/main/ets/pages/Index.ets
  27. BIN
      products/entry/src/main/resources/base/media/Diary_Icon_0.png
  28. BIN
      products/entry/src/main/resources/base/media/Diary_Icon_1.png
  29. BIN
      products/entry/src/main/resources/base/media/My_Icon_0.png
  30. BIN
      products/entry/src/main/resources/base/media/My_Icon_1.png
  31. BIN
      products/entry/src/main/resources/base/media/Recode_Icon_0.png
  32. BIN
      products/entry/src/main/resources/base/media/Recode_Icon_1.png

+ 13 - 1
commons/basic/src/main/ets/constants/index.ets

@@ -37,7 +37,19 @@ export enum AppStorageKeyCollect {
    * @type Record<string, string>
    * @description 验证码登录手机号与验证码
    */
-  CAPTCHA_LOGIN = 'captchaLogin'
+  CAPTCHA_LOGIN = 'captchaLogin',
+
+  /**
+   * @type number
+   * @description 屏幕宽度
+   */
+  SCREEN_WIDTH = 'screenWidth',
+
+  /**
+   * @type number
+   * @description 屏幕高度
+   */
+  SCREEN_HEIGHT = 'screenHeight',
 }
 
 export enum YTUserUrl {

+ 4 - 4
features/feature/src/main/ets/apis/DiaryApi.ets

@@ -45,7 +45,7 @@ export class DiaryApi {
    * @returns 日记列表
    */
   static diaryLogSearch(keyword: string): Promise<DiaryData[]> {
-    return YTRequest.post<DiaryData[], string>(ApiUrl.DIARY_LOG_SEARCH + '?keyword=' + keyword)
+    return YTRequest.get<DiaryData[]>(ApiUrl.DIARY_LOG_SEARCH + '?keyword=' + keyword)
   }
 
   /**
@@ -62,7 +62,7 @@ export class DiaryApi {
    * @param id 生活小记录id
    * @returns
    */
-  static deleteNote(id: string): Promise<boolean> {
+  static deleteNote(id: number): Promise<boolean> {
     return YTRequest.delete<boolean>(ApiUrl.DELETE_NOTE + '?id=' + id)
   }
 
@@ -81,7 +81,7 @@ export class DiaryApi {
    * @returns 生活小记录列表
    */
   static queryNoteList(nowTime: string): Promise<DiaryData[]> {
-    return YTRequest.post<DiaryData[], string>(ApiUrl.QUERY_BY_NOTE_LIST + '?nowTime=' + nowTime)
+    return YTRequest.get<DiaryData[]>(ApiUrl.QUERY_BY_NOTE_LIST + '?nowTime=' + nowTime)
   }
 
   /**
@@ -89,7 +89,7 @@ export class DiaryApi {
    * @param id 生活小记录id
    * @returns
    */
-  static queryNoteById(id: string): Promise<DiaryData> {
+  static queryNoteById(id: number): Promise<DiaryData> {
     return YTRequest.get<DiaryData>(ApiUrl.QUERY_NOTE_BY_ID + '?id=' + id)
   }
 

+ 4 - 1
features/feature/src/main/ets/components/DiaryDatePicker.ets

@@ -47,11 +47,14 @@ export struct DiaryDatePicker {
 
         DatePicker({
           end: new Date(),
-          selected: $$this.selectedDate,
+          selected: this.selectedDate,
         })
           .selectedTextStyle({
             color: Color.Black,
           })
+          .onDateChange((date: Date) => {
+            this.selectedDate = date
+          })
       }
       .padding({ left: 13, right: 13})
     }

+ 41 - 12
features/feature/src/main/ets/components/DiaryTimePicker.ets

@@ -1,23 +1,52 @@
+import { DateUtils } from "../utils/DateUtils"
+
 @Component
 export struct DiaryTimePicker {
-  @State selectedHour: number = 12
+  @State selectedHour: number = 0
   @State selectedMinute: number = 0
   private hourController: SwiperController = new SwiperController()
   private minuteController: SwiperController = new SwiperController()
 
+  iwidth = 160
+  timeStr: String = DateUtils.formatDateToCustomString(new Date(), true).split(' ')[1]
+
   // 回调函数
-  private onConfirm?: (hour: number, minute: number) => void = (hour: number, minute: number) => {
-    console.log('onConfirm' + ((hour+1)%24) + ':' + ((minute+1)%60))
+  onConfirm?: (time: string) => void = (time: string) => {
+    console.log('onConfirm' + time)
   }
-  private onCancel?: () => void
 
-  private iwidth = 160
-  private iheight = 180
+  onCancel?: () => void
+
   private linearInfo: LinearGradientOptions = {
     colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
     angle: 150
   }
 
+  aboutToAppear(): void {
+    if (this.timeStr) {
+      // 解析时间字符串 'hh:mm'
+      const timeParts = this.timeStr.split(':');
+      if (timeParts.length >= 2) {
+        let hour = parseInt(timeParts[0], 10) - 1;
+        let minute = parseInt(timeParts[1], 10) - 1;
+
+        if (hour < 0) hour = 23
+        if (minute < 0) minute = 59
+
+        // 验证时间有效性
+        if (!isNaN(hour) && !isNaN(minute) && hour >= 0 && hour < 24 && minute >= 0 && minute < 60) {
+          this.selectedHour = hour;
+          this.selectedMinute = minute;
+
+          setTimeout(() => {
+            this.hourController.changeIndex(hour);
+            this.minuteController.changeIndex(minute);
+          }, 0)
+        }
+      }
+    }
+  }
+
   build() {
     Column() {
 
@@ -44,14 +73,16 @@ export struct DiaryTimePicker {
         .borderRadius(36)
         .linearGradient(this.linearInfo)
         .onClick(() => {
-          this.onConfirm?.(this.selectedHour, this.selectedMinute)
+          const formattedHour = ((this.selectedHour+1)%24).toString().padStart(2, '0');
+          const formattedMinute = ((this.selectedMinute+1)%60).toString().padStart(2, '0');
+          const formattedTime = `${formattedHour}:${formattedMinute}`;
+          this.onConfirm?.(formattedTime);
         })
       }
       .width("100%")
       .justifyContent(FlexAlign.SpaceBetween)
       .padding({ left: 15, right: 15, top: 17})
 
-
       Stack({alignContent: Alignment.Center}){
         Row()
           .height(50)
@@ -104,9 +135,9 @@ export struct DiaryTimePicker {
             Swiper(this.minuteController) {
               ForEach(new Array(60).fill(0), (item: number, index: number) => {
                 Text(`${index.toString().padStart(2, '0')}`)
-                  .fontSize(index === (this.selectedMinute+1)%59 ? 16 : 14)
+                  .fontSize(index === (this.selectedMinute+1)%60 ? 16 : 14)
                   .fontWeight(FontWeight.Bold)
-                  .fontColor(index === (this.selectedMinute+1)%59 ? '#212245' : '#757575')
+                  .fontColor(index === (this.selectedMinute+1)%60 ? '#212245' : '#757575')
                   .width('100%')
                   .height(30)
                   .textAlign(TextAlign.Center)
@@ -134,7 +165,6 @@ export struct DiaryTimePicker {
       }
     }
     .width(this.iwidth)
-    // .height(this.iheight)
     .backgroundColor(Color.White)
     .borderRadius(20)
     .shadow({
@@ -142,6 +172,5 @@ export struct DiaryTimePicker {
       type: ShadowType.COLOR,
       color: Color.Black
     })
-    // .padding({ bottom: 22})
   }
 }

+ 6 - 5
features/feature/src/main/ets/components/DiaryTitleItem.ets

@@ -7,19 +7,20 @@ export struct DiaryTitleItem {
   build() {
     Column() {
       Text(this.title)
-        .fontSize(20)
+        .fontSize(16)
+        .fontWeight(600)
     }
     .height(60)
     .width("100%")
-    .borderRadius(20)
-    .backgroundColor("#D7D7D7")
+    .borderRadius(12)
+    .backgroundColor('#F1F1F1')
     .alignItems(HorizontalAlign.Start)
     .justifyContent(FlexAlign.Center)
     .padding({
       left: 16,
       right: 16,
-      top: 8,
-      bottom: 8
+      top: 17,
+      bottom: 17
     })
     .margin({ top: 5, bottom: 5 })
     .onClick(this.onClickBack)

+ 49 - 0
features/feature/src/main/ets/components/DoubleConfirm.ets

@@ -0,0 +1,49 @@
+import { BasicType, yTToast } from "basic"
+
+@Builder
+export function DoubleConfirm(item: BasicType<undefined>) {
+  Column() {
+    if(item.text)
+    Text(item.text)
+      .fontSize(16)
+      .fontColor(Color.Black)
+      .margin({ bottom: 18 })
+    if(item.message)
+    Text(item.message)
+      .fontColor($r('sys.color.mask_secondary'))
+      .lineHeight(18)
+      .fontSize(13)
+      .margin({ bottom: 18 })
+    Row() {
+      Text('取消')
+        .fontSize(16)
+        .fontWeight(400)
+        .borderRadius(36)
+        .fontColor(Color.Black)
+        .backgroundColor('#F5F5F7')
+        .padding({ left: 36, top: 9, right: 36, bottom: 9})
+        .onClick(() => {
+          yTToast.hide()
+        })
+
+      Text('确定')
+        .fontSize(16)
+        .fontWeight(400)
+        .borderRadius(36)
+        .fontColor(Color.Black)
+        .padding({ left: 36, top: 9, right: 36, bottom: 9})
+        .linearGradient({
+          colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
+          angle: 110
+        })
+        .onClick(item.click)
+    }
+    .justifyContent(FlexAlign.SpaceBetween)
+    .width('100%')
+  }
+  // .height(160)
+  .width(280)
+  .padding({ top: 28, left: 32, right: 32, bottom: 20 })
+  .backgroundColor(Color.White)
+  .borderRadius(8)
+}

+ 14 - 49
features/feature/src/main/ets/models/index.ets

@@ -1,7 +1,7 @@
 /**
  * 日记详细数据模型
  */
-export class DiaryData{
+export interface DiaryData{
   // 富文本正文
   content?: string
   // 日记日期
@@ -14,52 +14,17 @@ export class DiaryData{
   title?: string
   // 用户id
   userId?: number
-
-  // 设置日记日期
-  setDiaryDate(date: Date){
-    // 转换为 YY-MM-DD HH:mm:ss 格式
-    const year = date.getFullYear().toString().slice(-2);
-    const month = (date.getMonth() + 1).toString().padStart(2, '0');
-    const day = date.getDate().toString().padStart(2, '0');
-    const hours = date.getHours().toString().padStart(2, '0');
-    const minutes = date.getMinutes().toString().padStart(2, '0');
-    const seconds = date.getSeconds().toString().padStart(2, '0');
-
-    this.diaryDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
-  }
-
-  // 解析日记日期
-  parseDiaryDate(): Date {
-    if (!this.diaryDate)
-      return new Date();
-
-    // 分解字符串
-    const parts = this.diaryDate.split(' ');
-    const datePart = parts[0];
-    const timePart = parts[1];
-
-    // 解析日期部分
-    const year = datePart.split('-').map(Number)[0];
-    const month = datePart.split('-').map(Number)[1];
-    const day = datePart.split('-').map(Number)[2];
-
-    // 解析时间部分,如果没有则默认为00:00:00
-    let hours = 0;
-    let minutes = 0;
-    let seconds = 0;
-
-    if (timePart) {
-      const timeComponents = timePart.split(':').map(Number);
-      hours = timeComponents[0] || 0;
-      minutes = timeComponents[1] || 0;
-      seconds = timeComponents[2] || 0;
-    }
-
-    // 处理两位数年份(2000年代)
-    const fullYear = year < 50 ? 2000 + year : 1900 + year;
-
-    // 创建 Date 对象(月份需要减1,因为 Date 中月份从0开始)
-    return new Date(fullYear, month - 1, day, hours, minutes, seconds);
-  }
-
+  // 时间
+  noteTime?: string
+}
+
+export enum PageStatus{
+  DIARY,
+  RECODE
+}
+
+// 常量
+export enum Constant{
+  // 历史搜索记录 key 值
+  HistoricalSearchRecords = 'HISTORICAL_SEARCH_RECORDS'
 }

+ 189 - 54
features/feature/src/main/ets/pages/DiarySearchPage.ets

@@ -1,79 +1,200 @@
-import { YTAvoid, yTRouter } from 'basic'
+import { IBestToast, YTAvoid, yTRouter } from 'basic'
 import { LengthMetrics } from '@kit.ArkUI'
+import { Constant, DiaryData } from '../models'
+import { DiaryViewModel } from '../viewModels/DiaryViewModel'
+import { DiaryTitleItem } from '../components/DiaryTitleItem'
 
+// 存储历史搜索记录
+PersistentStorage.persistProp<string[]>(Constant.HistoricalSearchRecords, [])
 
 @Component
 struct DiarySearchPage{
   @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
+  @State delModel: boolean = false
+  @StorageLink(Constant.HistoricalSearchRecords) historicalSearchRecords: string[] = []
+  @State keyWord: string = ''
+  @State searchList: DiaryData[] = []
+
+  private linearInfo: LinearGradientOptions = {
+    colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
+    angle: 150
+  }
+
+  async onSearch(){
+    if(!this.keyWord) {
+      IBestToast.show('请输入搜索内容')
+      return
+    }
+
+    const targetIndex: number = this.historicalSearchRecords.indexOf(this.keyWord)
+    if(targetIndex !== -1){
+      this.historicalSearchRecords.splice(targetIndex, 1)
+    }
+    this.historicalSearchRecords.unshift(this.keyWord)
+
+    this.searchList = await DiaryViewModel.diaryLogSearch(this.keyWord)
+    if(this.searchList.length === 0) {
+      IBestToast.show('没有搜索结果')
+    }
+  }
+
+  onDelSearch(index: number){
+    this.historicalSearchRecords.splice(index, 1)
+  }
+
+  /**
+   * 跳转日记详情
+   * @param id 日记 id (可选),没有 id 表示新增日记
+   */
+  routerDiaryPage(id?: number) {
+    const pageReadOnly = id ? true : false
+    yTRouter.pushPathByName("IncreaseDiaryPage", {
+      'pageReadOnly': pageReadOnly,
+      'id': id
+    } as Record<string, boolean | number>);
+  }
+
+  aboutToAppear(): void {
+  }
 
   build(){
     NavDestination(){
       Column(){
         // Title
-        Row({ space: 15 }){
+        Row(){
           Image($r("app.media.back"))
             .width(20)
             .aspectRatio(1)
             .onClick(() => {
               yTRouter.pop()
             })
+        }
+        .width('100%')
+        .alignItems(VerticalAlign.Top)
+        .justifyContent(FlexAlign.Start)
+        .padding({top: 10, bottom: 10})
+
+        // 搜索框
+        Row({space: 15}){
+          Image($r("app.media.Search"))
+            .width(18)
+            .aspectRatio(1)
 
-          // 搜索框
-          Row({space: 15}){
-            Image($r("app.media.Search"))
-              .width(20)
+          TextInput({ placeholder: "输入物品名称", text: $$this.keyWord })
+            .padding(0)
+            .fontSize(12)
+            .layoutWeight(1)
+            .borderRadius(0)
+            .placeholderColor('#ff777272')
+            .placeholderFont({ size: 16 })
+            .backgroundColor(Color.Transparent)
+            .caretColor('app.color.main_ac_color_dark')
+            .onSubmit(()=>{ this.onSearch() })
+
+
+          if(this.keyWord.length > 0) {
+            Image($r('app.media.close'))
+              .width(12)
               .aspectRatio(1)
-
-            TextInput({ placeholder: "输入物品名称" })
-              .backgroundColor(Color.Transparent)
-              .height('100%')
-              .layoutWeight(1)
-              .fontSize(12)
-              .borderRadius(0)
-
-              // .placeholderFont("水果片")
-              // .placeholderColor()
-              .padding(0)
-              .caretColor('app.color.main_ac_color_dark')
-              // .enabled(this.isEnable)
-              .onSubmit(()=>{
-                // this.submit(this.searchValue)
+              .padding(5)
+              .backgroundColor('#EBEBEB')
+              .onClick(() => {
+                this.keyWord = ''
+                this.searchList = []
               })
-
-            Row(){
-              Text("确认")
-            }
           }
-          .height(40)
-          .layoutWeight(1)
-          .borderRadius(5)
-          .backgroundColor("#D7D7D7")
-          .padding({ left: 10, right: 10 })
-          .alignItems(VerticalAlign.Center)
+
+          Text("确认")
+            .borderRadius(32)
+            .linearGradient(this.linearInfo)
+            .padding({ left: 17, top: 5.5, right: 17, bottom: 5.5 })
+            .onClick(() => { this.onSearch() })
+
         }
-        .width('100%')
+        .width("100%")
         .alignItems(VerticalAlign.Center)
-        .justifyContent(FlexAlign.SpaceBetween)
+        .border({ width: { bottom: 1 } })
+        .padding({ bottom: 21, top: 13 })
 
+        // 历史记录
         Column({space: 15}){
-          // 搜索历史
-          Row(){
-            Text("搜索历史")
+          if(this.searchList.length !== 0) {
+            Column(){
+              List(){
+                ForEach(this.searchList, (item: DiaryData, i: number) => {
+                  ListItem() {
+                    DiaryTitleItem({
+                      title: item.title,
+                      onClickBack: () => {
+                        this.routerDiaryPage(item.id)
+                      }
+                    })
+                  }
+                }, (item: DiaryData) => item.id?.toString())
+              }
+              .width("100%")
+              .height("100%")
+              .scrollBar(BarState.Off)
+            }
+            .width("100%")
+            .layoutWeight(1)
+            .padding({bottom: 20})
 
-            Image($r('app.media.del'))
-              .width(20)
-              .aspectRatio(1)
-          }
-          .width("100%")
-          .justifyContent(FlexAlign.SpaceBetween)
+          } else if(this.historicalSearchRecords.length > 0){
+            // 搜索历史
+            Row(){
+              Text("搜索历史")
+                .fontSize(16)
+                .fontColor(Color.Black)
+
+              Row(){
+                if(this.delModel) {
+                  Text("取消")
+                    .fontSize(14)
+                    .fontColor('#ff625a5a')
+                } else {
+                  Image($r('app.media.del'))
+                    .width(12)
+                    .aspectRatio(1)
+                }
+              }
+              .onClick(() => {
+                this.delModel = !this.delModel
+              })
+            }
+            .width("100%")
+            .justifyContent(FlexAlign.SpaceBetween)
 
-          if(false){
             Flex({wrap: FlexWrap.Wrap, space: { main: new LengthMetrics(8), cross: new LengthMetrics(8)}}){
-              ForEach(new Array(10).fill(0), (item: number, index: number) => {
-                this.keyWordItem("测试关键字")
+              ForEach(this.historicalSearchRecords, (item: string, index: number) => {
+                this.keyWordItem(item, index)
               })
             }
           } else {
+            // 搜索历史
+            Row(){
+              Text("搜索历史")
+                .fontSize(16)
+                .fontColor(Color.Black)
+
+              Row(){
+                if(this.delModel) {
+                  Text("取消")
+                    .fontSize(14)
+                    .fontColor('#ff625a5a')
+                } else {
+                  Image($r('app.media.del'))
+                    .width(12)
+                    .aspectRatio(1)
+                }
+              }
+              .onClick(() => {
+                this.delModel = !this.delModel
+              })
+            }
+            .width("100%")
+            .justifyContent(FlexAlign.SpaceBetween)
+
             Column({ space: 5 }){
               Image($r('app.media.Search'))
                 .width(80)
@@ -84,26 +205,40 @@ struct DiarySearchPage{
             .width("100%")
             .padding({ top: 100 })
             .alignItems(HorizontalAlign.Center)
-
           }
-
         }
         .width("100%")
-        .padding({ top: 22, left: 8, right: 8 })
-
+        .layoutWeight(1)
+        .padding({ top: 35 })
       }
-      .padding({ top: this.safeTop + 22, left: 8, right: 8 })
+      .padding({ top: this.safeTop, left: 24, right: 24 })
     }
   }
 
   @Builder
-  keyWordItem(keyWord: string, id?: number){
-    Row(){
+  keyWordItem(keyWord: string, index: number){
+    Row({space: 8}){
       Text(keyWord)
+        .fontSize(16)
+
+      if(this.delModel){
+        Image($r('app.media.close'))
+          .width(16)
+          .aspectRatio(1)
+          .padding(2)
+      }
     }
     .borderRadius(8)
-    .backgroundColor("#D7D7D7")
-    .padding({left: 8, right: 8, top: 8, bottom: 8})
+    .backgroundColor("#F7F7F7")
+    .padding({top: 8, bottom: 8, left: 25, right: this.delModel ? 5 : 25})
+    .onClick(() => {
+      if(this.delModel) {
+        this.onDelSearch(index)
+        return;
+      }
+      this.keyWord = keyWord
+      this.onSearch()
+    })
   }
 }
 

+ 359 - 111
features/feature/src/main/ets/pages/IncreaseDiaryPage.ets

@@ -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()
+    })
   }
 }
 

+ 1 - 1
features/feature/src/main/ets/utils/DateUtils.ets

@@ -25,7 +25,7 @@ function createDateInfo(date: Date): DateInfo {
 
 
 export class DateUtils {
-  static formatDateToCustomString(date: Date, needTime: boolean = true) {
+  static formatDateToCustomString(date: Date, needTime: boolean = true): string {
     // 转换为 YY-MM-DD HH:mm:ss 格式
     const year = date.getFullYear().toString();
     const month = (date.getMonth() + 1).toString().padStart(2, '0');

+ 55 - 19
features/feature/src/main/ets/view/DiaryView.ets

@@ -1,6 +1,7 @@
-import { IBestToast, YTAvoid, yTRouter, yTToast } from "basic"
+import { IBestToast, userInfo, UserInfo, YTAvoid, yTRouter, yTToast } from "basic"
 import { DiaryTitleItem } from "../components/DiaryTitleItem"
-import { DiaryData } from "../models"
+import { DoubleConfirm } from "../components/DoubleConfirm"
+import { DiaryData, PageStatus } from "../models"
 import { DateUtils } from "../utils/DateUtils"
 import { DiaryViewModel } from "../viewModels/DiaryViewModel"
 
@@ -11,17 +12,36 @@ import { DiaryViewModel } from "../viewModels/DiaryViewModel"
 export struct DiaryView {
   @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
   @State Vm: DiaryViewModel = new DiaryViewModel()
+  @StorageProp(UserInfo.KEY) @Watch('loginStateChanged')  userInfo: UserInfo = userInfo
+
+  private linearInfo: LinearGradientOptions = {
+    colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
+    angle: 110
+  }
+
+  /**
+   * 登录状态发生变化
+   */
+  loginStateChanged(){
+    console.log('登录状态发生变化 登录状态为 ' + this.userInfo.checkLogin())
+    const loginState = this.userInfo.checkLogin()
+    if(loginState){
+      this.reloadDiaryData()
+    } else {
+      this.Vm.diaryDataList = []
+      this.Vm.dateList = []
+    }
+  }
 
   /**
    * 跳转日记详情
    * @param id 日记 id (可选),没有 id 表示新增日记
    */
   routerDiaryPage(id?: number) {
-    const pageReadOnly = id ? true : false
     yTRouter.pushPathByName("IncreaseDiaryPage", {
-      'pageReadOnly': pageReadOnly,
-      'id': id
-    } as Record<string, boolean | number>);
+      'id': id,
+      'PageStatus': PageStatus.DIARY
+    } as Record<string, string | number>);
   }
 
   /**
@@ -29,12 +49,10 @@ export struct DiaryView {
    * @param index
    */
   decreaseDiary(index: number){
-    yTToast.doubleConfirm({
-      text: "删除日记",
-      message: "确定删除日记吗?",
+    yTToast.openToast(wrapBuilder(DoubleConfirm), {
+      text: "确定删除该篇日记吗?",
       click: async () => {
         yTToast.hide()
-
         let ans = await this.Vm.deleteDiaryLog(index)
         if(ans){
           IBestToast.show({ message: '删除了日记' })
@@ -81,7 +99,15 @@ export struct DiaryView {
       },
       onWillDisappear: () => {
         console.info("calendar onWillDisappear");
+      },
+      acceptButtonStyle: {
+        // backgroundColor: this.linearInfo
+        fontColor: Color.Black
+      },
+      cancelButtonStyle:{
+        fontColor: Color.Black
       }
+
     })
   }
 
@@ -123,12 +149,12 @@ export struct DiaryView {
       }
       .width("100%")
       .justifyContent(FlexAlign.SpaceBetween)
-      .padding({ bottom: 10 })
+      .padding({ top: this.safeTop + 22, left: 16, right: 16, bottom: 33 })
 
       // swiper
       Stack({ alignContent: Alignment.BottomEnd }) {
         // 日记列表
-        List({ space: 15 }) {
+        List({ space: 16 }) {
           ForEach(this.Vm.dateList, (groupTitle: string, index: number) => {
             ListItemGroup({
               header: this.DiaryHead(groupTitle),
@@ -160,8 +186,8 @@ export struct DiaryView {
 
         // 增加日记按钮
         Row() {
-          Image($r("app.media.add"))
-            .width(20)
+          Image($r("app.media.add_Img"))
+            .width(40)
             .aspectRatio(1)
         }
         .onClick(() => {
@@ -169,21 +195,31 @@ export struct DiaryView {
         })
         .width(40)
         .aspectRatio(1)
-        .border({
-          width: 1
-        })
         .borderRadius(20)
         .margin({ bottom: 16 })
-        .backgroundColor(Color.White)
         .alignItems(VerticalAlign.Center)
         .justifyContent(FlexAlign.Center)
+        .linearGradient(this.linearInfo)
       }
       .width("100%")
       .layoutWeight(1)
+      .backgroundColor(Color.White)
+      .padding({ left: 16, right: 16, top: 13 })
+      .borderRadius({
+        topLeft: 28, topRight: 28
+      })
     }
     .width("100%")
     .height("100%")
-    .padding({ top: this.safeTop + 22, left: 16, right: 16 })
+    .linearGradient(this.linearInfo)
+    .onVisibleAreaChange([0, 1], (isExpanding: boolean, currentRatio: number) => {
+      if(isExpanding) {
+        console.log("组件出来了")
+        this.reloadDiaryData()
+      } else {
+        console.log("组件退了")
+      }
+    })
   }
 
   // 日记时间组 - 头部组件

+ 284 - 154
features/feature/src/main/ets/view/RecodView.ets

@@ -1,49 +1,60 @@
-import { YTAvoid } from 'basic'
+import { AppStorageKeyCollect, IBestToast, YTAvoid, yTRouter } from 'basic'
 import { DateInfo } from '../models/DateInfo'
 import { RecodeViewModel } from '../viewModels/RecodeViewModel'
 import { DiaryDatePicker } from '../components/DiaryDatePicker'
 import { DiaryTimePicker } from '../components/DiaryTimePicker'
+import { DateUtils } from '../utils/DateUtils'
+import { DiaryData, PageStatus } from '../models'
 
 /**
  * 记录页面
  */
-
-/**
- * 日历组件
- * 1. 懒加载用上
- * 2. 纵向 swiper, 最右边(今天)作为头
- *
- * 加载方式
- * 1. 通过监听 swiper index 的变化来触发相应逻辑
- *
- * * 未通过日历进行跳转日期
- * 1. 向左滑动时, 如果日期剩余 < 10,则加载下一周 ( index == list.length - 10 )
- *
- * * 通过日历进行跳转日期
- * * *
- */
-
-// 小 《 《 《 大
 @Component
 export struct RecodView {
   @StorageProp(YTAvoid.SAFE_BOTTOM_KEY) bottom: number = 0
   @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
-  // ViewModel
   @State Vm: RecodeViewModel = new RecodeViewModel()
-
   @State heightList: number[] = []
 
   private linearInfo: LinearGradientOptions = {
     colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
-    angle: 150
-  }
-
-  aboutToAppear(): void {
-    this.Vm.selectedDateChange = this.selectDateChange
+    angle: 110
   }
 
   selectDateChange = (index: number) => {
     this.Vm.selectedDate = index
+    this.Vm.changeDataByIndex()
+    console.log('改变了选择的日期')
+  }
+
+  // 加载小记录数据列表
+  async loadDataList(targetDate: string) {
+    this.Vm.queryNoteList(targetDate)
+  }
+
+  async updateNoteTime(index: number, time: string) {
+    let currentNote: DiaryData = this.Vm.recodeList[index]
+    currentNote.noteTime = currentNote.noteTime?.split(' ')[0] + ' ' + time + ':00'
+    let ans = await this.Vm.updateNoteTime(currentNote)
+    if(ans) {
+      this.Vm.changeDataByIndex()
+      IBestToast.show('更改成功')
+    } else {
+      IBestToast.show('更改失败')
+    }
+  }
+
+  // 跳转至添加小记录页面
+  routerAddNote(id?: number) {
+    yTRouter.pushPathByName("IncreaseDiaryPage", {
+      'id': id,
+      'PageStatus': PageStatus.RECODE
+    } as Record<string, boolean | number | string>);
+  }
+
+  aboutToAppear(): void {
+    this.Vm.selectedDateChange = this.selectDateChange
+    this.loadDataList(DateUtils.formatDateToCustomString(new Date(), false))
   }
 
   build() {
@@ -78,6 +89,27 @@ export struct RecodView {
         this.Vm.showDatePicker = false
       })
 
+      // 时间选择器 - 使用区域变换实现
+      if(this.Vm.showTimePicker != -1) {
+        DiaryTimePicker({
+          timeStr: this.Vm.getTime(this.Vm.showTimePicker),
+          onConfirm: (time: string) => {
+            this.updateNoteTime(this.Vm.showTimePicker, time)
+            this.Vm.showTimePicker = -1
+          },
+          onCancel: () => {
+            this.Vm.showTimePicker = -1
+          }
+        })
+          .position({
+            // x: 5,
+            // y: 35
+            x: this.Vm.getPostion('x'),
+            y: this.Vm.getPostion('y')
+          })
+          .zIndex(100)
+      }
+
       // 主体内容
       Stack({alignContent: Alignment.TopEnd}){
         Column(){
@@ -95,8 +127,8 @@ export struct RecodView {
                 .borderRadius(10)
                 .linearGradient(this.Vm.selectedDate === index ? this.linearInfo : null)
 
-                // TODO 表示某天有数据
-                if(true) {
+                // TODO 表示某天有数据 - 暂无接口,待定
+                if(false) {
                   Row()
                     .width(6)
                     .height(6)
@@ -112,7 +144,7 @@ export struct RecodView {
                 top: 9,
               })
               .onClick(() => {
-                this.Vm.selectedDate = index
+                this.selectDateChange(index)
               })
             }, (item: DateInfo, index: number) => { return item.id.toString() })
           }
@@ -125,163 +157,253 @@ export struct RecodView {
           })
 
           // 记录内容主体
-          List({space: 10}) {
-            ListItem()
-              .height(20)
-              .onClick(() => {
-              this.Vm.showTimePicker = -1
-              this.Vm.showDatePicker = false
-            })
+          Stack({alignContent: Alignment.BottomEnd}){
+            List({space: 10}) {
+              ListItem()
+                .height(20)
+                .onClick(() => {
+                  this.Vm.showTimePicker = -1
+                  this.Vm.showDatePicker = false
+                })
 
-            ForEach(new Array(10).fill(0), (item: number, index: number) => {
-              ListItem(){
-                Stack({alignContent: Alignment.TopStart}){
-                  Row({space: 20}){
-                    // 时间 和 分隔线
-                    Column({space: 5}){
-                      Row(){
-                        Text("13:49")
-                          .fontSize(14)
-                          .padding({
-                            top: 5,
-                            left: 8,
-                            right: 8,
-                            bottom: 5
-                          })
-                          .fontWeight(400)
-                          .borderRadius(8)
-                          .fontColor(Color.Black)
-                          .linearGradient(this.linearInfo)
-                      }
-                      .width(54)
-                      .height(30)
-                      .alignItems(VerticalAlign.Center)
-                      .justifyContent(FlexAlign.Center)
-                      .onClick(() => {
-                        if(this.Vm.showTimePicker === index) {
-                          this.Vm.showTimePicker = -1
-                        } else {
-                          this.Vm.showTimePicker = index
-                          this.Vm.showDatePicker = false
-                        }
-                      })
-
-                      // 分隔线
-                      Column(){
-                        Row() {
-                          Row()
-                            .width(7)
-                            .aspectRatio(1)
-                            .borderRadius(4)
-                            .backgroundColor(Color.White)
+              ForEach(this.Vm.recodeList, (item: DiaryData, index: number) => {
+                ListItem(){
+                    Row({space: 20}){
+                      // 时间 和 分隔线
+                      Column({space: 5}){
+                        Row(){
+                          Text(this.Vm.getTime(index))
+                            .fontSize(14)
+                            .padding({
+                              top: 5,
+                              left: 8,
+                              right: 8,
+                              bottom: 5
+                            })
+                            .fontWeight(400)
+                            .borderRadius(8)
+                            .fontColor(Color.Black)
+                            .linearGradient(this.linearInfo)
                         }
-                        .width(10)
-                        .aspectRatio(1)
-                        .borderRadius(5)
-                        .backgroundColor('#B9FD2A')
+                        .width(54)
+                        .height(30)
                         .alignItems(VerticalAlign.Center)
                         .justifyContent(FlexAlign.Center)
+                        .onClick(() => {
+                          if(this.Vm.showTimePicker === index) {
+                            this.Vm.showTimePicker = -1
+                          } else {
+                            this.Vm.showTimePicker = index
+                            this.Vm.showDatePicker = false
+                          }
+                        })
 
-                        Row()
-                          .width(3)
-                          .backgroundColor('#E9E9EC')
-                          .layoutWeight(1)
+                        // 分隔线
+                        Column(){
+                          Row() {
+                            Row()
+                              .width(7)
+                              .aspectRatio(1)
+                              .borderRadius(4)
+                              .backgroundColor(Color.White)
+                          }
+                          .width(10)
+                          .aspectRatio(1)
+                          .borderRadius(5)
+                          .backgroundColor('#B9FD2A')
+                          .alignItems(VerticalAlign.Center)
+                          .justifyContent(FlexAlign.Center)
 
-                        Row() {
                           Row()
-                            .width(7)
-                            .aspectRatio(1)
-                            .borderRadius(4)
-                            .backgroundColor(Color.White)
+                            .width(3)
+                            .backgroundColor('#E9E9EC')
+                            .layoutWeight(1)
+
+                          Row() {
+                            Row()
+                              .width(7)
+                              .aspectRatio(1)
+                              .borderRadius(4)
+                              .backgroundColor(Color.White)
+                          }
+                          .width(10)
+                          .aspectRatio(1)
+                          .borderRadius(5)
+                          .backgroundColor('#B9FD2A')
+                          .alignItems(VerticalAlign.Center)
+                          .justifyContent(FlexAlign.Center)
                         }
-                        .width(10)
-                        .aspectRatio(1)
-                        .borderRadius(5)
-                        .backgroundColor('#B9FD2A')
-                        .alignItems(VerticalAlign.Center)
-                        .justifyContent(FlexAlign.Center)
+                        .width(30)
+                        .height(this.heightList[index] + 15)
                       }
-                      .width(30)
-                      .height(this.heightList[index] + 15)
-                    }
-                    // .layoutWeight(1)
+                      // .layoutWeight(1)
 
-                    // 标题 和 内容
-                    Column({space: 5}){
-                      Row(){
-                        Text("生活日记")
-                          .fontSize(14)
-                          .fontWeight(600)
-                          .padding({
-                            top: 5,
-                            left: 8,
-                            right: 8,
-                            bottom: 5
-                          })
-                      }
-                      .height(30)
-                      .alignItems(VerticalAlign.Center)
-                      .justifyContent(FlexAlign.Center)
+                      // 标题 和 内容
+                      Column({space: 5}){
+                        Row(){
+                          Text(item.title)
+                            .fontSize(14)
+                            .fontWeight(600)
+                            .padding({
+                              top: 5,
+                              left: 8,
+                              right: 8,
+                              bottom: 5
+                            })
+                        }
+                        .height(30)
+                        .alignItems(VerticalAlign.Center)
+                        .justifyContent(FlexAlign.Center)
 
-                      // 内容
-                      Column({space: 8}){
-                        Text("内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容")
-                          .fontSize(12)
-                          .fontColor('#212245')
-                          .opacity(0.5)
+                        // 内容
+                        Column({space: 8}){
+                          Text(item.content)
+                            .fontSize(12)
+                            .fontColor('#212245')
+                            .opacity(0.5)
 
-                        // 图片显示
-                        Scroll(){
-                          Row({space: 5}){
-                            ForEach(new Array(5).fill(0), (item: number, index: number) => {
-                              Image('https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg')
-                                .width(100)
-                                .height(150)
-                                .borderRadius(12)
-                            })
+                          // 图片显示
+                          Scroll(){
+                            Row({space: 5}){
+                              ForEach(item.imageUrls, (url: string, index: number) => {
+                                Image(url)
+                                  .width(100)
+                                  .height(150)
+                                  .borderRadius(12)
+                              })
+                            }
                           }
+                          .scrollable(ScrollDirection.Horizontal)
+                          .scrollBar(BarState.Off)
+
                         }
-                        .scrollable(ScrollDirection.Horizontal)
-                        .scrollBar(BarState.Off)
+                        .alignItems(HorizontalAlign.Start)
+                        .justifyContent(FlexAlign.Start)
+                        .onAreaChange((_o: Area, _n: Area) => {
+                          this.heightList[index] = _n.height as number
+                        })
 
+                        Blank().height(15)
                       }
+                      .layoutWeight(1)
                       .alignItems(HorizontalAlign.Start)
                       .justifyContent(FlexAlign.Start)
-                      .onAreaChange((_o: Area, _n: Area) => {
-                        this.heightList[index] = _n.height as number
+                      .onClick(() => {
+                        this.routerAddNote(item.id!)
+                        this.Vm.showDatePicker = false
+                        this.Vm.showTimePicker = -1
                       })
-
-                      Blank().height(15)
+                      .gesture(
+                        LongPressGesture()
+                          .onAction(() => {
+                            console.log("长按了哦")
+                            this.Vm.onDelRecode(item.id!)
+                          })
+                      )
                     }
-                    .layoutWeight(1)
-                    .alignItems(HorizontalAlign.Start)
-                    .justifyContent(FlexAlign.Start)
-                  }
-                  .onClick(() => {
-                    this.Vm.showTimePicker = -1
-                    this.Vm.showDatePicker = false
-                  })
+                    .onClick(() => {
+                      this.Vm.showTimePicker = -1
+                      this.Vm.showDatePicker = false
+                    })
+                    .onAreaChange((_o: Area, _n: Area) => {
+                      console.log('位置信息' + JSON.stringify(_n.globalPosition))
+                      let postion = this.Vm.postionList
+                      postion[index] = _n.globalPosition
+                      this.Vm.postionList = postion
+                    })
+                }
+              })
 
+              // 空数据页面
+              if(this.Vm.recodeList.length === 0) {
+                ListItem(){
+                  Column({space: 12}){
+                    Row({space: 8}){
+                      Text("+")
+                      Text("去添加")
+                    }
+                    .borderRadius(8)
+                    .linearGradient(this.linearInfo)
+                    .alignItems(VerticalAlign.Center)
+                    .justifyContent(FlexAlign.Center)
+                    .border({width: 1, color: Color.Black})
+                    .padding({ left: 16, top: 12, right: 16, bottom: 12})
 
-                  // 时间选择器
-                  if(this.Vm.showTimePicker == index) {
-                    DiaryTimePicker()
-                      .offset({
-                        x: 5,
-                        y: 35
-                      })
+                    Text("暂无记录~")
+                      .fontSize(14)
+                      .fontWeight(400)
                   }
+                  .width("100%")
+                  .height("100%")
+                  .alignItems(HorizontalAlign.Center)
+                  .padding({ top: '30%'})
+                  // .justifyContent(FlexAlign.Center)
                 }
+                .layoutWeight(1)
+                .width("100%")
               }
+            }
+            .width("100%")
+            .height("100%")
+            .scrollBar(BarState.Off)
+            .padding({top: 10})
+            .onScrollIndex(() => {
+              this.Vm.showTimePicker = -1
+            })
+
+            // 增加日记按钮
+            Row() {
+              Image($r("app.media.add_Img"))
+                .width("100%")
+                .aspectRatio(1)
+            }
+            .onClick(() => {
+              this.routerAddNote()
             })
+            .width(40)
+            .aspectRatio(1)
+            .borderRadius(20)
+            .margin({ bottom: 16 })
+            .alignItems(VerticalAlign.Center)
+            .justifyContent(FlexAlign.Center)
+            .linearGradient(this.linearInfo)
           }
           .width("100%")
           .layoutWeight(1)
-          .padding({ left: 24, right: 24, top: 10})
-          .scrollBar(BarState.Off)
+          .padding({
+            bottom: 20, left: 24, right: 24
+          })
+
+          // 记录内容主体
+          // Stack({ alignContent: Alignment.BottomEnd }){
+          //
+          //   // 增加日记按钮
+          //   Row() {
+          //     Image($r("app.media.add"))
+          //       .width(20)
+          //       .aspectRatio(1)
+          //   }
+          //   .onClick(() => {
+          //     this.routerAddNote()
+          //   })
+          //   .width(40)
+          //   .aspectRatio(1)
+          //   .borderRadius(20)
+          //   .padding(8)
+          //   // .border({ width: 1 })
+          //   .margin({ bottom: 16 })
+          //   // .backgroundColor(Color.White)
+          //   .alignItems(VerticalAlign.Center)
+          //   .justifyContent(FlexAlign.Center)
+          //   .linearGradient(this.linearInfo)
+          // }
+          // .width("100%")
+          // .layoutWeight(1)
+
+
         }
 
-        // 时间选择器
+        // 日期选择器
         if(this.Vm.showDatePicker) {
           DiaryDatePicker({
             selectedDate: this.Vm.weekLoop.getData(this.Vm.swiperCurrentIndex).id,
@@ -308,6 +430,14 @@ export struct RecodView {
       colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
       angle: 150
     })
+    .onVisibleAreaChange([0, 1], (isExpanding: boolean, currentRatio: number) => {
+      if(isExpanding) {
+        console.log("组件出来了")
+        this.Vm.changeDataByIndex()
+      } else {
+        console.log("组件退了")
+      }
+    })
 
   }
 }

+ 62 - 12
features/feature/src/main/ets/viewModels/DiaryViewModel.ets

@@ -1,8 +1,10 @@
-import { IBestToast, YTLog, yTToast } from "basic"
+import { YTLog, YTUserRequest } from "basic"
 import { DiaryApi } from "../apis/DiaryApi"
 import { DiaryData } from "../models"
-import { DateUtils } from "../utils/DateUtils"
-import { HashMap } from "@kit.ArkTS"
+import { util } from "@kit.ArkTS"
+import { fileIo as fs } from "@kit.CoreFileKit"
+import { image } from "@kit.ImageKit"
+
 
 export class DiaryViewModel{
   // 日记列表
@@ -54,9 +56,11 @@ export class DiaryViewModel{
    * @param keyWord 日记标题关键字
    * @returns
    */
-  async diaryLogSearch(keyWord: string) {
-    const result: DiaryData[] = await DiaryApi.diaryLogSearch(keyWord)
+  static async diaryLogSearch(keyWord: string): Promise<DiaryData[]> {
+    let encode = encodeURIComponent(keyWord)
+    const result: DiaryData[] = await DiaryApi.diaryLogSearch(encode)
     YTLog.info(`查询日记搜索结果 ${JSON.stringify(result)}`)
+    return result
   }
 
   /**
@@ -71,6 +75,7 @@ export class DiaryViewModel{
     }
     const result = await DiaryApi.updateDiaryLog(params)
     YTLog.info(`修改日记结果 ${result}`)
+    return result
   }
 
   /**
@@ -92,12 +97,57 @@ export class DiaryViewModel{
   static async saveDiaryLog(params: DiaryData) {
     const result = await DiaryApi.saveDiaryLog(params)
     YTLog.info(`新增日记结果 ${result}`)
-    // if(result) {
-    //   IBestToast.show("删除成功")
-    //   yTToast.hide()
-    // } else {
-    //   IBestToast.show("删除失败")
-    //   yTToast.hide()
-    // }
+    return result
+  }
+
+  // 上传图片
+  static async uploadImage(conText: Context, filePath: string) {
+    const promise = new Promise<string>(async (resolve, reject) => {
+      let uri = DiaryViewModel.copyToSync(conText, filePath) as string
+      uri = await DiaryViewModel.manualCompression(uri, conText)
+      console.log("uri " + uri)
+      YTUserRequest.uploadFile(conText, uri, (url) => {
+        resolve(url)
+      })
+    })
+    const url = await promise
+    return url
+  }
+
+  // 图片处理
+  static copyToSync(conText: Context, uri: string) {
+    // 切割图片路径
+    let temp: string[] = uri.split("/")
+
+    // 使用时间戳拼接文件名 ( 仅仅是为了获取文件后缀名 )
+    let fileName: string = Date.now() + "." + temp[temp.length-1].split(".")[1]
+
+    // 根据上下文对象获取 cache 文件的路径,将其于 filename 进行拼接
+    let filePath: string = conText.cacheDir + "/" + fileName
+
+    // 获取图片路径的文件指针,模式设置为只读
+    const file = fs.openSync(uri, fs.OpenMode.READ_ONLY)
+
+    // 将文件拷贝至 cache 的路径
+    fs.copyFileSync(file.fd, filePath)
+
+    // 需要拿到复制到 Cache 中的文件名
+    return filePath;
+  }
+
+  /**
+   * 手动压缩图片
+   */
+  static async manualCompression(filePath: string, context: Context) {
+    const imageSourceApi: image.ImageSource = image.createImageSource(filePath);
+    let packOpts: image.PackingOption = { format: "image/jpeg", quality: 20 };
+    const imagePackerApi = image.createImagePacker()
+    const buffer = await imagePackerApi.packing(imageSourceApi, packOpts)
+    const imagePath = context.cacheDir + '/' + util.generateRandomUUID() + '.jpeg'
+    const file = fs.openSync(imagePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE)
+    fs.writeSync(file.fd, buffer)
+    fs.closeSync(file)
+    fs.unlinkSync(filePath)
+    return imagePath
   }
 }

+ 129 - 2
features/feature/src/main/ets/viewModels/RecodeViewModel.ets

@@ -1,5 +1,7 @@
-import { IBestToast, yTToast } from 'basic';
+import { AppStorageKeyCollect, IBestToast, yTToast } from 'basic';
 import { DiaryApi } from '../apis/DiaryApi';
+import { DoubleConfirm } from '../components/DoubleConfirm';
+import { DiaryData } from '../models';
 import { BasicDataSource } from '../models/BasicDataSource';
 import { DateInfo } from '../models/DateInfo';
 import { DateUtils } from '../utils/DateUtils';
@@ -17,8 +19,12 @@ export class RecodeViewModel{
   swiperCurrentIndex: number = 0
   // 日历中被选中的日期
   selectedDate: number = 0
+  // 当天小记录的数据
+  recodeList: DiaryData[] = []
+  // 记录时间组件的位置信息
+  postionList: Position[] = []
 
-  // 外部传入, 用于修改日历中选中的日期 ( 直接在本类中修改 UI 无法进行刷新WW )
+  // 外部传入, 用于修改日历中选中的日期 ( 直接在本类中修改 UI 无法进行刷新WWW
   selectedDateChange: (index: number) => void = (index: number) => {}
 
   /**
@@ -107,6 +113,127 @@ export class RecodeViewModel{
     this.selectedDateChange(targetIndex)
   }
 
+  // 获取日历中被选中的日期
+  getSelectedDate(): string {
+    const ans = this.weekLoop.getData(this.selectedDate).id
+    const date = DateUtils.formatDateToCustomString(ans, false)
+    console.log("日历中被选中的日期" + date)
+    return date
+  }
+
+  /**
+   * 根据当前日历中选择的日期刷新数据
+   */
+  changeDataByIndex(){
+    const date = this.getSelectedDate()
+    this.queryNoteList(date)
+    console.log("当天小记录" + JSON.stringify(this.recodeList))
+  }
+
+  /**
+   * 时间选择器用 - 动态更改时间选择器的位置
+   * @param type 需要的坐标类型(x/y)
+   * @returns 坐标值
+   */
+  getPostion(type: 'x'|'y'): Length{
+    // 获取屏幕高度
+    const screenHeight = AppStorage.get<number>(AppStorageKeyCollect.SCREEN_HEIGHT)
+
+    if(type == 'x') {
+      return this.postionList[this.showTimePicker].x!
+    } else {
+      const y = this.postionList[this.showTimePicker].y! as number
+      // 屏幕剩余高度过小
+      if(screenHeight && y > screenHeight - 300) {
+        return y - 260
+      }
+      return y - 20
+    }
+  }
+
+  getTime(index: number){
+    let time = this.recodeList[index].noteTime?.split(' ')[1]
+    let time1 = time?.split(':')
+    time1?.pop()
+    return time1?.join(':')
+  }
+
+  /**
+   * 在首页通过长按记录执行的删除的逻辑
+   * @param id
+   */
+  onDelRecode(id: number){
+      yTToast.openToast(wrapBuilder(DoubleConfirm), {
+        text: "确定删除该这条记录吗?",
+        click: async () => {
+          yTToast.hide()
+          let ans = await this.deleteNote(id)
+          if(ans){
+            IBestToast.show({ message: '删除了记录' })
+            this.changeDataByIndex()
+          }
+        }
+      })
+
+  }
+
   // 请求函数
 
+  // 删除生活小记录
+  async deleteNote(id: number){
+    const ans = await DiaryApi.deleteNote(id)
+    return ans;
+  }
+
+  // 查询生活小记录
+  async queryNoteList(nowTime: string){
+    const result: DiaryData[] = await DiaryApi.queryNoteList(nowTime)
+
+    result.forEach(item => {
+      item.diaryDate = item.noteTime
+    })
+
+    result.sort((a, b) => {
+      return new Date(a.noteTime!).getTime() - new Date(b.noteTime!).getTime()
+    })
+
+    this.recodeList = result
+
+    console.log('查询生活小记录' + JSON.stringify(result))
+
+    // this.dateList[0] = result[0].noteTime?.split(' ')[0] ?? ' '
+    // for (let index = 0; index < result.length; index++) {
+    //   if(result[index].diaryDate != this.dateList[this.dateList.length-1]){
+    //     this.dateList.push(result[index].noteTime?.split(' ')[0] ?? ' ')
+    //   }
+    // }
+    //
+    // console.log('时间列表' + JSON.stringify(this.dateList))
+    // let dateStr = this.getSelectedDate()
+    // this.todayNote = this.totalNote.filter(item => item.noteTime?.split(' ')[0] == dateStr)
+  }
+
+  // 修改生活小记录时间
+  async updateNoteTime(params: DiaryData){
+    const ans = await DiaryApi.updateNoteTime(params)
+    return ans;
+  }
+
+  // 查询生活小记录对象
+  static async queryNoteById(id: number){
+    const ans: DiaryData = await DiaryApi.queryNoteById(id)
+    return ans;
+  }
+
+  // 编辑生活小记录
+  static async updateNote(params: DiaryData){
+    const ans = await DiaryApi.updateNote(params)
+    return ans;
+  }
+
+  // 添加生活小记录
+  static async saveNote(params: DiaryData){
+    const ans = await DiaryApi.saveNote(params)
+    return ans;
+  }
 }

+ 1 - 0
features/feature/src/main/resources/base/media/Diary_DateOpen.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755755766785" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5050" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M112.593358 228.860385c41.35999 0 767.301594 0 795.827277 0 37.003775 0 64.532759 27.609825 42.885739 54.892191-17.330714 21.871123-367.19501 458.883245-397.113413 496.180709-19.661805 24.495904-66.530252 24.081465-86.208431 0-21.951965-26.850531-373.59579-465.531666-398.023132-497.297137C52.043307 259.377422 71.837118 228.860385 112.593358 228.860385z" p-id="5051"></path></svg>

+ 4 - 0
features/feature/src/main/resources/base/media/Diary_close.svg

@@ -0,0 +1,4 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="design-iconfont">
+  <path fill="#EBEBEB" d="M12 2A10 10 0 1 0 12 22A10 10 0 1 0 12 2Z"/>
+  <path d="M14.8 9L12 11.8966M12 11.8966L15 15M12 11.8966L9.2 9M12 11.8966L9 15" stroke="#BDBDBD" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 4 - 1
features/feature/src/main/resources/base/media/Search.svg

@@ -1 +1,4 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755065843022" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6253" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M415.59889935 818.40673751c-103.69194019 0-207.38388041-39.48836529-286.31642412-118.42090898-157.86508737-157.87981634-157.86508737-414.78248979 0-572.66230613 157.85035841-157.85035841 414.76776082-157.90927428 572.64757719 0 157.86508737 157.87981634 157.86508737 414.78248979 0 572.66230613-78.93254368 78.93254368-182.63921287 118.42090898-286.33115307 118.42090898z m0-725.22496474c-82.09927197 0-164.21327292 31.25487175-226.70828746 93.74988629-125.00475803 125.00475803-125.00475803 328.44127481 0 453.44603281 125.01948701 124.9753001 328.41181686 125.03421596 453.43130386 0 125.00475803-125.00475803 125.00475803-328.44127481 0-453.44603281-62.5097435-62.49501453-144.60901547-93.74988627-226.7230164-93.74988629z" fill="#2c2c2c" p-id="6254"></path><path d="M973.48804978 1013.69813456c-10.78160515 0-21.57793927-4.10938229-29.79670383-12.34287584L658.31757585 715.95203069c-16.46698708-16.46698708-16.46698708-43.14114955 0-59.60813666s43.14114955-16.46698708 59.60813665 0l285.37377009 285.38849908c16.46698708 16.46698708 16.46698708 43.14114955 0 59.60813663a42.07329932 42.07329932 0 0 1-29.81143281 12.35760482z" fill="#2c2c2c" p-id="6255"></path></svg>
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 86 86" class="design-iconfont">
+  <rect x="14.3585" y="12.5641" width="57.2833" height="57.2833" rx="28.6417" stroke="#898989" stroke-width="10.8"/>
+  <path d="M63.2891 64.5L73.7541 75.2777" stroke="#898989" stroke-width="10.8" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 12 - 1
features/feature/src/main/resources/base/media/add.svg

@@ -1 +1,12 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755066395823" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7241" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M511.81 118c22.66 0 41.013 18.364 41.013 41.025l-0.001 311.96h312.153c22.661 0 41.025 18.356 41.025 41.017 0 22.66-18.364 41.013-41.025 41.013H552.822v311.957c0 22.663-18.351 41.028-41.011 41.028-22.662 0-41.017-18.365-41.017-41.028l-0.001-311.957H159.028c-22.663 0-41.028-18.352-41.028-41.013 0-22.661 18.365-41.017 41.028-41.017h311.765v-311.96c0-22.661 18.356-41.025 41.018-41.025z" fill="#191F39" p-id="7242"></path></svg>
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" class="design-iconfont">
+  <rect width="48" height="48" rx="24" fill="url(#4hppupeu9__paint0_linear_4970_74986)"/>
+  <rect x="16" y="22" width="15" height="3" rx="1.5" fill="#222345"/>
+  <rect x="22" y="32" width="16" height="3" rx="1.5" transform="rotate(-90 22 32)" fill="#222345"/>
+  <path d="M40.2467 28.0552C40.1477 28.872 40.0982 29.2804 40.0945 29.31C39.3902 34.8671 35.9063 38.2787 30.3355 38.8663C30.3059 38.8694 29.8756 38.9124 29.0151 38.9985V38.9985C28.9752 39.0025 28.9553 39.0045 28.9354 39.0064C25.6532 39.332 22.3468 39.332 19.0646 39.0064C19.0447 39.0045 19.0169 39.0017 18.9612 38.9961V38.9961C18.7263 38.9726 18.6089 38.9609 18.5186 38.9505C13.0115 38.3154 8.65621 33.9908 7.98228 28.4883C7.97124 28.3982 7.95994 28.2927 7.93735 28.0819V28.0819C7.92689 27.9843 7.92166 27.9355 7.91673 27.8883C7.6467 25.3037 7.65731 22.6975 7.94837 20.1152C7.95369 20.0681 7.95914 20.0208 7.97004 19.9263L8.04387 19.2865C8.1587 18.2913 8.21612 17.7937 8.36129 17.1746C9.15298 13.7988 12.3169 10.3369 15.608 9.24538C16.2115 9.04523 16.4945 8.98648 17.0603 8.86897C19.4162 8.37972 21.916 8 24 8C25.145 8 26.4154 8.11461 27.7185 8.29902C32.772 9.0142 35.2988 9.37179 37.7283 12.0588C40.1578 14.7458 40.2614 17.3335 40.4687 22.509C40.4889 23.0145 40.5 23.5134 40.5 24C40.5 25.4782 40.3978 26.8092 40.2467 28.0552Z" stroke="#222345" stroke-width="2"/>
+  <defs>
+    <linearGradient id="4hppupeu9__paint0_linear_4970_74986" x1="0" y1="0" x2="53.5679" y2="40.6656" gradientUnits="userSpaceOnUse">
+      <stop stop-color="#B9FD2A"/>
+      <stop offset="1" stop-color="#F5FD6D"/>
+    </linearGradient>
+  </defs>
+</svg>

BIN
features/feature/src/main/resources/base/media/add_Img.png


+ 10 - 1
features/feature/src/main/resources/base/media/calendar.svg

@@ -1 +1,10 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755056081010" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6298" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M725.333333 170.666667h74.709334C864.853333 170.666667 917.333333 223.189333 917.333333 288.096V799.893333C917.333333 864.757333 864.832 917.333333 800.042667 917.333333H223.957333C159.146667 917.333333 106.666667 864.810667 106.666667 799.904V288.106667C106.666667 223.242667 159.168 170.666667 223.957333 170.666667H298.666667v-32a32 32 0 0 1 64 0v32h298.666666v-32a32 32 0 0 1 64 0v32z m0 64v32a32 32 0 0 1-64 0v-32H362.666667v32a32 32 0 0 1-64 0v-32h-74.709334A53.354667 53.354667 0 0 0 170.666667 288.096V799.893333A53.301333 53.301333 0 0 0 223.957333 853.333333h576.085334A53.354667 53.354667 0 0 0 853.333333 799.904V288.106667A53.301333 53.301333 0 0 0 800.042667 234.666667H725.333333z m-10.666666 224a32 32 0 0 1 0 64H309.333333a32 32 0 0 1 0-64h405.333334zM586.666667 618.666667a32 32 0 0 1 0 64H309.333333a32 32 0 0 1 0-64h277.333334z" fill="#000000" p-id="6299"></path></svg>
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="design-iconfont">
+  <g clip-path="url(#59jtqozsx__clip0_4976_75684)">
+    <path d="M8 5V3M16 5V3M9 16H15M6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20Z" stroke="#212245" stroke-width="2" stroke-linecap="round"/>
+  </g>
+  <defs>
+    <clipPath id="59jtqozsx__clip0_4976_75684">
+      <path fill="#fff" d="M0 0H24V24H0z"/>
+    </clipPath>
+  </defs>
+</svg>

BIN
features/feature/src/main/resources/base/media/close.png


+ 0 - 1
features/feature/src/main/resources/base/media/close.svg

@@ -1 +0,0 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755073797641" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8374" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z" p-id="8375"></path></svg>

+ 10 - 1
features/feature/src/main/resources/base/media/del.svg

@@ -1 +1,10 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755072542687" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7312" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M202.666667 256h-42.666667a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.666667v565.333333a53.333333 53.333333 0 0 0 53.333333 53.333334h384a53.333333 53.333333 0 0 0 53.333333-53.333334V352a32 32 0 0 1 64 0v469.333333c0 64.8-52.533333 117.333333-117.333333 117.333334H320c-64.8 0-117.333333-52.533333-117.333333-117.333334V256z m224-106.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z m-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z m170.666666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z" fill="#000000" p-id="7313"></path></svg>
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="design-iconfont">
+  <g clip-path="url(#necc0pqe1__clip0_4980_81502)">
+    <path d="M6.59961 8.4H7.79961M7.79961 8.4H17.3996M7.79961 8.4V16.8C7.79961 17.1183 7.92604 17.4235 8.15108 17.6485C8.37612 17.8736 8.68135 18 8.99961 18H14.9996C15.3179 18 15.6231 17.8736 15.8481 17.6485C16.0732 17.4235 16.1996 17.1183 16.1996 16.8V8.4M9.59961 8.4V7.2C9.59961 6.88174 9.72604 6.57652 9.95108 6.35147C10.1761 6.12643 10.4813 6 10.7996 6H13.1996C13.5179 6 13.8231 6.12643 14.0481 6.35147C14.2732 6.57652 14.3996 6.88174 14.3996 7.2V8.4M10.7996 11.4V15M13.1996 11.4V15" stroke="#000" stroke-opacity=".5" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
+  </g>
+  <defs>
+    <clipPath id="necc0pqe1__clip0_4980_81502">
+      <path fill="#fff" d="M0 0H24V24H0z"/>
+    </clipPath>
+  </defs>
+</svg>

+ 12 - 1
features/feature/src/main/resources/base/media/photoAlbum.svg

@@ -1 +1,12 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755075747828" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9441" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M876.613818 861.090909a11.636364 11.636364 0 0 0 11.636364-11.636364v-674.90909a11.636364 11.636364 0 0 0-11.636364-11.636364h-721.454545a11.636364 11.636364 0 0 0-11.636364 11.636364v674.90909a11.636364 11.636364 0 0 0 11.636364 11.636364h721.454545z m0 69.818182h-721.454545a81.454545 81.454545 0 0 1-81.454546-81.454546v-674.90909a81.454545 81.454545 0 0 1 81.454546-81.454546h721.454545a81.454545 81.454545 0 0 1 81.454546 81.454546v674.90909a81.454545 81.454545 0 0 1-81.454546 81.454546z" p-id="9442"></path><path d="M129.256727 700.206545l-47.197091-51.432727 182.574546-167.493818a81.454545 81.454545 0 0 1 113.314909 3.072l158.673454 162.327273a11.636364 11.636364 0 0 0 15.965091 0.651636l94.138182-81.803636a81.454545 81.454545 0 0 1 107.822546 0.861091l191.627636 171.962181-46.615273 51.968-191.650909-171.985454a11.636364 11.636364 0 0 0-15.383273-0.116364l-94.138181 81.803637a81.454545 81.454545 0 0 1-111.685819-4.538182l-158.696727-162.327273a11.636364 11.636364 0 0 0-16.174545-0.442182l-182.574546 167.493818z" p-id="9443"></path><path d="M686.545455 337.454545m-58.181819 0a58.181818 58.181818 0 1 0 116.363637 0 58.181818 58.181818 0 1 0-116.363637 0Z" p-id="9444"></path></svg>
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="design-iconfont">
+  <g clip-path="url(#qnjwvfk81__clip0_4996_75116)">
+    <path d="M1.20364 8.58219C1.54832 5.17362 4.27706 2.54264 7.68904 2.23347C9.16308 2.0999 10.7001 2 12 2C13.2999 2 14.8369 2.0999 16.311 2.23347C19.7229 2.54264 22.4517 5.17362 22.7964 8.58219C22.9158 9.76383 23 10.9639 23 12C23 13.0361 22.9158 14.2362 22.7964 15.4178C22.4517 18.8264 19.7229 21.4574 16.311 21.7665C14.8369 21.9001 13.2999 22 12 22C10.7001 22 9.16308 21.9001 7.68904 21.7665C4.27707 21.4574 1.54832 18.8264 1.20364 15.4178C1.08416 14.2362 1 13.0361 1 12C1 10.9639 1.08416 9.76383 1.20364 8.58219Z" stroke="#212245" stroke-width="2"/>
+    <path d="M5 17L7.91343 14.0234L11 17.5L15 13L19 17" stroke="#212245" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+    <path fill="#212245" d="M16 5A2 2 0 1 0 16 9A2 2 0 1 0 16 5Z"/>
+  </g>
+  <defs>
+    <clipPath id="qnjwvfk81__clip0_4996_75116">
+      <path fill="#fff" d="M0 0H24V24H0z"/>
+    </clipPath>
+  </defs>
+</svg>

+ 8 - 0
products/entry/src/main/ets/entryability/EntryAbility.ets

@@ -112,8 +112,16 @@ export default class EntryAbility extends UIAbility {
         name: 'category'
       })
       AppStorage.setOrCreate<preferences.Preferences>('category', preference)
+
+
+      windowClass.on('windowSizeChange', size => {
+        YTBreakPoint.setBreakPoint(size.width)
+        AppStorage.setOrCreate(AppStorageKeyCollect.SCREEN_WIDTH, px2vp(size.width))
+        AppStorage.setOrCreate(AppStorageKeyCollect.SCREEN_HEIGHT, px2vp(size.height))
+      })
     });
 
+
   }
 
   onWindowStageDestroy(): void {

+ 8 - 8
products/entry/src/main/ets/pages/Index.ets

@@ -11,18 +11,18 @@ struct Index {
   contentList: BasicType<undefined>[] = [
     {
       text: '记录',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      src: $r('app.media.Recode_Icon_0'),
+      acSrc: $r('app.media.Recode_Icon_1')
     },
     {
       text: '日记',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      src: $r('app.media.Diary_Icon_0'),
+      acSrc: $r('app.media.Diary_Icon_1')
     },
     {
       text: '我的',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      src: $r('app.media.My_Icon_0'),
+      acSrc: $r('app.media.My_Icon_1')
     }
   ]
   tabsController: TabsController = new TabsController()
@@ -88,8 +88,8 @@ struct Index {
       Text(item.text)
         .fontSize($r('[basic].float.page_text_font_size_10'))
         .lineHeight(16)
-        .fontColor(this.currentIndex == item.index ? $r('[basic].color.main_ac_color_dark') :
-        $r('[basic].color.main_na_color'))
+        .fontColor(this.currentIndex == item.index ? $r('[basic].color.main_blank') :
+        $r('[basic].color.mask_color'))
 
     }
     .margin({ top: 5 })

BIN
products/entry/src/main/resources/base/media/Diary_Icon_0.png


BIN
products/entry/src/main/resources/base/media/Diary_Icon_1.png


BIN
products/entry/src/main/resources/base/media/My_Icon_0.png


BIN
products/entry/src/main/resources/base/media/My_Icon_1.png


BIN
products/entry/src/main/resources/base/media/Recode_Icon_0.png


BIN
products/entry/src/main/resources/base/media/Recode_Icon_1.png