diff --git a/entry/src/main/ets/pages/PersonalInformation.ets b/entry/src/main/ets/pages/PersonalInformation.ets index a8e4ff37674d0686a08ca5675312be0b42dbdc1d..39d79af4317497a4dfd40a6d97735cfe3400066a 100644 --- a/entry/src/main/ets/pages/PersonalInformation.ets +++ b/entry/src/main/ets/pages/PersonalInformation.ets @@ -203,6 +203,7 @@ export struct PersonalInformation { let month = date.getMonth() + 1; let day = date.getDate(); this.currentDate = year + '-' + month + '-' + day; + this.selectTime = new Date(`${this.currentDate}T08:30:00`); if (!this.birthDate) { this.birthDate = CommonUtils.getBirthDateValue(year, month, day); } @@ -276,7 +277,7 @@ export struct PersonalInformation { onItemClick: () => { this.getUIContext().showDatePickerDialog({ start: new Date('1925-1-1'), - end: new Date(this.currentDate), + end: new Date('2055-1-1'), selected: this.selectTime, lunarSwitch: true, showTime: false, @@ -361,7 +362,8 @@ export struct PersonalInformation { .padding(16) } .onBackPressed(() => { - if (!this.isSaved && this.isEdit) { + let inputIsEdit: boolean | undefined = AppStorage.get('inputIsEdit'); + if (!this.isSaved && (this.isEdit || inputIsEdit)) { this.getUIContext().showAlertDialog({ message: $r('app.string.tips'), autoCancel: true, @@ -384,6 +386,7 @@ export struct PersonalInformation { this.signature = ''; this.hobbies = ''; AppStorage.setOrCreate('isEdit', false); + AppStorage.setOrCreate('inputIsEdit', false); this.pathStack.pop(); } } diff --git a/entry/src/main/ets/view/TextInputComponent.ets b/entry/src/main/ets/view/TextInputComponent.ets index 1d586bac99f0b7ecbbf17819856bba60109afc9d..cea74d7b7b6201ae7f0267436cc2b16c07404499 100644 --- a/entry/src/main/ets/view/TextInputComponent.ets +++ b/entry/src/main/ets/view/TextInputComponent.ets @@ -38,7 +38,13 @@ export default struct TextInputComponent { .height(48) .enableKeyboardOnFocus(false) .onChange((value: string) => { - this.text = value; + if (this.text !== value) { + this.text = value; + AppStorage.setOrCreate('inputIsEdit', true); + } + if (!value) { + AppStorage.setOrCreate('inputIsEdit', false); + } }) } .margin({ top: 12 })