<template>
	<view :class="[AppTheme]">
		<!-- 导航 -->
		<!-- #ifdef APP-PLUS || MP-WEIXIN -->
		<u-sticky offset-top="0" style="z-index: 10;">
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<u-sticky offset-top="-44" style="z-index: 10;">
				<!-- #endif -->
				<view class="nav bg-white">
					<u-tabs ref="uTabs" @click="tabs" :list="nav_status_list" :scrollable="false" lineWidth="30"
						:lineColor="primary" :current="tabscurrent" :activeStyle="{
			     color: primary,
			     transform: 'scale(1.05)'
			 }" :inactiveStyle="{
			     color: '#606266',
			     transform: 'scale(1)'
			 }">
					</u-tabs>
				</view>
			</u-sticky>

			<!-- 列表 -->
			<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="30">
				<view v-if="livedata.length>0" class="data-list">
					<view @click="godetail(item.roomid)" v-for="(item, index) in livedata" :key="index"
						class="item padding-main border-radius-main bg-white oh pr spacing-mb">
						<view class="navigator" hover-class="none">
							<image class="fl radius" :src="item.share_img" mode="aspectFit"></image>
							<view class="base fl">
								<view class="single-text text-size">{{item.name}}</view>
								<view class="margin-top-xl oh">
									<view class="start_time">开播时间</view>
									<view class="time">
										<view class="fl cr-green">{{item.start_time}}</view>
										<view class="fl cr-red">{{item.end_time}}</view>
									</view>
								</view>
							</view>
							<view v-if="item.live_status==102" :class="'status pa status-' + item.live_status">未开始
							</view>
							<view v-if="item.live_status==101" :class="'status pa status-' + item.live_status">直播中
							</view>
							<view v-if="item.live_status==103" :class="'status pa status-' + item.live_status">已结束
							</view>
							<view v-if="item.live_status==105" :class="'status pa status-' + item.live_status">暂停中
							</view>
						</view>
					</view>
					<u-loadmore line :status="status"></u-loadmore>
				</view>
				<view v-else style="padding-top: 100px;">
					<!-- 提示信息 -->
					<u-empty text="暂时无直播" mode="list"></u-empty>
				</view>

				<!-- 结尾 -->
			</scroll-view>
	</view>
</template>
<script>
	const app = getApp();
	import componentNoData from "@/pagesC/components/no-data/no-data.vue";
	import mineApi from "@/api/mine/index.js"
	export default {
		data() {
			return {
				status: "loadmore",
				primary: this.$theme.primary,
				tabscurrent: 0, //tabs当前选中标签的索引
				livedata: [],
				data_list_loding_status: 1,
				data_bottom_line_status: false,
				params: null,
				load_status: 0,
				data_list: [],
				data_base: null,
				data_total: 0,
				data_page_total: 0,
				data_page: 1,
				nav_status_list: [{
						name: "全部",
						value: ""
					},
					{
						name: "未开始",
						value: "102"
					},
					{
						name: "直播中",
						value: "101"
					},
					{
						name: "暂停中",
						value: "105"
					},
					{
						name: "已结束",
						value: "103"
					},
				],
				nav_status_index: 0,
				// 自定义分享信息
				share_info: {},
				p: 1
			};
		},

		components: {
			componentNoData
		},
		props: {},

		onLoad(params) {

			this.getliverooms(0, 1)
			// 是否指定状态
			var nav_status_index = 0;
			if ((params.status || null) != null) {
				for (var i in this.nav_status_list) {
					if (this.nav_status_list[i]['value'] == params.status) {
						nav_status_index = i;
						break;
					}
				}
			}
			// this.setData({
			//     params: params,
			//     nav_status_index: nav_status_index
			// });
			// this.init();
		},

		onShow() {},

		// 下拉刷新
		onPullDownRefresh() {
			this.setData({
				data_page: 1
			});
			this.get_data_list(1);
		},

		methods: {
			godetail(id) {
				var params = encodeURIComponent(JSON.stringify({
					type: 'detail'
				}));
				uni.navigateTo({
					url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}&custom_params=${params}`
				})
			},
			tabs(e) { //tabs切换的回调
				console.log(e, "eee")
				this.livedata = []
				let type = e.value
				this.getliverooms(type, 1)
			},
			//获取直播列表
			getliverooms(status, p) {
				let data = {
					live_status: status,
					p: p
				}
				mineApi.room_list(data).then(res => {
					if (res.status == 1) {
						res.data.forEach(ele => {
							this.livedata.push(ele)
						})
						if (res.data.length == 10) {
							this.status = "loanmore"
						} else {
							this.status = 'nomore'
						}
					} else {
						this.status = 'nomore'
					}
				})
			},
			// 滚动加载
			scroll_lower(e) {
				this.get_data_list();
			},
		}
	};
</script>
<style scoped lang="scss">
	/*
	* 导航
	*/
	.nav {
		height: 80rpx;
		line-height: 80rpx;
	}

	.nav .item {
		width: 20%;
	}

	/**
	* 数据列表
	*/
	.data-list {
		overflow: scroll;
	}

	.data-list .item {
		background-color: #fff;
		margin: 0 20rpx;
		border-radius: 20rpx;
		margin-top: 20rpx;
		box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.08);

		.navigator {
			display: flex;
			justify-content: space-evenly;
			align-items: center;
			padding: 15rpx;
			position: relative;

			image {
				width: 160rpx;
				height: 160rpx !important;
				border-radius: 10rpx !important;
			}

			.base {
				width: calc(100% - 190rpx);
				text-align: left;
				padding: 0 10rpx 0 20rpx;

				.text-size {
					font-size: 32rpx !important;
				}

				.margin-top-xl {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					margin-top: 20rpx;

					.start_time {
						width: 60rpx;
						background: #7ad2ff;
						line-height: 30rpx;
						font-size: 26rpx !important;
						padding: 10rpx;
						color: #fff;
						text-align: center;
						border-radius: 10rpx !important
					}

					.time {
						font-size: 26rpx !important;
						margin-left: 10rpx;

						view {
							padding: 10rpx;
						}
					}
				}
			}

			.status {
				font-size: 26rpx;
				position: absolute;
				bottom: 20rpx;
				right: 20rpx;
			}
		}
	}

	.data-list .ite .status-102 {
		color: #0e90d2;
	}

	.data-list .item .status-101 {
		color: #5eb95e;
	}

	.data-list .item .status-103 {
		color: #F37B1D;
	}

	.data-list .item .status-105 {
		color: #888;
	}
</style>
