Просмотр исходного кода

优化足迹中健康宣教的点击

张田田 1 месяц назад
Родитель
Сommit
20026ef102
1 измененных файлов с 20 добавлено и 10 удалено
  1. 20 10
      miniprogram/module/article/pages/foot-print/foot-print.ts

+ 20 - 10
miniprogram/module/article/pages/foot-print/foot-print.ts

@@ -3,6 +3,7 @@ import tickleBehavior, {
   getTickleContext,
 } from "../../../../core/behavior/tickle.behavior";
 import { getFootPrintListMethod } from "../../request";
+import { Get } from "../../../../lib/request/method";
 Page({
   behaviors: [PageContainerBehavior, tickleBehavior],
   lifetimes: {
@@ -10,20 +11,30 @@ Page({
   },
   properties: {},
   data: {
-    articleList: [],
+    articleList: [] as any[],
   },
-  goDetail(e: any) {
+  async goDetail(e: any) {
     const type = e.currentTarget.dataset.type;
     const item = e.currentTarget.dataset.item;
-    // type 1 中医科普 2 药膳 4 茶饮
+    // type ,1-健康宣教 2-药膳 3-膳食 4-茶饮
     // 药膳详情
-    console.log(type, "详情");
     if (type === "1") {
-      wx.navigateTo({
-        url: `/module/article/pages/science-info/science-info?id=${item.sourceId}`,
-      }).then((res) => {
-        res.eventChannel.emit("load", item);
-      });
+      try {
+        const res: any = await Get(`/psarticle/clickPsarticle`, {
+          params: { popularScienceArticleId: item.sourceId },
+        });
+        const url = res?.data;
+        const detailPayload = {
+          url,
+        };
+        wx.navigateTo({
+          url: `/module/article/pages/science-info/science-info`,
+        }).then((res) => {
+          res.eventChannel.emit("load", detailPayload);
+        });
+      } catch (error) {
+        console.log(error);
+      }
     } else if (type === "2" || type === "4") {
       wx.navigateTo({
         url: `/module/article/pages/diet-info/diet-info?id=${item.sourceId}`,
@@ -37,7 +48,6 @@ Page({
     try {
       const res = await getFootPrintListMethod();
       const list = res?.data?.data ?? [];
-      console.log(list, "list",res.data.data);
       this.setData({ articleList: Array.isArray(list) ? list : [] });
     } catch (error: any) {
       getTickleContext.call(this).showWarnMessage(error.errMsg);