<template>
	<view class="box">
		<!-- 1 回放  2.直播列表 -->
		<view v-if="flag == 1" class="boxlist">
			<view  v-if="item.live_status=='101'" @click="nextTo(item,ind, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
				<image class="imgbox" :src="item.share_img" mode=""></image>
				<view class="dffd flex1">
					<view class="title elli">{{ item.name }}</view>
					<view class="textgrey fontsm">{{ item.up_name }}</view>
					<view class="auth dfsb">
						<text class="fontssm textgrey">作者：{{ item.anchor_name }}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- <navigator url="plugin-private://wx00d3d08bf67e853e/pages/live-player-plugin?room_id=6&custom_params=''">
			gogoogogog
		</navigator> -->
		<view v-if="flag == 2" class="boxlist">
			<view v-if="item.live_status !='101'" @click="nextTo(item,ind, 2)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
				<image class="imgbox" :src="item.share_img" mode=""></image>
				<view class="dffd flex1">
					<view class="title elli">{{ item.name }}</view>
					<!-- 101：直播中，102：未开始，103已结束，104禁播，105：暂停，106：异常，107：已过期 -->
					<view class="textgrey fontsm">{{ item.live_status=='101'?'直播中':item.live_status=='102'?'未开始':item.live_status=='103'?'已结束，观看回放':'暂未开始' }}</view>
					<view class="auth dfsb">
						<text class="fontssm textgrey">作者：{{ item.anchor_name }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {};
	},
	props: {
		list: {
			type: Array,
			default: []
		},
		flag: {
			type: [String, Number],
			default: 1 //1 回放  2.直播列表
		}
	},
	methods: {
		nextTo(item,ind, val) {
			if (val == 1) {  
				let roomId = item.roomid; // 填写具体的房间号，可通过下面【获取直播房间列表】 API 获取
				let customParams = '' // 开发者在直播间页面路径上携带自定义参数（如示例中的path和pid参数），后续可以在分享卡片链接和跳转至商详页时获取，详见【获取自定义参数】、【直播间到商详页面携带参数】章节（上限600个字符，超过部分会被截断）
				uni.navigateTo({
				    url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
				})
			}else{
				// uni.navigateTo({
				// 	url:'/pagesA/broadcast/blist?item='+JSON.stringify(item)
				// }); 
					this.$api.request('live/get_replay', { roomid: item.roomid }).then(data => {
						if (data.code == 200) {
							let  media_url= data.data.live_replay[0].media_url;
							uni.navigateTo({
								url: '/pagesA/broadcast/bdInfo?media_url=' + JSON.stringify(media_url)
							}); 
							
							console.log(media_url);
						} else {
							this.$api.toast(data.msg);
						}
					}); 
			} 
		}
	}
};
</script>

<style scoped lang="scss">
.boxlist {
	.vidLi {
		width: 100%;
		padding: 27rpx 0;
		background-color: #fff;
		&:nth-of-type(2n) {
			margin-right: 0;
		}
		.imgbox {
			width: 146rpx;
			height: 146rpx;
			margin-right: 18rpx;
			border-radius: 10rpx;
		}
		.title {
			font-size: 28rpx;
			line-height: 40rpx;
			margin-bottom: 12rpx;
		}
		.auth {
			margin-top: 15rpx;
			width: 100%;
		}
		.down {
			width: 35rpx;
			height: 30rpx;
			margin-left: 58rpx;
		}
	}
}
</style>
