<template>
	<view>
		<view class="" v-if="props.show">
			<qf-image-cropper :src="props.url" :width="props.width" :height="props.height" :radius="20"
				@crop="handleCrop"></qf-image-cropper>
		</view>

	</view>
</template>

<script setup lang="ts">
	import { ref, watch } from 'vue';
	import { onBeforeUnmount, onMounted, reactive } from 'vue';
	import { Service, BycAdminService } from '@/Service/Byc/BycAdminService'
	// const props = defineProps({
	// 	show : string,
	// 	// url : string,
	// 	// width : number,
	// 	// height:number,
	// 	// upType:string,
	// 	// retFun:Function
	// });


	let props = defineProps(["show","url",'width','height','upType',"retFun","imgName"]);

	onMounted(() => {
		
	})


	const handleCrop = (e) => {
		let arr = e.tempFilePath.split('.')
		let name = arr[arr.length - 1]
		Service.UpLoadMedia(props.upType, name, '', e.tempFilePath).then(rest => {
			if (rest.code == 0) {
				uni.showToast({
					title: rest.msg,
					icon: 'none'
				})
				props.retFun( {name:props.imgName,url:rest.data.file})
			} else {
				uni.showToast({
					title: rest.msg,
					icon: 'none'
				})
			}
		})
	}
</script>

<style>

</style>