<template>
	<view>
		<web-view :src="src" @message="handlePostMessage"></web-view>
	</view>
</template>

<script>
	const {H5ServerUrl} = require('@/static/api');
	export default {
		data() {
			return {
				src:'',
			};
		},
		onLoad(options) {
			let token = uni.getStorageSync('token').token;
			let start = options.startTime;
			let end = options.endTime;
			let time = options.time;
			this.src = 'https://zhongnengyunche.com/dispatching/'+ H5ServerUrl +'/index.html?id='+options.id+'&start='+start+'&end='+end+'&token='+token+'&time='+time;
			console.log('h5src:',this.src);
		},
		methods:{
			handlePostMessage(e) {
			    let resObj = e.detail.data[e.detail.data.length - 1];
				//多次传递会是数组的形式，传递一次会push进数组，所以我们需要拿到最新的数据，也就是数组的最后一个子集
			    console.log('h5传参',resObj.message)
				if(resObj.message == 0){ 
					uni.showToast({
						title: '暂无轨迹',
						icon: 'none'
					}); 
				}else{
					uni.showToast({
						title: '加载失败',
						icon: 'none'
					}); 
				}
			},
		}
		
	}
</script>

<style lang="scss" scoped>

</style>
