foot-print.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
  2. import tickleBehavior, {
  3. getTickleContext,
  4. } from "../../../../core/behavior/tickle.behavior";
  5. import { getFootPrintListMethod } from "../../request";
  6. import { Get } from "../../../../lib/request/method";
  7. Page({
  8. behaviors: [PageContainerBehavior, tickleBehavior],
  9. lifetimes: {
  10. attached() {},
  11. },
  12. properties: {},
  13. data: {
  14. articleList: [] as any[],
  15. },
  16. async goDetail(e: any) {
  17. const type = e.currentTarget.dataset.type;
  18. const item = e.currentTarget.dataset.item;
  19. // type ,1-健康宣教 2-药膳 3-膳食 4-茶饮
  20. // 药膳详情
  21. if (type === "1") {
  22. try {
  23. const res: any = await Get(`/psarticle/clickPsarticle`, {
  24. params: { popularScienceArticleId: item.sourceId },
  25. });
  26. const url = res?.data;
  27. const detailPayload = {
  28. url,
  29. };
  30. wx.navigateTo({
  31. url: `/module/article/pages/science-info/science-info`,
  32. }).then((res) => {
  33. res.eventChannel.emit("load", detailPayload);
  34. });
  35. } catch (error) {
  36. console.log(error);
  37. }
  38. } else if (type === "2" || type === "4") {
  39. wx.navigateTo({
  40. url: `/module/article/pages/diet-info/diet-info?id=${item.sourceId}`,
  41. }).then((res) => {
  42. res.eventChannel.emit("load", item);
  43. });
  44. }
  45. },
  46. async load() {
  47. wx.showLoading({ title: "加载中" });
  48. try {
  49. const res = await getFootPrintListMethod();
  50. const list = res?.data?.data ?? [];
  51. this.setData({ articleList: Array.isArray(list) ? list : [] });
  52. } catch (error: any) {
  53. getTickleContext.call(this).showWarnMessage(error.errMsg);
  54. }
  55. wx.hideLoading();
  56. },
  57. onShow() {
  58. this.load();
  59. },
  60. });