From fb2d23f6f5caeb35de55c4b1d576e4ac4023c380 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Thu, 11 Jun 2026 11:11:31 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E6=A0=A1=E5=87=86=E5=AE=8C?= =?utf8?q?=E6=88=90=E6=9C=89=E6=95=88=E6=9C=9F=E6=98=BE=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/BPCalibSecondDoneView.h | 1 + .../bloodpressure/include/BPEntryView.h | 2 + .../nativeui/bloodpressure/include/BPModel.h | 2 + .../src/BPCalibSecondDoneView.cpp | 21 +++++++++ .../bloodpressure/src/BPEntryView.cpp | 43 +++++++++++++++++++ .../nativeui/bloodpressure/src/BPMainView.cpp | 9 ++++ .../nativeui/bloodpressure/src/BPModel.cpp | 19 ++++++++ 7 files changed, 97 insertions(+) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPCalibSecondDoneView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPCalibSecondDoneView.h index 85f1c3aa7..25341c785 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPCalibSecondDoneView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPCalibSecondDoneView.h @@ -14,6 +14,7 @@ public: ~BPCalibSecondDoneView(); static BPCalibSecondDoneView *GetInstance(); UIViewGroup *InitView(); + void UpdateExpiryText(); private: UIViewGroup *group_{nullptr}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPEntryView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPEntryView.h index 6858450c5..e66264a22 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPEntryView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPEntryView.h @@ -26,12 +26,14 @@ public: ~BPEntryView(); static BPEntryView *GetInstance(); UIViewGroup *InitView(); + void RefreshView(); void InitCalibratedView(); void InitCalibrationExpiredView(); void InitNotCalibratedView(); void InitPageIndicator(); private: + void ResetContent(); void InitCalibExpiringSoonBar(); void InitNoCalibratedBar(); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPModel.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPModel.h index 554db623a..c43be740c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPModel.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPModel.h @@ -39,6 +39,8 @@ public: /** 校准完成后写入当前时间戳与校准值 */ bool SaveCalibrationResult(); int32_t GetCalibrationTimestamp() const; + /** 校准到期日 YYYY/MM/DD,无效时返回 "--" */ + std::string GetCalibrationExpiryDateText() const; /** 校准有效期(秒),默认 30 天,与 fd230 needMeasure 一致 */ void SetCalibrationTimeoutSec(uint32_t seconds); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPCalibSecondDoneView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPCalibSecondDoneView.cpp index f55999b13..4f1f52f96 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPCalibSecondDoneView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPCalibSecondDoneView.cpp @@ -1,7 +1,9 @@ #include "bloodpressure/include/BPCalibSecondDoneView.h" #include "bloodpressure/include/BPEntryView.h" #include "bloodpressure/include/BPMainPresenter.h" +#include "bloodpressure/include/BPModel.h" #include "bloodpressure/include/BPViewClickIds.h" +#include "securec.h" #include "uicomponents/UIComponents.h" namespace OHOS { @@ -31,6 +33,24 @@ BPCalibSecondDoneView::~BPCalibSecondDoneView() { BPCalibSecondDoneView *BPCalibSecondDoneView::GetInstance() { return g_instance; } +void BPCalibSecondDoneView::UpdateExpiryText() { + if (timeLabel_ == nullptr) { + return; + } + BPModel *model = BPModel::GetInstance(); + if (model == nullptr) { + timeLabel_->SetText("有效期至:----"); + return; + } + char textBuf[48] = {0}; + if (sprintf_s(textBuf, sizeof(textBuf), "有效期至:%s", + model->GetCalibrationExpiryDateText().c_str()) < 0) { + timeLabel_->SetText("有效期至:----"); + return; + } + timeLabel_->SetText(textBuf); +} + UIViewGroup *BPCalibSecondDoneView::InitView() { group_ = new UIViewGroup(); group_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); @@ -54,6 +74,7 @@ UIViewGroup *BPCalibSecondDoneView::InitView() { group_->Add(timeLabel_); group_->Add(noteLabel_); group_->Add(confirmButton_); + UpdateExpiryText(); return group_; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPEntryView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPEntryView.cpp index dc9cc3ce2..cbb9828b3 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPEntryView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPEntryView.cpp @@ -46,6 +46,49 @@ BPEntryView::~BPEntryView() { BPEntryView *BPEntryView::GetInstance() { return g_pBPEntryView; } +void BPEntryView::ResetContent() { + if (group_ != nullptr) { + group_->RemoveAll(); + } + delete titleLabel_; + delete instructionLabel_; + delete instructionButton_; + delete measureButton_; + delete imageView_; + delete calibWarnBg_; + delete calibWarnIcon_; + delete calibWarnLabel_; + delete dotEntry_; + delete dotHistory_; + titleLabel_ = nullptr; + instructionLabel_ = nullptr; + instructionButton_ = nullptr; + measureButton_ = nullptr; + imageView_ = nullptr; + calibWarnBg_ = nullptr; + calibWarnIcon_ = nullptr; + calibWarnLabel_ = nullptr; + dotEntry_ = nullptr; + dotHistory_ = nullptr; +} + +void BPEntryView::RefreshView() { + if (group_ == nullptr) { + return; + } + ResetContent(); + currentState_ = BPModel::GetInstance()->GetCurrentstate(); + if (currentState_ == BP_CALIB_STATE_VALID) { + InitCalibratedView(); + } else if (currentState_ == BP_CALIB_STATE_EXPIRED) { + InitCalibrationExpiredView(); + } else { + InitNotCalibratedView(); + } + InitPageIndicator(); + group_->Invalidate(); +} + UIViewGroup *BPEntryView::InitView() { group_ = new UIViewGroup(); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainView.cpp index 8e7ada6c6..069966d22 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainView.cpp @@ -94,6 +94,9 @@ void BPMainView::OnStop() { bool BPMainView::ChangeBPEntryView(int16_t thisView, int16_t type) { UNUSED(type); if (group_[thisView] != nullptr) { + if (entryView_ != nullptr) { + entryView_->RefreshView(); + } return true; } entryView_ = new BPEntryView(); @@ -302,6 +305,9 @@ bool BPMainView::ChangeBPCalibFirstDoneView(int16_t thisView, int16_t type) { bool BPMainView::ChangeBPCalibSecondDoneView(int16_t thisView, int16_t type) { UNUSED(type); if (group_[thisView] != nullptr) { + if (calibSecondDoneView_ != nullptr) { + calibSecondDoneView_->UpdateExpiryText(); + } return true; } calibSecondDoneView_ = new BPCalibSecondDoneView(); @@ -375,6 +381,9 @@ void BPMainView::ChangeView(int16_t hideView, int16_t showView, int16_t type) { historyView_->RefreshView(); historyView_->StartArrowAnimation(); } + if (showView == BP_ENTRY_VIEW && entryView_ != nullptr) { + entryView_->RefreshView(); + } RefreshCurrentView(); container_->Invalidate(); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPModel.cpp index dc34646e4..059f8fb93 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPModel.cpp @@ -172,6 +172,25 @@ bool BPModel::SaveCalibrationResult() { int32_t BPModel::GetCalibrationTimestamp() const { return calibrationTimestamp_; } +std::string BPModel::GetCalibrationExpiryDateText() const { + if (calibrationTimestamp_ <= 0) { + return "--"; + } + uint32_t expiryTs = + static_cast(calibrationTimestamp_) + calibrationTimeoutSec_; + struct tm timeInfo = {0}; + time_t ts = static_cast(expiryTs); + if (localtime_r(&ts, &timeInfo) == nullptr) { + return "--"; + } + char buf[32] = {0}; + if (sprintf_s(buf, sizeof(buf), "%04d/%02d/%02d", timeInfo.tm_year + 1900, + timeInfo.tm_mon + 1, timeInfo.tm_mday) < 0) { + return "--"; + } + return std::string(buf); +} + /** 设置校准有效期(秒),默认 30 天,与 fd230 needMeasure 一致 */ void BPModel::SetCalibrationTimeoutSec(uint32_t seconds) { if (seconds > 0) { -- 2.17.1