<template>
	<view>
		<view class="page-body">
			<view class="page-section">
				<video id="myVideo" :src="detail.video"
				 autoplay='true' controls></video>
			</view>
			<view class="content">
				<view class="title">
					{{detail.title ? detail.title : '--'}}
				</view>
				<view class="time">
				<text>{{detail.updated_at? detail.updated_at :'--'}}</text>	<text class="num">播放量：{{detail.view_num?detail.view_num:'--'}}</text>
				</view>
				<uParse :content="detail.body"></uParse>
			</view>
			
		</view>
	</view>
</template>

<script>
	var app = getApp()
	import uParse from "@/components/feng-parse/parse.vue"
	export default {
		components: {
			uParse
		},

		data() {
			return {
				detail: ''
				// 
			}
		},
		onReady: function(res) {
			this.videoContext = uni.createVideoContext('myVideo')
		},
		onLoad(options) {
			console.log(options)
			uni.showLoading()
			app.request('/resource?id=' + options.id, '', 'get').then(res => {
				wx.hideLoading()
				if (res.statusCode == 200) {
					console.log(res, 'ppp')
					this.detail = res.data.data
				}

			})
		},
		methods: {

			bindButtonTap: function() {
				var that = this
				uni.chooseVideo({
					sourceType: ['album', 'camera'],
					maxDuration: 60,
					camera: ['front', 'back'],
					success: function(res) {
						this.src = res.tempFilePath
					}
				})
			},

			videoErrorCallback: function(e) {
				console.log('视频错误信息:')
				console.log(e.target.errMsg)
			},
			getRandomColor: function() {
				const rgb = []
				for (let i = 0; i < 3; ++i) {
					let color = Math.floor(Math.random() * 256).toString(16)
					color = color.length == 1 ? '0' + color : color
					rgb.push(color)
				}
				return '#' + rgb.join('')
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FFFFFF;
	}
	video {
		width: 100%;
	}
	.content{
		padding: 30rpx;
		.title{
			font-size: 36upx;
			margin-bottom: 20upx;
		}
		.time{
			font-size: 28upx;
			margin-bottom: 20upx;
			color: #949494;
			.num{
				display: inline-block;
				vertical-align: top;
				margin-left: 30upx;
			}
		}
	}
</style>
