فهرست منبع

首页添加女性特殊期描述

cc12458 1 سال پیش
والد
کامیت
c679a750b3
3فایلهای تغییر یافته به همراه25 افزوده شده و 4 حذف شده
  1. 6 3
      miniprogram/pages/home/home.ts
  2. 1 1
      miniprogram/pages/home/home.wxml
  3. 18 0
      miniprogram/pages/home/request.ts

+ 6 - 3
miniprogram/pages/home/home.ts

@@ -6,7 +6,7 @@ const { shared, Easing, timing } = wx.worklet
 const offset = shared(0);
 
 // pages/home/home.ts
-import { getPatients, healthReportMethod, healthIndexMethod, getSolarTerms, getShortScienceList } from "./request";
+import { getPatients, healthReportMethod, healthIndexMethod, getSolarTerms, getShortScienceList, getPatientDescription } from "./request";
 import { toCertificationPage } from "./router";
 import { useLocation } from "../../lib/use/use-location";
 
@@ -38,12 +38,13 @@ Page({
   },
   onShareTimeline() {
     return {
-      title: `健康为基,从容赏生活之美`, 
+      title: `健康为基,从容赏生活之美`,
     }
   },
   data: {
     patients: [] as (App.Patient.Model & { isDefault: 'Y' | 'N' })[],
     patient: null as App.Patient.Model | null,
+    patientDescription: '',
 
     healthId: '',
     healthReport: { data: null, message: '' },
@@ -262,12 +263,14 @@ Page({
     }
   },
 
-  observerPatient(model: { patientId: string, sex: 0 | 1 }) {
+  observerPatient(model: { patientId: string, sex: '0' | '1' }) {
     wx.setStorageSync('patientId', model.patientId);
     this._getHealthReport();
     this._getAbnormalHealthIndex();
     const patientIcon = { 0: 'gender-male', 1: 'gender-female' }[model.sex];
     const patientIconColor = { 0: '#0f40f5', 1: '#E560B3' }[model.sex];
     this.setData({ patientIcon, patientIconColor })
+
+    getPatientDescription(model).then((patientDescription) => { this.setData({ patientDescription }) })
   },
 })

+ 1 - 1
miniprogram/pages/home/home.wxml

@@ -8,7 +8,7 @@
         <t-icon color="{{patientIconColor}}" name="{{patientIcon}}" size="14px"></t-icon>
         <text class="user-name">{{patient.name}}</text>
         <text class="user-age">{{patient.age}}岁</text>
-        <text wx:if="{{false}}" class="user-description" overflow="fade" max-lines="1"></text>
+        <text class="user-description" overflow="fade" max-lines="1">{{patientDescription}}</text>
         <image wx:if="{{patients.length > 1}}" class="user-select-icon" src="../../assets/icon/arrows-down.icon.png" mode="aspectFit" />
       </block>
     </view>

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

@@ -13,6 +13,24 @@ export function getPatients(id?: string) {
   return Post('/mobileAccountManage/getPatsByAid', {}, { transform })
 }
 
+export async function getPatientDescription(patient: { sex: '0' | '1'; patientId: string; }) {
+  if (patient.sex === '0') return '';
+  try {
+    const transform = ({ data }: any) => data;
+    const dict = await Get('/dict/getDicts', { transform });
+    const options = dict.find((item: any) => item.dictType === 'women_special_period').items;
+    const { womenSpecialPeriod } = await Post('/patientInfoManage/getPatientInfoDetail', {}, { transform });
+    if (womenSpecialPeriod) return womenSpecialPeriod.split(',').map((k: string) => {
+      const [key, value] = k.split(':')
+      const label = options.find((option: any) => option.dictValue === key).dictLabel;
+      return value ?? label !== '无' ? label : ''
+    }).filter(Boolean).join(',')
+  } catch (error) {
+    return ''
+  }
+
+}
+
 export function healthReportMethod() {
   const transform = ({ data }: AnyObject) => {
     if (Array.isArray(data?.conditProgram?.types)) {