|
@@ -14,7 +14,6 @@ export struct MoodLogTab {
|
|
|
date: DateUtils.formatTimestamp(Date.now()),
|
|
date: DateUtils.formatTimestamp(Date.now()),
|
|
|
timestamp: Date.now()
|
|
timestamp: Date.now()
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
moodOptions: MoodItem[] = [
|
|
moodOptions: MoodItem[] = [
|
|
|
{ type: 'good', url: $r('app.media.mood_vary_good'), title: '心情很好' },
|
|
{ type: 'good', url: $r('app.media.mood_vary_good'), title: '心情很好' },
|
|
|
{ type: 'ordinary', url: $r('app.media.mood_ordinary'), title: '心情一般' },
|
|
{ type: 'ordinary', url: $r('app.media.mood_ordinary'), title: '心情一般' },
|
|
@@ -30,7 +29,7 @@ export struct MoodLogTab {
|
|
|
const existing = this.moodLogs.find(m => m.date === todayStr);
|
|
const existing = this.moodLogs.find(m => m.date === todayStr);
|
|
|
if (existing) {
|
|
if (existing) {
|
|
|
// this.todayMood = { ...existing };
|
|
// this.todayMood = { ...existing };
|
|
|
- this.todayMood = JSON.parse(JSON.stringify( existing))
|
|
|
|
|
|
|
+ this.todayMood = JSON.parse(JSON.stringify(existing))
|
|
|
this.selectedType = existing.type;
|
|
this.selectedType = existing.type;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -40,20 +39,20 @@ export struct MoodLogTab {
|
|
|
this.todayMood.type = option.type;
|
|
this.todayMood.type = option.type;
|
|
|
this.todayMood.mood = option.title;
|
|
this.todayMood.mood = option.title;
|
|
|
this.todayMood.timestamp = Date.now();
|
|
this.todayMood.timestamp = Date.now();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Update list
|
|
// Update list
|
|
|
const index = this.moodLogs.findIndex(m => m.date === this.todayMood.date);
|
|
const index = this.moodLogs.findIndex(m => m.date === this.todayMood.date);
|
|
|
if (index >= 0) {
|
|
if (index >= 0) {
|
|
|
// this.moodLogs[index] = { ...this.todayMood };
|
|
// this.moodLogs[index] = { ...this.todayMood };
|
|
|
- this.moodLogs[index] =JSON.parse(JSON.stringify(this.todayMood))
|
|
|
|
|
|
|
+ this.moodLogs[index] = JSON.parse(JSON.stringify(this.todayMood))
|
|
|
} else {
|
|
} else {
|
|
|
// this.moodLogs.unshift({ ...this.todayMood });
|
|
// this.moodLogs.unshift({ ...this.todayMood });
|
|
|
this.moodLogs.unshift(JSON.parse(JSON.stringify(this.todayMood)))
|
|
this.moodLogs.unshift(JSON.parse(JSON.stringify(this.todayMood)))
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Sort
|
|
// Sort
|
|
|
this.moodLogs.sort((a, b) => b.timestamp - a.timestamp);
|
|
this.moodLogs.sort((a, b) => b.timestamp - a.timestamp);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
promptAction.showToast({ message: '保存成功' });
|
|
promptAction.showToast({ message: '保存成功' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -86,7 +85,7 @@ export struct MoodLogTab {
|
|
|
.border({ width: 3, color: this.selectedType === item.type ? '#FFCC00' : 'transparent' })
|
|
.border({ width: 3, color: this.selectedType === item.type ? '#FFCC00' : 'transparent' })
|
|
|
.onClick(() => this.saveMood(item))
|
|
.onClick(() => this.saveMood(item))
|
|
|
})
|
|
})
|
|
|
- }.width('100%').margin({ top: 30 }) .justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
|
|
+ }.width('100%').margin({ top: 30 }).justifyContent(FlexAlign.SpaceBetween)
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.padding(16)
|
|
.padding(16)
|
|
@@ -94,7 +93,7 @@ export struct MoodLogTab {
|
|
|
// Mood List
|
|
// Mood List
|
|
|
Column() {
|
|
Column() {
|
|
|
Text('心情记录').fontSize(18).fontWeight(FontWeight.Medium).margin({ bottom: 16 })
|
|
Text('心情记录').fontSize(18).fontWeight(FontWeight.Medium).margin({ bottom: 16 })
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
List() {
|
|
List() {
|
|
|
ForEach(this.moodLogs, (item: MoodLogItem) => {
|
|
ForEach(this.moodLogs, (item: MoodLogItem) => {
|
|
|
ListItem() {
|
|
ListItem() {
|
|
@@ -122,6 +121,13 @@ export struct MoodLogTab {
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.height('100%')
|
|
.height('100%')
|
|
|
- .backgroundColor('#F5F7FA')
|
|
|
|
|
|
|
+ .linearGradient({
|
|
|
|
|
+ angle: 112,
|
|
|
|
|
+ colors: [
|
|
|
|
|
+ ['#FFF1EA', 0],
|
|
|
|
|
+ ['#E5E9FC', 0.34],
|
|
|
|
|
+ ['#FBE3EB', 0.74]
|
|
|
|
|
+ ]
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|