<template>

	<view>

		<!-- 左侧显示略缩图、图标 -->
		<uni-list>

			<uni-list-item v-for="item in dataList" :show-arrow="true" :title="item.title" :note="item.intro"
				:rightText="stateText(item.state)" link="navigateTo" @click="showLive(item)">
			</uni-list-item>

		</uni-list>

	</view>

</template>

<script>
	export default {
		name: 'CourseLive',
		props: {
			value: Array,
			courseId: String
		},

		data() {
			return {
				current: {},
				dataList: []
			}
		},

		watch: {
			value: {
				handler(val) {
					this.dataList = val
				}
			}
		},
		created() {
			this.dataList = this.value
		},
		methods: {

			stateText(state) {
				if (state === 0) {
					return "未开始";
				}
				if (state === 1) {
					return "直播中";
				}
				if (state === 2) {
					return "已结束";
				}
			},

			showLive(live) {
				uni.navigateTo({
					url: `/pages/course/live?courseId=${this.courseId}&liveId=${live.id}&url=${encodeURIComponent(live.m3u8Url)}`
				});
			}

		}
	}
</script>

<style scoped>

</style>
