<template>
	<cl-page :backgroundColor="data.background" :backgroundImage="data.backgroundImage" :statusBar="!!data.statusBar"
		:statusBarBackground="data.statusBarColor">
		<fix-index :list="data.form" :statusBar="!!data.statusBar"></fix-index>
	</cl-page>
</template>

<script lang="ts" setup>
	import { ref, nextTick } from "vue";
	import { useCool } from "/@/cool";
	import { onReady, onPageScroll, onLoad } from "@dcloudio/uni-app";
	import { useUi } from "/$/cool-ui";
	defineProps({ id: String });
	const { service } = useCool();
	const ui = useUi();

	const data = ref({
		background: "#f5f6fa",
		backgroundImage: "",
		statusBarColor: "",
		statusBar: 1,
		name: "",
		form: [],
	});

	function getPage(id : string) {
		service.fixtures.mould
			.getPage({ id })
			.then((res : any) => {
				data.value = res;
			})
			.catch((e) => {
				ui.showToast(e.message);
			})
			.finally(() => {
				nextTick().then(() => {
					uni.hideLoading();
				});
			});
	}
	// 加载数据
	function loadSuccess(query : any) {
		getPage(query.id);
	}
	onReady(() => { });
	onLoad((query : any) => {
		uni.showLoading({
			title: "加载中...",
			mask: true,
		});
		loadSuccess(query)
	});
	onPageScroll(() => { });
</script>