<template>
	<web-view :src="url" @message="handleMessage" @load="handleLoad" @error="handleError"></web-view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
			}
		},
		onLoad() {
			const eventChannel = this.getOpenerEventChannel();
			eventChannel.on('acceptData', (data) => {
				this.url = data.url;
			});
		},
		methods: {
			handleMessage(e) {
				console.log(e.detail.data);
				const data = e.detail.data || [];
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('callbackData', data[0] || {});
			},
			// 加载完成
			handleLoad(e) {
				
			},
			// 加载失败
			handleError(e) {
				uni.showToast({ title: '加载失败', icon: 'none' });
			}
		}
	}
</script>

<style>
</style>