import history from "../../utils/history";
import { getHospitalDistrictList } from "./service";
import { getRegisteredAnnouncement } from "../../../../core/utils/ywtService";
Component({
  props: {
    height: "100vh",
    componentData: {},
  },
  methods: {
    getExtInfo() {
      const { componentData } = this.props;
      const { componentExtInfo } = componentData;
      return componentExtInfo || {};
    },

    async onService() {
      const list = await getHospitalDistrictList();
      return {
        list,
        pagination: {
          total: list.length,
        },
      };
    },

    onItemTap({ target: { dataset } }) {
      this.toNextPage(dataset.item);
    },

    async toNextPage(item, replace) {
      const { name, hospitalDistrictId, extInfo, address } = item;
      const { componentData } = this.props;
      const { query = {} } = this.$page.data;
      history[replace ? "replace" : "push"]({
        query: {
          ...query,
          name,
          hospitalDistrictId,
          hospitalId: extInfo.hospitalId || "",
          subHospitalId: extInfo.subHospitalId || "",
          subHospitalTitle: `${name}(${address})`,
        },
        componentData,
        title: "医院介绍",
        pageType: "hospital-introduce",
      });
      return;
    },
  },
});
