import { healthReportListMethod } from "../../request";
import { getTickleContext } from "../../../../core/behavior/tickle.behavior";
interface PanelProps {
  shade?: boolean;
  title?: string;
  data: AnyArray;
  type?: "analysis" | "report";
}
Page({
  onLoad() {
    this.getReportRecordList();
  },

  data: {
    panel: {
      shade: false,
      data: [],
    } as PanelProps,
    _healthReportList: { data: [], loaded: false },
    defaultIcon: '/assets/health/record-icon.png',
  },
  async getReportRecordList() {
    if (!this.data._healthReportList.loaded) {
      wx.showLoading({ title: "加载中" });
      try {
        const data = await healthReportListMethod();
        this.setData({
          "_healthReportList.data": data,
          "_healthReportList.loaded": true,
        });
      } catch (error) {
        getTickleContext.call(this).showErrorMessage(error.errMsg);
      }
      wx.hideLoading();
    }
  },
  onItemTap(e: any) {
    const id = e.currentTarget.dataset.id;
    // 跳转到详情页
    wx.navigateTo({ url: `/module/health/pages/report/report?id=${id}` });
  }
});
