// module/health/components/field-ruler/field-ruler.ts
import { getCareRecordListMethod } from "../../request";
Component({
  behaviors: ["wx://form-field-group"],
  lifetimes: {
    attached(this: any) {
      this.getCareRecordList();
    },
  },
  methods: {
    async getCareRecordList(this: any) {
      // 0 进行中 1 已完成
      const res = await getCareRecordListMethod("0");
      // console.log(res,"所有的调养记录列表");
      if (res && res.data && res.data.length > 0) {
        this.setData({
          careRecordList: res.data,
        });
      } else {
        this.setData({
          careRecordList: [],
        });
      }
    },
    goDetail(this: any, e: any) {
      const id = e.currentTarget.dataset.id;
      const name = e.currentTarget.dataset.name;
      if (id) {
        wx.navigateTo({
          url: `/module/care/pages/careDetail/careDetail?id=${id}&name=${name ? name : ''}`,
        });
      } else {
        wx.showToast({
          title: "数据异常",
          icon: "none",
        });
      }
    },
  },
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    loading: false,
    careRecordList: [],
  },
  observers: {},
});
