ソースを参照

给唐古加跳转按钮

张田田 1 週間 前
コミット
d311faea3e

+ 21 - 0
miniprogram/pages/home/home.scss

@@ -572,6 +572,27 @@ $scale: 0.5;
   height: 32rpx;
 }
 
+.chronic-container {
+  margin-top: 10px;
+  padding: 0px 9px;
+}
+
+.chronic-card {
+  background: #4165f4;
+  color: #fff;
+  font-weight: bold;
+  font-size: 32rpx;
+  border-radius: 12rpx;
+  padding: 20rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.chronic-title {
+  text-align: center;
+}
+
 // 详细内容
 .detail-image {
   width: 120rpx;

+ 43 - 0
miniprogram/pages/home/home.ts

@@ -24,6 +24,8 @@ import {
   getPatientDescription,
   getNotDealLists,
   getCareList,
+  getChronicDiseaseManageVisible,
+  getChronicDiseaseManageUrl,
 } from "./request";
 import { toCertificationPage, toChats } from "./router";
 import { Post } from "../../lib/request/method";
@@ -40,6 +42,12 @@ Page({
     NoteTitle: "",
     isShowComplete: true,
     careList: [],
+    // 慢病管理入口:showFlag 控制按钮显示,url 为 H5 跳转链接
+    // 慢病管理:两个独立接口分别取值
+    // 接口一 isShowChronicDisease 控制按钮显示;接口二 chronicDiseaseUrl 为 H5 链接
+    // TODO(临时): 真实接口一就绪后改回 false,由接口返回值控制显示
+    isShowChronicDisease: true,
+    chronicDiseaseUrl: "",
     displayList: [] as {
       id: number;
       conditioningProgramType: string;
@@ -459,6 +467,12 @@ Page({
     }
     // 加载健康宣教的文章
     this.loadScienceList(true);
+    // 接口一:判断慢病管理按钮是否显示
+    getChronicDiseaseManageVisible()
+      .then((showFlag) => {
+        this.setData({ isShowChronicDisease: showFlag });
+      })
+      .catch(() => {});
     if (!this.data._loaded) {
       getSolarTerms()
         .then((solarTerms) => {
@@ -690,6 +704,35 @@ Page({
   toSciencePage() {
     wx.navigateTo({ url: `/module/article/pages/science-list/science-list` });
   },
+  // 跳转慢病管理 H5(点击时按需获取链接,已获取则直接跳转)
+  async goChronicDisease() {
+    let url = this.data.chronicDiseaseUrl;
+    if (!url) {
+      wx.showLoading({ title: "加载中" });
+      try {
+        url = await getChronicDiseaseManageUrl();
+        this.setData({ chronicDiseaseUrl: url });
+      } catch (error: any) {
+        wx.hideLoading();
+        wx.showToast({
+          title: error?.errMsg || "加载失败",
+          icon: "none",
+        });
+        return;
+      }
+      wx.hideLoading();
+    }
+    if (!url) {
+      wx.showToast({ title: "暂无链接", icon: "none" });
+      return;
+    }
+    wx.navigateTo({
+      url: "/module/article/pages/science-info/science-info",
+      success: (res) => {
+        res.eventChannel?.emit?.("load", { title: "慢病管理", url });
+      },
+    });
+  },
   async toReportPage() {
     // const { patient } = await getPatients(/*this.data.patientId*/);
     if (!this.data.patient) await toCertificationPage();

+ 7 - 0
miniprogram/pages/home/home.wxml

@@ -133,6 +133,13 @@
       </view>
     </view>
 
+    <!-- 慢病管理入口:接口一 isShowChronicDisease 为真时显示,点击跳转 H5 -->
+    <view class="chronic-container" wx:if="{{isShowChronicDisease}}" bindtap="goChronicDisease">
+      <view class="chronic-card">
+        <text class="chronic-title">慢病管理</text>
+      </view>
+    </view>
+
     <view class="science-list-wrapper" wx:if="{{scienceList.length}}">
       <view class="list-title" bind:tap="toSciencePage">
         <view class="missionary">{{i18n.healthTeach.title}}</view>

+ 37 - 0
miniprogram/pages/home/request.ts

@@ -28,6 +28,43 @@ export function getCareList() {
   );
 }
 
+// 慢病管理入口(拆成两个接口):
+// 1. 判断首页按钮是否显示;2. 点击时获取 H5 跳转链接。
+// TODO: 接口路径与返回字段需与后端确认,以下为占位实现
+
+// 接口一:判断慢病管理按钮是否显示
+export function getChronicDiseaseManageVisible() {
+  return Post(
+    "/chronicDiseaseManage/checkShow",
+    {},
+    {
+      transform({ data }: AnyObject) {
+        const raw = data?.showFlag;
+        // 兼容后端可能的取值:true / 1 / "1" / "Y" 视为显示,其余隐藏
+        return (
+          raw === true || raw === 1 || raw === "1" || raw === "Y" || raw === "y"
+        );
+      },
+    }
+  );
+}
+
+// 接口二:获取慢病管理 H5 跳转链接
+// 后端返回完整的、带鉴权参数的链接,小程序直接打开即可
+export function getChronicDiseaseManageUrl() {
+  return Post(
+    "/chronicDiseaseManage/getUrl",
+    {},
+    {
+      transform({ data }: AnyObject) {
+        // 兼容:直接返回字符串,或 { url } / { h5Url } / { link }
+        if (typeof data === "string") return data;
+        return data?.url || data?.h5Url || data?.link || "";
+      },
+    }
+  );
+}
+
 export function getPatients(id?: string) {
   id ??= wx.getStorageSync("patientId");
   const transform = ({ data }: AnyObject) => {