<template>
	<view>
		<web-view src="http://localhost:8081/#/gardenMap?point=113.1093017627431,22.574540836684672&userId=91754"
			@message="handleMapEvent"></web-view>

	</view>
</template>

<script setup>
	import {
		onMounted
	} from 'vue';

	const handleBack = () => {
		uni.navigateBack();
	};

	const handleMapEvent = (e) => {
		const data = e.detail.data;
		console.log('地图点击坐标:', data);
		switch (data.type) {
			case 'map-click':
				console.log('地图点击坐标:', data.lat, data.lng);
				break;
			case 'marker-click':
				console.log('标记点点击:', data.markerId);
				break;
		}
	}
	// 动态注入 JS 监听（兼容性方案）
	// onMounted(() => {
	//   window.addEventListener('message', (e) => {
	// 	  alert('eee', e.data)
	//     if (e.data && e.data.type === 'from-h5') {
	//       console.log('H5页面消息2222:', e.data.payload);
	//     }
	//   });
	// });
</script>