foot-print.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. Page({
  7. behaviors: [PageContainerBehavior, tickleBehavior],
  8. lifetimes: {
  9. attached() {},
  10. },
  11. properties: {},
  12. data: {
  13. articleList: [],
  14. },
  15. goDetail(e: any) {
  16. const type = e.currentTarget.dataset.type;
  17. const item = e.currentTarget.dataset.item;
  18. // type 1 中医科普 2 药膳 4 茶饮
  19. // 药膳详情
  20. console.log(type, "详情");
  21. if (type === "1") {
  22. wx.navigateTo({
  23. url: `/module/article/pages/science-info/science-info?id=${item.sourceId}`,
  24. }).then((res) => {
  25. res.eventChannel.emit("load", item);
  26. });
  27. } else if (type === "2" || type === "4") {
  28. wx.navigateTo({
  29. url: `/module/article/pages/diet-info/diet-info?id=${item.sourceId}`,
  30. }).then((res) => {
  31. res.eventChannel.emit("load", item);
  32. });
  33. }
  34. },
  35. async load() {
  36. wx.showLoading({ title: "加载中" });
  37. try {
  38. const res = await getFootPrintListMethod();
  39. const list = res?.data?.data ?? [];
  40. console.log(list, "list",res.data.data);
  41. this.setData({ articleList: Array.isArray(list) ? list : [] });
  42. } catch (error: any) {
  43. getTickleContext.call(this).showWarnMessage(error.errMsg);
  44. }
  45. wx.hideLoading();
  46. },
  47. onShow() {
  48. this.load();
  49. },
  50. });