<template>
  <view class="webview-container">
    <view class="webview">
      <web-view :src="url" id="webcon" cache-control="no-cache">
      </web-view>
    </view>
  </view>
</template>

<script>

	export default {
		data() {
			return {
				url: '',
				device_id: '',
				accessToken: ''
			}
		},
		onLoad(options) {
			this.device_id = options.device_id
			this.accessToken = uni.getStorageSync('session_key')
      console.log(this.accessToken,'accessTokenaccessToken')
			// 使用修改后的h52.html，支持dgp播放
			this.url = "https://wx.hnyfwlw.com/wexin/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken + "&videoType=dgp"
			// this.url = "https://demo.nyzhwlw.com/wechat?device_id=" + this.device_id + "&accessToken=" + this.accessToken
			//设置 webview 界面的状态栏的 title
			uni.setNavigationBarTitle({
				title: '监控详情'
			});
			
			// 监听来自webview的消息
			window.addEventListener('message', (event) => {
				console.log('收到webview消息:', event.data);
				if (event.data && event.data.type === 'navigate') {
					uni.navigateTo({
						url: event.data.url
					});
				}
			});
		},
		methods: {
      nativeTo(){
        uni.navigateTo({
					url: '/pages/monitor/imagelist?id=' + this.device_id
				})
      },
      nativeToLanch(){
				uni.navigateTo({
					url: '/pages/monitor/dgpImagelist?id=' + this.device_id
				})
      },
		}
	}
</script>

<style>
.webview-container{
  height: 100vh;
}
.webview {
  width: 100vw;
  height: 90vh;
}

</style>
