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

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