张田田 3 ماه پیش
والد
کامیت
172beda3a6
1فایلهای تغییر یافته به همراه29 افزوده شده و 31 حذف شده
  1. 29 31
      miniprogram/pages/home/home.ts

+ 29 - 31
miniprogram/pages/home/home.ts

@@ -327,7 +327,7 @@ Page({
           popupList: res,
           isShowPopup: true,
         });
-      }else{
+      } else {
         this.setData({
           popupList: [],
           isShowPopup: false,
@@ -351,9 +351,9 @@ Page({
     if (this.data.isCompleting) {
       return;
     }
-    
+
     this.setData({ isCompleting: true });
-    
+
     try {
       const { title } = e.currentTarget.dataset;
       let page = e.currentTarget.dataset.page;
@@ -428,18 +428,18 @@ Page({
           showCancel: false,
           confirmText: `重新加载`,
         })
-        .catch(() => {});
+        .catch(() => { });
       await this.load(true);
       return;
     }
-
+    // 加载健康宣教的文章
+    this.loadScienceList();
     if (!this.data._loaded) {
-      this.loadScienceList();
       getSolarTerms()
         .then((solarTerms) => {
           this.setData({ solarTerms });
         })
-        .catch(() => {});
+        .catch(() => { });
       this.setData({ _loaded: true });
     }
   },
@@ -616,17 +616,15 @@ Page({
     (<any>this).applyAnimatedStyle(".fab-2", () => {
       "worklet";
       return {
-        transform: `translateX(${-offset.value}px) translateY(${
-          -offset.value / 2
-        }px)`,
+        transform: `translateX(${-offset.value}px) translateY(${-offset.value / 2
+          }px)`,
       };
     });
     (<any>this).applyAnimatedStyle(".fab-3", () => {
       "worklet";
       return {
-        transform: `translateX(${-offset.value}px) translateY(${
-          offset.value / 2
-        }px)`,
+        transform: `translateX(${-offset.value}px) translateY(${offset.value / 2
+          }px)`,
       };
     });
     (<any>this).applyAnimatedStyle(".fab-4", () => {
@@ -736,7 +734,7 @@ Page({
         total,
         page: currentPage,
       } = await getShortScienceList(page, this.data.scienceListSize);
-
+      console.log("datas", data, "newList:", this.data.scienceList);
       const newList = reset ? data : [...this.data.scienceList, ...data];
       const hasMore = newList.length < total;
 
@@ -747,7 +745,7 @@ Page({
         scienceListHasMore: hasMore,
         scienceListLoading: false,
       });
-
+      console.log(this.data.scienceList, "this.data.scienceList");
       // 分配卡片到两列,实现瀑布流布局
       this.distributeCardsToColumns(newList, reset);
     } catch (error) {
@@ -779,14 +777,14 @@ Page({
     const itemsToDistribute = reset
       ? list
       : list.filter(
-          (item: any) =>
-            !this.data.leftColumnList.some(
-              (existing: any) => existing.id === item.id
-            ) &&
-            !this.data.rightColumnList.some(
-              (existing: any) => existing.id === item.id
-            )
-        );
+        (item: any) =>
+          !this.data.leftColumnList.some(
+            (existing: any) => existing.id === item.id
+          ) &&
+          !this.data.rightColumnList.some(
+            (existing: any) => existing.id === item.id
+          )
+      );
 
     if (itemsToDistribute.length === 0) return;
 
@@ -794,16 +792,16 @@ Page({
     let leftHeight = reset
       ? 0
       : this.data.leftColumnList.reduce(
-          (sum: number, item: any) => sum + this.estimateCardHeight(item),
-          0
-        );
+        (sum: number, item: any) => sum + this.estimateCardHeight(item),
+        0
+      );
 
     let rightHeight = reset
       ? 0
       : this.data.rightColumnList.reduce(
-          (sum: number, item: any) => sum + this.estimateCardHeight(item),
-          0
-        );
+        (sum: number, item: any) => sum + this.estimateCardHeight(item),
+        0
+      );
 
     // 追加新卡片到较短的列(重置时从空数组开始)
     const leftColumn = reset ? [] : [...this.data.leftColumnList];
@@ -838,8 +836,8 @@ Page({
       const imgHeightRange = imgMaxHeight - imgMinHeight;
       const idHash = item.id
         ? String(item.id)
-            .split("")
-            .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0)
+          .split("")
+          .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0)
         : 0;
       const imgHeight = imgMinHeight + (idHash % imgHeightRange);
       height += imgHeight;