import history from "../../utils/history";
import { getRegisteredAnnouncement } from "../../../../core/utils/ywtService";
Component({
	props: {
		componentData: {},
	},
	data: {
		type: "",
		content: "",
	},
	didMount() {
		const { query = {} } = this.$page.data;
		const { name, hospitalDistrictId } = query;
		console.log("query ===>", query);
		this.getAgreement(hospitalDistrictId);
		const nameMap = {
			黄石总院: "huangshi",
		};
		this.setData({
			type: nameMap[name] ? nameMap[name] : "normal",
		});
	},
	methods: {
		async getAgreement(hospitalId) {
			const [err, result] = await getRegisteredAnnouncement({
				hospitalId: Number(hospitalId),
			});
			if (!err && result && result.id > 0) {
				this.setData({ content: result.content });
			}
		},
		toNextPage() {
			const { componentData } = this.props;
			const { query = {} } = this.$page.data;
			history.push({
				query,
				componentData,
				title: "选择科室",
				pageType: "select-department",
			});
		},

		toService() {
			history.push({
				title: "授权协议",
				pageType: "service-agreement",
			});
		},
	},
});
