foot-print.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 药膳 4 茶饮
  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" || type === "4") {
  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. }
  64. },
  65. async load() {
  66. wx.showLoading({ title: "加载中" });
  67. try {
  68. const res = await getFootPrintListMethod();
  69. console.log(res.data.data, "获取足迹");
  70. if (res && res.data && res.data.data.length > 0) {
  71. this.setData({ articleList: res.data.data });
  72. }
  73. console.log(this.data.articleList, "articleList");
  74. } catch (error: any) {
  75. getTickleContext.call(this).showWarnMessage(error.errMsg);
  76. }
  77. wx.hideLoading();
  78. },
  79. onShow() {
  80. this.load();
  81. },
  82. });