张田田 пре 7 месеци
родитељ
комит
9d6307e091

+ 10 - 24
miniprogram/app.config.ts

@@ -1,28 +1,14 @@
 import { getAccountInfoSync } from "./lib/wx/open-api";
 
 const miniProgram = getAccountInfoSync();
-// 测试环境
-let BaseURL = "";
-let UploadURL = "";
-const url = "https://test.hzliuzhi.com/manager/";
-if (miniProgram.envVersion === "trial") {
-  BaseURL = url + "fdhb-mobile";
-  UploadURL = url + "file";
-} else {
-  const port = miniProgram.envVersion === "release" ? 433 : 4433;
-  BaseURL = `https://wx.hzliuzhi.com:${port}/manager/fdhb-mobile` as const;
-  UploadURL = `https://wx.hzliuzhi.com:${port}/manager/file` as const;
+const env = miniProgram.envVersion;
+let host = "wx2.hzliuzhi.com";
+if (env === "trial") {
+  host = "test.hzliuzhi.com";
+} else if (env === "develop") {
+  host = "wx.hzliuzhi.com:4433";
 }
-console.log(
-  miniProgram.envVersion,
-  "小程序的版本",
-  "BaseURL:",
-  BaseURL,
-  "UploadURL:",
-  UploadURL
-);
-export const Base_URL = BaseURL;
-export const Upload_URL = UploadURL;
-// const port = miniProgram.envVersion === 'release' ? 433 : 4433;
-// export const Base_URL = `https://wx.hzliuzhi.com:${port}/manager/fdhb-mobile` as const;
-// export const Upload_URL = `https://wx.hzliuzhi.com:${port}/manager/file` as const;
+export const Base_URL = `https://${host}/manager/fdhb-mobile`;
+export const Upload_URL = `https://${host}/manager/file`;
+
+

+ 0 - 8
miniprogram/components/media-carousel/media-carousel.wxml

@@ -29,14 +29,6 @@
         <video 
           src="{{item.src}}" 
           class="carousel-video"
-          poster="{{item.poster}}"
-          show-center-play-btn="{{true}}"
-          show-play-btn="{{true}}"
-          controls="{{true}}"
-          object-fit="cover"
-          autoplay="{{true}}"
-          loop="{{true}}"
-          muted="{{true}}"
           bind:error="onVideoError"
           data-index="{{index}}"
         />

+ 0 - 4
miniprogram/module/care/pages/careDetail/careDetail.ts

@@ -222,7 +222,6 @@ Page({
               item.carouselMediaList.push({
                 type: "image",
                 src: item.conditioningProgramDetail?.photo,
-                // title: "商品图片",
               });
             }
             // 添加itemImgFirst
@@ -230,7 +229,6 @@ Page({
               item.carouselMediaList.push({
                 type: "image",
                 src: item.conditioningProgramDetail?.itemImgFirst,
-                // title: "操作图片",
               });
             }
 
@@ -239,7 +237,6 @@ Page({
               item.carouselMediaList.push({
                 type: "video",
                 src: item.conditioningProgramDetail?.itemVideoFirst,
-                // title: "操作视频",
               });
             }
 
@@ -292,7 +289,6 @@ Page({
             this.setData({
               healthReports: processedReports,
             });
-
           }
         }
         this.setData({

+ 2 - 1
miniprogram/pages/home/home.json

@@ -13,7 +13,8 @@
     "science-card": "../../module/article/components/science-card/science-card",
     "t-popup": "tdesign-miniprogram/popup/popup",
     "tabbar": "../../components/tabbar/tabbar",
-    "media-carousel": "../../components/media-carousel/media-carousel"
+    "media-carousel": "../../components/media-carousel/media-carousel",
+    "t-loading": "tdesign-miniprogram/loading/loading"
   },
   "componentPlaceholder": {
     "report-health-scheme": "view",

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

@@ -564,6 +564,21 @@ $scale: 0.5;
     height: 100%;
   }
 
+  .carousel-loading {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    background-color: rgba(248, 249, 250, 0.95);
+    border-radius: 16rpx;
+    z-index: 10;
+  }
+
   .loading-overlay {
     position: absolute;
     top: 0;

+ 70 - 156
miniprogram/pages/home/home.ts

@@ -70,24 +70,10 @@ Page({
 
     statusList: [] as AnyArray,
 
+    carouselLoading: {} as Record<string | number, boolean>, // 用于跟踪每个轮播图的加载状态
+
     // 轮播媒体列表
-    carouselMediaList: [
-      // {
-      //   type: 'image',
-      //   src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/222_20250807164536A813.jpg",
-      //   title: '操作图片'
-      // },
-      // {
-      //   type: 'image',
-      //   src: "https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/111_20250807164533A812.jpg",
-      //   title: '商品图片'
-      // },
-      // {
-      //   type: 'video',
-      //   src: 'https://wx.hzliuzhi.com:4433/manager/file/statics/2025/08/07/song_20250807164546A814.mp4',
-      //   title: '操作视频'
-      // },
-    ] as Array<{
+    carouselMediaList: [] as Array<{
       type: "image" | "video";
       src: string;
       poster?: string;
@@ -101,11 +87,10 @@ Page({
 
   // 获取调养计划
   async getCareLists() {
-    // 保存当前的展开状态和媒体加载状态
+    // 保存当前的展开状态
     const currentExpandedStates = this.data.displayList.map((item: any) => ({
       id: item.id,
       expanded: item.expanded,
-      _mediaLoaded: item._mediaLoaded,
     }));
 
     const res = await getCareList();
@@ -113,12 +98,6 @@ Page({
       res.forEach((item: any, index: number) => {
         item.carouselMediaList = [];
 
-        // 检查是否已经加载过媒体内容
-        const existingItem = currentExpandedStates.find(
-          (state) => state.id === item.id
-        );
-        item._mediaLoaded = existingItem ? existingItem._mediaLoaded : false;
-
         // 确保 item.id 存在且为数字类型
         if (!item.id && item.id !== 0) {
           item.id = index;
@@ -126,13 +105,11 @@ Page({
 
         // 确保 id 是数字类型
         item.id = Number(item.id);
-
         // 添加photo
         if (item.photo) {
           item.carouselMediaList.push({
             type: "image",
             src: item.photo,
-            // title: "商品图片",
           });
         }
 
@@ -141,7 +118,6 @@ Page({
           item.carouselMediaList.push({
             type: "image",
             src: item.itemImgFirst,
-            // title: "操作图片",
           });
         }
 
@@ -150,30 +126,30 @@ Page({
           item.carouselMediaList.push({
             type: "video",
             src: item.itemVideoFirst,
-            poster: item.photo || item.itemImgFirst,
-            // title: "操作视频",
           });
         }
 
-        // 如果没有媒体内容,直接标记为已加载,避免一直显示加载状态
-        if (item.carouselMediaList.length === 0) {
-          item._mediaLoaded = true;
-        } else {
+        // 如果有轮播图内容,设置加载状态
+        if (item.carouselMediaList.length > 0) {
+          this.setData({
+            [`carouselLoading.${item.id}`]: true,
+          });
+
+          // 设置超时,防止一直显示加载中
           setTimeout(() => {
-            if (!item._mediaLoaded) {
+            // 检查是否还在加载状态,如果是则自动隐藏
+            const currentLoading = this.data.carouselLoading;
+            if (currentLoading && currentLoading[item.id]) {
               this.setData({
-                [`careList[${index}]._mediaLoaded`]: true,
+                [`carouselLoading.${item.id}`]: false,
               });
-              const displayIndex = this.data.displayList.findIndex(
-                (displayItem: any) => displayItem.id === item.id
-              );
-              if (displayIndex !== -1) {
-                this.setData({
-                  [`displayList[${displayIndex}]._mediaLoaded`]: true,
-                });
-              }
             }
-          }, 3000);
+          }, 10000); // 10秒后自动隐藏加载状态
+        } else {
+          // 如果没有轮播图内容,确保不显示加载状态
+          this.setData({
+            [`carouselLoading.${item.id}`]: false,
+          });
         }
       });
 
@@ -219,11 +195,9 @@ Page({
   async onShow() {
     wx.showShareMenu({ withShareTicket: true, menus }).then();
     await this.load();
-    console.log(this.data.patient, "获取用户信息patient");
-    // console.log(this.data.patient, "获取用户信息patient");
     // 如果用户没有手机号每次进入页面都提示  点击跳到注册页补充
     // todo 要先判断用户有没有手机号 isPerfectInfo是true 就出来弹窗提示用户
-    if (this.data.patient?.isPerfectInfo ?? true) {
+    if ((this.data.patient as any)?.isPerfectInfo ?? true) {
       wx.showModal({
         title: "提示",
         content: "手机号为空,请补充",
@@ -247,7 +221,7 @@ Page({
       }
     );
   },
-  onShareAppMessage(opts): WechatMiniprogram.Page.ICustomShareContent {
+  onShareAppMessage(_opts): WechatMiniprogram.Page.ICustomShareContent {
     return {
       title: `健康为基,从容赏生活之美`,
       imageUrl: `https://wx.hzliuzhi.com/media/healthManager/wx/share.jpg`,
@@ -264,14 +238,13 @@ Page({
     preserveExpandedStates?: Array<{
       id: number;
       expanded: boolean;
-      _mediaLoaded?: boolean;
     }>
   ) {
     const { careList, allExpanded } = this.data;
     let newDisplayList: any[] =
       allExpanded || careList.length <= 4 ? careList : careList.slice(0, 4);
 
-    // 如果有保存的展开状态和媒体加载状态,则恢复它们
+    // 如果有保存的展开状态,则恢复它们
     if (preserveExpandedStates && preserveExpandedStates.length > 0) {
       newDisplayList = newDisplayList.map((item: any) => {
         const savedState = preserveExpandedStates.find(
@@ -281,10 +254,6 @@ Page({
           return {
             ...item,
             expanded: savedState.expanded,
-            _mediaLoaded:
-              savedState._mediaLoaded !== undefined
-                ? savedState._mediaLoaded
-                : item._mediaLoaded,
           };
         }
         return item;
@@ -301,7 +270,7 @@ Page({
       this.updateDisplayList
     );
   },
-  toggleItem(e) {
+  toggleItem(e: any) {
     const index = e.currentTarget.dataset.index;
     const key = `displayList[${index}].expanded`;
     this.setData({ [key]: !this.data.displayList[index].expanded });
@@ -419,7 +388,7 @@ Page({
         this.observerPatient(patient);
       }
       wx.hideLoading();
-    } catch (error) {
+    } catch (error: any) {
       await wx
         .showModal({
           title: `加载失败`,
@@ -428,7 +397,7 @@ Page({
           confirmText: `重新加载`,
         })
         .catch(() => {});
-      this.load(true);
+      await this.load(true);
       return;
     }
 
@@ -454,11 +423,11 @@ Page({
     try {
       const data = await healthReportMethod();
 
-      if (!data ) {
+      if (!data) {
         this.setData({
           isShowComplete: true,
         });
-      }else{
+      } else {
         this.setData({
           isShowComplete: false,
         });
@@ -533,7 +502,7 @@ Page({
           .filter(Boolean),
         "healthIndex.loading": false,
       });
-    } catch (error) {
+    } catch (error: any) {
       this.setData({
         "healthIndex.data": [],
         "healthIndex.loading": false,
@@ -660,7 +629,7 @@ Page({
     if (!this.data.patient?.patientId) {
       try {
         await this.load();
-      } catch (error) {
+      } catch (error: any) {
         wx.showModal({
           title: "出错了",
           content: error?.errMsg ?? error?.message ?? "错误,请重试",
@@ -707,7 +676,7 @@ Page({
       else wx.showToast({ title: "暂无分析报告", icon: "none" });
     }
   },
-  onDraggableSizeUpdate(e) {
+  onDraggableSizeUpdate(e: any) {
     "worklet";
     if (e.pixels < 1) {
       wx.worklet.runOnJS(this.hideDraggableSheet.bind(this))();
@@ -761,98 +730,34 @@ Page({
     // 获取调养计划
     this.getCareLists();
   },
-  // 图片加载成功
-  onImageLoad(e: any) {
-    const { item, itemId } = e.detail;
-    // 如果有itemId,直接更新对应项的状态
+  // 轮播图加载完成
+  onCarouselLoaded(e: any) {
+    const { itemId } = e.detail;
     if (itemId) {
-      this.updateMediaLoadedStateById(itemId);
-    } else {
-      // 兼容旧版本,通过查找来匹配
-      this.updateMediaLoadedState(item);
+      this.setData({
+        [`carouselLoading.${itemId}`]: false,
+      });
     }
   },
   // 图片加载失败
   onImageError(e: any) {
-    const { item, itemId } = e.detail;
-    wx.showToast({
-      title: "图片加载失败",
-      icon: "none",
-    });
-    // 即使加载失败也要标记为已加载,避免一直显示加载状态
+    const { itemId } = e.detail;
+    // 图片加载失败时也要隐藏加载状态
     if (itemId) {
-      this.updateMediaLoadedStateById(itemId);
-    } else {
-      this.updateMediaLoadedState(item);
-    }
-  },
-
-  // 通过ID更新媒体加载状态的辅助方法
-  updateMediaLoadedStateById(itemId: string | number) {
-    const { careList, displayList } = this.data;
-
-    // 查找对应的 careList 项
-    const careListIndex = careList.findIndex((item: any) => item.id == itemId);
-
-    // 查找对应的 displayList 项
-    const displayListIndex = displayList.findIndex(
-      (item: any) => item.id == itemId
-    );
-
-    if (careListIndex !== -1) {
       this.setData({
-        [`careList[${careListIndex}]._mediaLoaded`]: true,
-      });
-    }
-
-    if (displayListIndex !== -1) {
-      this.setData({
-        [`displayList[${displayListIndex}]._mediaLoaded`]: true,
+        [`carouselLoading.${itemId}`]: false,
       });
     }
   },
 
-  // 更新媒体加载状态的辅助方法(兼容旧版本)
-  updateMediaLoadedState(mediaItem: any) {
-    const { careList, displayList } = this.data;
-    // 查找对应的 careList 项
-    const careListIndex = careList.findIndex(
-      (item: any) =>
-        item.carouselMediaList &&
-        item.carouselMediaList.some((media: any) => media.src === mediaItem.src)
-    );
-    // 查找对应的 displayList 项
-    const displayListIndex = displayList.findIndex(
-      (item: any) =>
-        item.carouselMediaList &&
-        item.carouselMediaList.some((media: any) => media.src === mediaItem.src)
-    );
-
-    if (careListIndex !== -1) {
-      this.setData({
-        [`careList[${careListIndex}]._mediaLoaded`]: true,
-      });
-    }
-
-    if (displayListIndex !== -1) {
-      this.setData({
-        [`displayList[${displayListIndex}]._mediaLoaded`]: true,
-      });
-    }
-  },
-
-  // 视频播放失败
+  // 视频播放错误
   onVideoError(e: any) {
-    const { item, itemId } = e.detail;
-    wx.showToast({
-      title: "视频播放失败",
-      icon: "none",
-    });
-    // 视频播放错误时也要标记为已加载,避免一直显示加载状态
+    const { itemId } = e.detail;
+    // 视频播放错误时也要隐藏加载状态
     if (itemId) {
-      this.updateMediaLoadedStateById(itemId);
-    } else {
-      this.updateMediaLoadedState(item);
+      this.setData({
+        [`carouselLoading.${itemId}`]: false,
+      });
     }
   },
   // 没有健康分析去做健康分析
@@ -887,11 +792,10 @@ Page({
 
   // 无感刷新调养计划,保持展开状态和媒体加载状态
   async refreshCareListsWithState() {
-    // 保存当前的展开状态和媒体加载状态
+    // 保存当前的展开状态
     const currentExpandedStates = this.data.displayList.map((item: any) => ({
       id: item.id,
       expanded: item.expanded,
-      _mediaLoaded: item._mediaLoaded,
       carouselMediaList: item.carouselMediaList, // 保存媒体列表,避免重新加载
     }));
 
@@ -906,21 +810,18 @@ Page({
         );
 
         // 如果找到旧数据且媒体已加载,保持媒体状态
-        if (oldItem && oldItem._mediaLoaded && oldItem.carouselMediaList) {
+        if (oldItem && oldItem.carouselMediaList) {
           // 保持原有的媒体列表,避免重新加载
           item.carouselMediaList = oldItem.carouselMediaList;
-          item._mediaLoaded = true;
         } else {
           // 否则重新构建媒体列表
           item.carouselMediaList = [];
-          item._mediaLoaded = false;
 
           // 添加photo
           if (item.photo) {
             item.carouselMediaList.push({
               type: "image",
               src: item.photo,
-              cacheKey: `photo_${item.id}_${item.photo}`, // 添加缓存键
             });
           }
 
@@ -929,23 +830,37 @@ Page({
             item.carouselMediaList.push({
               type: "image",
               src: item.itemImgFirst,
-              cacheKey: `img_${item.id}_${item.itemImgFirst}`, // 添加缓存键
             });
           }
-
           // 添加itemVideoFirst
           if (item?.itemVideoFirst) {
             item.carouselMediaList.push({
               type: "video",
               src: item.itemVideoFirst,
-              poster: item.photo || item.itemImgFirst,
-              cacheKey: `video_${item.id}_${item.itemVideoFirst}`, // 添加缓存键
             });
           }
 
-          // 如果没有媒体内容,直接标记为已加载
-          if (item.carouselMediaList.length === 0) {
-            item._mediaLoaded = true;
+          // 如果有轮播图内容,设置加载状态
+          if (item.carouselMediaList.length > 0) {
+            this.setData({
+              [`carouselLoading.${item.id}`]: true,
+            });
+
+            // 设置超时,防止一直显示加载中
+            setTimeout(() => {
+              // 检查是否还在加载状态,如果是则自动隐藏
+              const currentLoading = this.data.carouselLoading;
+              if (currentLoading && currentLoading[item.id]) {
+                this.setData({
+                  [`carouselLoading.${item.id}`]: false,
+                });
+              }
+            }, 10000); // 10秒后自动隐藏加载状态
+          } else {
+            // 如果没有轮播图内容,确保不显示加载状态
+            this.setData({
+              [`carouselLoading.${item.id}`]: false,
+            });
           }
         }
 
@@ -972,7 +887,6 @@ Page({
           return {
             ...item,
             expanded: savedState.expanded,
-            _mediaLoaded: savedState._mediaLoaded,
             carouselMediaList:
               savedState.carouselMediaList || item.carouselMediaList,
           };

+ 5 - 6
miniprogram/pages/home/home.wxml

@@ -84,13 +84,12 @@
                 <view style="width: 60%;">
                   <!-- 轮播媒体容器 -->
                   <view class="carousel-container" wx:if="{{item.carouselMediaList && item.carouselMediaList.length > 0}}">
-                    <!-- 轮播组件 -->
-                    <media-carousel wx:if="{{item.carouselMediaList && item.carouselMediaList.length > 0}}" mediaList="{{item.carouselMediaList}}" showIndicator="{{true}}" autoplay="{{true}}" interval="{{4000}}" circular="{{true}}" bind:imageload="onImageLoad" bind:imageerror="onImageError" bind:videoerror="onVideoError" itemId="{{item.id}}" />
-                    <!-- 加载状态覆盖层 -->
-                    <view class="loading-overlay" wx:if="{{!item._mediaLoaded}}">
-                      <view class="loading-spinner"></view>
-                      <text class="loading-text">加载中...</text>
+                    <!-- 加载状态 -->
+                    <view wx:if="{{carouselLoading[item.id]}}" class="carousel-loading">
+                      <t-loading size="40rpx" text="加载中..." />
                     </view>
+                    <!-- 轮播组件 -->
+                    <media-carousel wx:else mediaList="{{item.carouselMediaList}}" showIndicator="{{true}}" autoplay="{{true}}" interval="{{4000}}" circular="{{true}}" bind:imageload="onCarouselLoaded" bind:imageerror="onImageError" bind:videoerror="onVideoError" itemId="{{item.id}}" />
                   </view>
                   <view class="item-box">
                     <view class="flex" wx:if="{{item.arrangeDate}}"><text>下一次时间:</text><text>{{item.arrangeDate}}</text></view>