<template>
	<view class="monitor-video">
		<web-view id="web_view" :src="webURL"></web-view>
		<!-- <web-view  :src="url" ></web-view> -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				webURL: '', // web-view要引入的页面url
				cameraIndexCode: 'a639bb55c237414f8c487c409d5789c7', // 监控设备编号
				cameraList: [],
				codelist:'',
				cameraUrl:'ws://171.16.8.53:1883/openUrl/uKPIUtb'
			}
		},
		//       onLoad() {
		// 	this.previewURLs()
		// },
		onLoad(options) {
			// console.log('options ===>', JSON.parse(options.list))
			this.cameraList = JSON.parse(options.list)
			let arr = []
			// this.cameraList.map(item =>{
			// 	if(item.tags){
			// 		arr.push(JSON.parse(item.tags).cameraIndexCode)
			// 	}
			// })
			// console.log('arr ====>',arr.join(','))
			this.previewURLs()
			// this.getUrl()
		},
		methods: {
			// getUrl(){
			// 	uni.request({
			// 		url: getApp().globalData.apiUrl + '/alarmInformation/preview?code=' + JSON.parse(this.cameraList.tags).cameraIndexCode,
			// 		method: 'GET',
			// 		success: (res) => {
			// 			console.log('res =====>',res)
			// 			if(res.data.code == 0 || res.data.code == 200){
			// 				this.previewURLs(res.data.data)
			// 			}else{
			// 				// 'ws://171.16.8.60:559/openUrl/QKCBP32'
			// 				this.previewURLs()
			// 			}
			// 		}
			// 	})
			// },
			// 获取视频流
			previewURLs() {
				// 视频流需要根据监控设备编号获取 接口请求这里省略
				// cameraUrl 走后台接口获取到监控的视频流
				this.webURL = 
				    '/static/html/webpalyer.html?carmeraCode=' + encodeURIComponent(JSON.stringify(this.cameraList))
						// this.webURL =
						//     '/static/html/webpalyer.html?carmeraCode=' + this.cameraIndexCode + "&cameraUrl=" + this.cameraUrl
				// this.webURL = "/static/html/webplayer.html?cameraIndexCode=" + this.cameraIndexCode + "&cameraUrl=" + this.cameraUrl
			}
		}
	}
</script>