Przeglądaj źródła

注册优化、调理方案样式优化、上一次治疗反馈改为治疗备注

张田田 6 miesięcy temu
rodzic
commit
660cecfe4a

+ 4 - 0
miniprogram/app.config.ts

@@ -2,12 +2,16 @@ import { getAccountInfoSync } from "./lib/wx/open-api";
 
 const miniProgram = getAccountInfoSync();
 const env = miniProgram.envVersion;
+console.log("env",env)
 let host = "wx2.hzliuzhi.com";
 if (env === "trial") {
   host = "test.hzliuzhi.com";
 } else if (env === "develop") {
+  console.log("develop")
+  // host = "wx2.hzliuzhi.com";
   host = "wx.hzliuzhi.com:4433";
 }
+console.log("host",host)
 export const Base_URL = `https://${host}/manager/fdhb-mobile`;
 export const Upload_URL = `https://${host}/manager/file`;
 

+ 1 - 1
miniprogram/module/care/pages/care/verifyRecord.wxml

@@ -13,7 +13,7 @@
         <text style="color:black">{{item.operateBy}}</text>
       </view>
       <view class="record-row" wx:if="{{item.feedback}}">
-        <text class="label">上一次治疗反馈:</text>
+        <text class="label">治疗备注:</text>
         <text style="color:black">{{item.feedback}}</text>
       </view>
       <view class="record-row" wx:if="{{item.acuPointNames}}">

+ 1 - 19
miniprogram/module/chats/components/questionnaire/questionnaire.ts

@@ -31,7 +31,6 @@ interface MessageType {
 Component({
   lifetimes: {
     attached: function () {
-
       let isAnalysis: number;
       isAnalysis = wx.getStorageSync("isAnalysis");
       if (isAnalysis === 3 || isAnalysis === 4) {
@@ -210,29 +209,12 @@ Component({
             payload: { title: "" },
           });
         } else if (this.data.messageType === 2) {
-          // todo 如果是对话管家 调用dialogueManage/dialog 这个接口
-          // 如果是健康评估 调用其他接口  但后端返回的数据是一样的
-
           let data: any = {};
           const res = await Post(
             `/dialogueManage/dialogTreat`,
             this.data._next
           );
           data = res.data;
-          // if (isAnalysis === 3) {
-          //   const res = await Post(`/dialogueManage/dialog`, this.data._next);
-          //   data = res.data;
-          // } else {
-          //   const res = await Post(
-          //     `/dialogueManage/dialogTreat`,
-          //     this.data._next
-          //   );
-          //   data = res.data;
-          // }
-          // const { data } = await Post(
-          //   `/dialogueManage/dialog`,
-          //   this.data._next
-          // );
 
           data.nextQuestions?.forEach((question: any, index: number) => {
             // isAnalysis 2是随访  3健康管家 4健康评估
@@ -342,7 +324,7 @@ Component({
             payload: { title: error.errMsg ?? `图像检测失败,请重新拍摄上传` },
           });
           this.triggerEvent("to");
-          setTimeout(() => this._start(), 20);
+          // setTimeout(() => this._start(), 20);
         } else {
           const date = Date.now();
           this._createMessage({

+ 8 - 30
miniprogram/module/user/pages/user-certification/user-certification.ts

@@ -18,7 +18,6 @@ Component({
   behaviors: [PageContainerBehavior, DictionariesBehavior, tickleBehavior],
   lifetimes: {
     attached() {
-    
       const channel = this.getOpenerEventChannel();
       channel.on("navigateBack", (data) => {
         this.setData(data);
@@ -37,6 +36,7 @@ Component({
   data: {
     loading: false,
     verifying: false,
+    submitting: false,
     model: {} as AnyObject,
     name: "",
     cardno: "",
@@ -103,6 +103,8 @@ Component({
       }
     },
     async onSubmit(event: WechatMiniprogram.FormSubmit) {
+      if (this.data.submitting) return;
+      this.setData({ submitting: true });
       const data = { ...this.data.model, ...event.detail.value };
       data.phone = this.data.model.phone;
       const submitBtn = this.selectComponent("#submitBtn");
@@ -110,26 +112,9 @@ Component({
         if (submitBtn) submitBtn.resetState();
         return getTickleContext.call(this).showWarnMessage("请获取手机号码");
       }
-      // if (!data.cardno) data.cardno = this.data.cardno;
-      // if (data.sex == null) data.sex = this.data.sex;
       if (!data.agemust) {
         data.agemust = this.data.privacyContract.agree ? "Y" : "N";
       }
-
-      // if (!data.name)
-      //   return getTickleContext.call(this).showWarnMessage("请输入姓名");
-      // if (data.cardno?.length !== 18)
-      //   return getTickleContext
-      //     .call(this)
-      //     .showWarnMessage("请输入正确的身份证号");
-      // if (data.sex === "1" && !data.womenSpecialPeriod)
-      //   return getTickleContext
-      //     .call(this)
-      //     .showWarnMessage("请至少选择一项女性特殊期");
-      // if (!data.height)
-      //   return getTickleContext.call(this).showWarnMessage("请输入身高");
-      // if (!data.weight)
-      //   return getTickleContext.call(this).showWarnMessage("请输入体重");
       if (data.agemust === "N") {
         if (submitBtn) submitBtn.resetState();
         this.setData({ "privacyContract.show": true });
@@ -140,22 +125,13 @@ Component({
       }
       wx.showLoading({ title: "保存中" });
       try {
-        // const { patientId } = await createUserInfoMethod(<any>data);
         const { patientId } = await createPhoneRegister(<any>data);
-        // await wx.navigateBack();
-        // if (patientId) this.getOpenerEventChannel().emit('update', { patientId });
         wx.setStorageSync("patientId", patientId);
-        // wx.redirectTo({
-        //   url: `/module/chats/pages/index/index?component=questionnaire`,
-        // });
-        // wx.redirectTo({
-        //   url: `/pages/home/home`,
-        // });
         // 回到相应的页面
         if (this.data.type === "home") {
           wx.navigateTo({
-            url: '/pages/home/home',
-          })
+            url: "/pages/home/home",
+          });
         } else {
           wx.navigateBack();
         }
@@ -165,8 +141,10 @@ Component({
           submitBtn.resetState();
         }
         getTickleContext.call(this).showErrorMessage(error.errMsg);
+      } finally {
+        this.setData({ submitting: false });
+        wx.hideLoading();
       }
-      wx.hideLoading();
     },
   },
 });

+ 45 - 11
miniprogram/pages/mine/mine.ts

@@ -9,6 +9,7 @@ Page({
     userInfo: null,
     tabbarValue: "/pages/mine/mine",
     phone: "",
+    loaded: false,
     mineOrderList: [
       {
         url: "../../assets/icon/obligation@3x.png",
@@ -40,6 +41,38 @@ Page({
       },
     ],
   },
+  // 读取缓存,若存在则直接渲染并返回已读到的数据
+  hydrateFromCache() {
+    const cachedPatient = (wx.getStorageSync("patient") || null) as App.Patient.Model | null;
+    const cachedPhone = (wx.getStorageSync("patientPhone") || "") as string;
+    if (cachedPatient || cachedPhone) {
+      this.setData({
+        patient: cachedPatient || null,
+        phone: cachedPhone || "",
+        loaded: true,
+      });
+    }
+    return { cachedPatient, cachedPhone } as {
+      cachedPatient: App.Patient.Model | null;
+      cachedPhone: string;
+    };
+  },
+  // 写入缓存
+  syncCache(patient: App.Patient.Model | null, phone: string) {
+    try {
+      wx.setStorageSync("patient", patient || null);
+      wx.setStorageSync("patientPhone", phone || "");
+      wx.setStorageSync("patientName", patient?.name);
+    } catch {}
+  },
+  // 轻量对比(避免 JSON 深比较):患者用 patientId 或 name,对比手机号字符串
+  isDifferent(cachedPatient: App.Patient.Model | null, newPatient: App.Patient.Model | null, cachedPhone: string, newPhone: string) {
+    const cachedId = cachedPatient?.patientId || "";
+    const newId = newPatient?.patientId || "";
+    const cachedName = cachedPatient?.name || "";
+    const newName = newPatient?.name || "";
+    return cachedId !== newId || cachedName !== newName || (cachedPhone || "") !== (newPhone || "");
+  },
   // 获取各状态调理记录数量
   async getRecordCount() {
     console.log("获取各状态调理记录数量");
@@ -81,19 +114,17 @@ Page({
     }
     this.getRecordCount();
     try {
+      // 1) 先读缓存渲染,避免初始闪烁
+      const { cachedPatient, cachedPhone } = this.hydrateFromCache();
+
+      // 2) 并行请求接口,完成后轻量对比,有变更再更新与回写缓存
       wx.showLoading({ title: "加载中" });
-      const { patient } = await getPatients();
-      const res = await getPatientPhone();
-      console.log(res, "获取手机号");
-      if (res && res.phone) {
-        this.setData({
-          phone: res.phone,
-        });
+      const [{ patient }, phoneRes] = await Promise.all([getPatients(), getPatientPhone()]);
+      const latestPhone = phoneRes?.phone || "";
+      if (this.isDifferent(cachedPatient, patient || null, cachedPhone || "", latestPhone) || !this.data.loaded) {
+        this.setData({ patient: patient || null, phone: latestPhone, loaded: true });
+        this.syncCache(patient || null, latestPhone);
       }
-      wx.setStorageSync("patientName", patient?.name);
-      this.setData({
-        patient: patient || null,
-      });
     } catch (error) {
       console.error("加载失败:", error);
       wx.showToast({
@@ -103,6 +134,9 @@ Page({
       });
     } finally {
       wx.hideLoading();
+      if (!this.data.loaded) {
+        this.setData({ loaded: true });
+      }
     }
   },
 

+ 2 - 2
miniprogram/pages/mine/mine.wxml

@@ -6,8 +6,8 @@
       <view class="head-box">
         <t-avatar class="avatar-example" size="64px">W</t-avatar>
         <view class="name-box">
-          <view class="name">{{patient ? patient.name : '未登录'}}</view>
-          <view class="phone" wx:if="{{phone}}">{{phone}}</view>
+        <view class="name" wx:if="{{loaded}}">{{patient ? patient.name : '未登录'}}</view>
+          <view class="phone" wx:if="{{loaded && phone}}">{{phone}}</view>
         </view>
       </view>