foot-print.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // module/diet/pages/delivery-address/delivery-address.ts
  7. Page({
  8. behaviors: [PageContainerBehavior, tickleBehavior],
  9. lifetimes: {
  10. attached() {},
  11. },
  12. properties: {},
  13. data: {
  14. articleList: [
  15. {
  16. id: 1,
  17. img: "", // 图片地址,留空显示占位
  18. title: "补肾误区大揭秘:这些食物并非越多越好…",
  19. subtitle: "",
  20. time: "2024-02-03 15:32:42",
  21. type: "article",
  22. },
  23. {
  24. id: 2,
  25. img: "",
  26. title: "虾的营养如何?怎么吃安全又营养",
  27. subtitle: "",
  28. time: "2024-02-03 15:32:42",
  29. type: "diet",
  30. },
  31. ],
  32. },
  33. // toInfoPage(event: WechatMiniprogram.TouchEvent) {
  34. // console.log(event, '健康宣教');
  35. // const item = event.currentTarget.dataset.item.item;
  36. // wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${item.sourceId}` })
  37. // .then(res => { res.eventChannel.emit('load', item) })
  38. // // if (this.data.replace) {
  39. // // wx.redirectTo({ url: `/module/article/pages/science-info/science-info?id=${item.sourceId}` });
  40. // // } else {
  41. // // wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${item.sourceId}` })
  42. // // .then(res => { res.eventChannel.emit('load', item) })
  43. // // }
  44. // },
  45. goDetail(e: any) {
  46. const type = e.currentTarget.dataset.type;
  47. const item = e.currentTarget.dataset.item;
  48. // type 1 中医科普 2 药膳 3 茶饮
  49. // 药膳详情
  50. console.log(type, "详情");
  51. if (type === "1") {
  52. wx.navigateTo({
  53. url: `/module/article/pages/science-info/science-info?id=${item.sourceId}`,
  54. }).then((res) => {
  55. res.eventChannel.emit("load", item);
  56. });
  57. } else if (type === "2") {
  58. wx.navigateTo({
  59. url: `/module/article/pages/diet-info/diet-info?id=${item.sourceId}`,
  60. }).then((res) => {
  61. res.eventChannel.emit("load", item);
  62. });
  63. } else if (type === "3") {
  64. console.log("茶饮");
  65. }
  66. },
  67. async load() {
  68. wx.showLoading({ title: "加载中" });
  69. try {
  70. const res = await getFootPrintListMethod();
  71. console.log(res.data.data, "获取足迹");
  72. if (res && res.data && res.data.data.length > 0) {
  73. this.setData({ articleList: res.data.data });
  74. }
  75. console.log(this.data.articleList, "articleList");
  76. } catch (error: any) {
  77. getTickleContext.call(this).showWarnMessage(error.errMsg);
  78. }
  79. wx.hideLoading();
  80. },
  81. onShow() {
  82. this.load();
  83. },
  84. });