<!-- component标签可以变换组件 -->
<template>
	<view>
		<view v-if="ifH5">
			<SinopecEsignPageH5 :taskDefKey="props.taskDefKey" :valiData="props.valiData"  :procInsId="props.procInsId"  :path="props.path" ref="signH5" :fileName="props.fileName" @stampSuccess="getStampSuccess"></SinopecEsignPageH5>
		</view>
		<view v-else>
			<SinopecEsignPageAPP :taskDefKey="props.taskDefKey" :valiData="props.valiData" :procInsId="props.procInsId"  :path="props.path" ref="signAPP" :fileName="props.fileName" @stampSuccess="getStampSuccess"></SinopecEsignPageAPP>
		</view>
	</view>
</template>
<script setup lang="ts">
	import {
		ref
	} from 'vue'
	import {
		onLoad,
	} from '@dcloudio/uni-app';
	import SinopecEsignPageH5 from '@/components/Esign/SinopecEsignPageH5.vue'
	import SinopecEsignPageAPP from '@/components/Esign/SinopecEsignPageAPP.vue'
	const emit = defineEmits(['stampSuccess'])
	const ifH5 = ref(null);
	const signH5 = ref(null);
	const signAPP = ref(null);
	

	const props = defineProps({
		fileName: {
			type: String,
			default: ""
		},
		valiData: {
			type: Object,
			 default: () => ({})
		},
		procInsId: { //签章验证
			type: String,
			default: ""
		},
		path: {//签章验证
			type: String,
			default: ""
		},
		taskDefKey: { //流程节点
			type: String,
			default: ""
		}
	})

	//判断是否h5 by 闵
	var ifH = false;

	onLoad(() => {
		//#ifdef H5 || MP-WEIXIN
		ifH5.value = true;
		//#endif
	})
	
	//获取印章成功事件，并将信号传给确认提交按钮。
	const getStampSuccess=(val)=> {
			emit('stampSuccess', val)
	 }
	 
	 const signValidator = ()=>{
	 	//这里进行电子签章验证
	 	if(ifH5.value){
		  return	signH5.value.signValidator();
		}else{
		  return	signAPP.value.signValidator()
		}
	 }
	 
	 
	defineExpose({ //暴露方法
	  signValidator
	})
</script>

<style scoped>
	
</style>