<template>
	<view class="container">
		<view class="list-icon"></view>
		<view class="title">{{videoName}}</view>
		<video class="video" id="myVideo" ref="video1" :src="videoUrl"
				 loop=true 
				 enable-danmu danmu-btn controls enable-progress-gesture show-mute-btn
				></video>
		<!-- <view class="video"></view> -->
		<view class="jieshao">{{videoDescription}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				videoUrl:'',//视频链接
				videoDescription:'',
				videoName:'',//视频名
				id:'',
				list:[],//当前页面数据
				resultDecodeN:'',//解密后
				token:'',//缓存token
			}
		},
		onShow(){
			this.getList()
			if(wx.getStorageSync('token')==''){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
		},
		onLoad(option) {
			// this.videoUrl=option.video
			// this.videoDescription=option.videoDescription
			// this.videoName=option.videoName
			this.id=option.id
			this.token=wx.getStorageSync('token')
			
		},
		methods: {
			getList(){
				this.list=[]
				this.resultDecodeN=''
				this.$axios.get('/videos/api/video/video',
				{
					headers:{
						'token':wx.getStorageSync('token')
					}
				}
				).then(res => {
					if(res.data.message=='token已过期'){
						uni.navigateTo({
							url:'/pages/login/login'
						})
					}
					if (res.data.success) {
						var shu=res.data.data
						var length=Object.values(res.data.data).length
						// console.log(Object.values(res.data.data).length)
						// 开始解密
						for(var i=0;i<length;i++){
							this.resultDecodeN =this.resultDecodeN+this.$fns.rsaDecode(shu[i])
						}
						// 开始解密
						// this.resultDecodeN = this.$fns.rsaDecode(shu[0])+
						// this.$fns.rsaDecode(shu[1])+this.$fns.rsaDecode(shu[2])+
						// this.$fns.rsaDecode(shu[3])+this.$fns.rsaDecode(shu[4])+
						// this.$fns.rsaDecode(shu[5])+this.$fns.rsaDecode(shu[6])+
						// this.$fns.rsaDecode(shu[7])+this.$fns.rsaDecode(shu[8])+
						// this.$fns.rsaDecode(shu[9])
						
						//解析
						console.log(JSON.parse(this.resultDecodeN));
						//获取数组
						JSON.parse(this.resultDecodeN).forEach(data => {
							this.list.push(data)
						})
						var length=JSON.parse(this.resultDecodeN).length
						//根据id判断
						for(var i=0;i<length;i++){
							console.log(this.list[i].id)
							if(this.id==this.list[i].id){
								this.videoUrl=this.list[i].videoUrl
								this.videoDescription=this.list[i].videoDescription
								this.videoName=this.list[i].videoName
							}
						}
					} else {
						uni.showToast({ title: res.data.message, icon: 'none' });
					}
				}).catch(res =>{
				});
			},
		}
	}
</script>

<style>
	.container {
		/* padding: 10px 20px 20px 15px; */
		font-size: 16px;
		line-height: 24px;
		background-image: url('../../static/video_bg.png');
		width: 749rpx;
		height: 1211rpx;
		background-size: 100%;
	}
	.list-icon{
		position: absolute;
		margin-left: 32px;
		margin-top: 253px;
		width: 8rpx;
		height: 18px;
		opacity: 1;
		border-radius: 33rpx;
		background: #FFFFFF;
	}
	.title{
		line-height: 19px;
		position: absolute;
		margin-left: 43px;
		margin-top: 251px;
		font-size: 19px;
		font-family: Microsoft YaHei-3970(82674968);
		font-weight: 400;
		color: #FFFFFF;
	}
	.video{
		position: absolute;
		margin-left: 42px;
		margin-top: 278px;
		width: 283px;
		height: 347rpx;
	}
	.jieshao{
		position: absolute;
		margin-left: 32px;
		margin-top: 465px;
		color: #FFFFFF;
	}
</style>