import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";

// module/health/pages/scheme/scheme.ts
import { healthSchemeMethod } from "../../request";
import { toReportPage } from "../../router";
Component({
  behaviors: [
    PageContainerBehavior,
    TickleBehavior
  ],
  lifetimes: {
    attached() {
      this.getHealthScheme(this.data.id);
    }
  },
  properties: {
    id: { type: String, value: '' },
  },
  data: {
    dataset: null,
    schemeId: '',
    healthIndex: { data: [], loading: false, message: '' },
  },
  observers: {},
  methods: {
    async getHealthScheme(id: string) {
      wx.showLoading({ title: '加载中' });
      try {
        const dataset = await healthSchemeMethod(id);
        console.log(dataset, '1-->');
        
        this.setData({ dataset });
      } catch (error) {
        console.log(error);

        getTickleContext.call(this).showErrorMessage(error.errMsg || error.message, 0);
      }
      wx.hideLoading();
    },
    toReportPage() { toReportPage(this.data.id); }
  }
})