<template>
	<view>
		<web-view :src="webViewUrl"></web-view>
	</view>
</template>

<script setup>
	import {
		onMounted, ref
	} from 'vue';
	import { onLoad } from "@dcloudio/uni-app"
	const userInfo = uni.getStorageSync('userInfo')

	// 创建响应式的webview URL
	const webViewUrl = ref('')
	
	onLoad(({enterSelectTree, isScanAuthSuccess, code}) => {
		if (enterSelectTree) {
			webViewUrl.value =
				`https://feiniao-mini-h5-dev.sysuimars.cn/youwei/#/gardenMap?userId=${userInfo.id}&token=${userInfo.token}&enterSelectTree=true`
			// webViewUrl.value = "http://localhost:8081/#/gardenMap?userId=91754&token=034d7cf5-25fc-42d3-993e-460120419e5a&enterSelectTree=true"
		} else if (isScanAuthSuccess) {
			webViewUrl.value =
				`https://feiniao-mini-h5-dev.sysuimars.cn/youwei/#/gardenMap?userId=${userInfo.id}&token=${userInfo.token}&isScanAuthSuccess=true`
				// webViewUrl.value = `http://localhost:8081/#/gardenMap?userId=${userInfo.id}&token=${userInfo.token}&isScanAuthSuccess=true`
		} else if (code) {
			webViewUrl.value =
				`https://feiniao-mini-h5-dev.sysuimars.cn/youwei/#/gardenMap?userId=${userInfo.id}&token=${userInfo.token}&code=${code}`
				// webViewUrl.value = "http://localhost:8081/#/gardenMap?userId=91754&token=034d7cf5-25fc-42d3-993e-460120419e5a"
		} else {
			webViewUrl.value =
				`https://feiniao-mini-h5-dev.sysuimars.cn/youwei/#/gardenMap?userId=${userInfo.id}&token=${userInfo.token}`
				// webViewUrl.value = "http://localhost:8081/#/gardenMap?userId=91754&token=034d7cf5-25fc-42d3-993e-460120419e5a"
		}
	})
</script>