<template>
	<div class="page-box">
		<img v-if="channelInfo.pcBackgroundUrl" class="bg-img" :src="channelInfo.pcBackgroundUrl" alt="">
		<img v-else class="bg-img" :src="require(`@/assets/img/pc-bg.png`)" alt="">
		<div class="live">
			<div class="container-box">
				<div class="content-box">
					<div class="left-box">
						<div class="header-box">
							<h1 class="title">{{channelInfo.channelName}}</h1>
							<ul class="btn-list">
								<li class="follow" v-if="wechatInfo.status">
									<a href="javascript:;" @click="_showFollow">关注公众号</a>
								</li>
								<li class="wap-watch">
									<a href="javascript:;">手机观看</a>
									<div class="show-box">
										<img :src="`https://console.guangdianyun.tv/qrcode.php?level=L&size=10&text=${slefHref}`">
									</div>
								</li>
							</ul>
						</div>
						<div class="mps-box">
							<div class="player-box">
								<player-box></player-box>
								<auth-box v-if="channelInfo.needPay == 1"></auth-box>
							</div>
						</div>
					</div>
					<div class="right-box">
						<div class="chat-box">
							<div class="chat-header">
								<div class="user-head" v-if="userInfo.id" @click="_goMyCenter">
									<span class="name">{{userInfo.userNick}}</span>
									<img  class="head" width="50" height="50" :src="userInfo.userHeadImg" alt="">
								</div>
								<div class="login-btn" v-else @click="_toggleLogin">登录</div>
							</div>
							<div class="chat-body">
								<div class="chat-list-box">
									<chat-box v-if="isChat"></chat-box>
								</div>
							</div>
							<div class="chat-footer">
								<div class="chat-input-box">
									<send-chat v-if="isChat"></send-chat>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="camera-box" v-if="channelInfo.cameraShowStatus == 1">
					<camera-box></camera-box>
				</div>
				<div class="menu-box" v-if="menuListPc.length">
					<menus-tab v-model="menusActive"></menus-tab>
					<menus-list v-model="menusActive"></menus-list>
				</div>
			</div>
		</div>
		<transition name="fade">
			<follow-box></follow-box>
		</transition>
		<transition name="fade">
			<red-box></red-box>
		</transition>
		<login-box></login-box>
		<!--加密直播-->
		<transition name="fade">
			<encrypt-box></encrypt-box>
		</transition>
	</div>
</template>
<script>
    import { mapGetters,mapMutations } from 'vuex'
	const menusTab = resolve => require(['@/components/modules/menus/tabPc'],resolve)
	const menusList = resolve => require(['@/components/modules/menus/listPc'],resolve)
	const cameraBox = resolve => require(['@/components/modules/camera/indexPc'],resolve)
	const chatBox = resolve => require(['@/components/modules/menus/menuClass/chatPc'],resolve)
	const sendChat = resolve => require(['@/components/modules/sendChat/indexPC'],resolve)
    const authBox = resolve => require(['@/components/modules/auth/index'],resolve)
    const redBox = resolve => require(['@/components/modules/red/indexPc'],resolve)
    import playerBox from '@/components/modules/player/indexPc'
    import followBox from '@/components/modules/follow/index'
    import loginBox from '@/components/modules/login/index'
    import encryptBox from '@/components/modules/encrypt/index'

	export default{
		components: {
			playerBox,
			menusTab,
			menusList,
			cameraBox,
			followBox,
			loginBox,
			redBox,
			chatBox,
			sendChat,
			authBox,
			encryptBox,
		},
		data(){
			return {
                slefHref: '',
                menusActive: 0,
			}
		},
		computed: {
            ...mapGetters({
                'channelInfo': 'channelInfo',
                'menuList': 'menuList',
                'menuListPc': 'menuListPc',
                'userInfo': 'userInfo',
                'wechatInfo': 'wechatInfo',
                'jumpUrls': 'jumpUrls'
            }),
            isChat(){
		        for(let i = 0; i < this.menuList.length; i++){
		            let item = this.menuList[i];
		            if(item.menuType == 'chat'){
		            	return true
		            }
		        }
		        return false;
            }
        },
        mounted(){
        	this.slefHref = encodeURIComponent(window.location.href);
        },
        methods: {
        	...mapMutations({
                'set_wechatInfo': 'set_wechatInfo'
            }),
        	_showFollow(){
                let info = JSON.parse(JSON.stringify(this.wechatInfo));
                info.isShow = true;
                this.set_wechatInfo(info)
            },
            _toggleLogin(){
            	this.$Bus.$emit('bus-showLogin', true)
            },
            _goMyCenter(){
                if(!this.userInfo.id){
                    this.$Bus.$emit('bus-showLogin', true);
                }else if( this.corpId == 1421){
                    return false;
                }else{
                    window.location.href = this.jumpUrls.center;
                }
            },
        },
	}
</script>
<style lang="less" scoped>
.page-box{
	width: 100vw;
	height: 100vh;
	position: relative;
	.bg-img{
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.live{
		padding: 20px;	
		position: relative;
		z-index: 1;
		width: 100%;
		height: 100%;
		overflow: auto;
	}
}
.container-box{
	margin: auto;
	width: 1600px;
	.content-box{
		height: 773px;
	}
}
@media screen and (max-width: 1600px) {
	.container-box{
		width: 1300px;

		.content-box{
			height: 603px;
		}
	}
}
@media screen and (max-width: 1300px) {
	.container-box{
		width: 1000px;

		.content-box{
			height: 436px;
		}
	}
}
.content-box {
	display: flex;
	.left-box {
		flex: 1;
		height: 100%;
		margin-right: 10px;
		.header-box {
			position: relative;
			margin-bottom: 10px;
			padding: 5px 10px;
			height: 60px;
			background-color: rgba(255, 255, 255, 0.6);
			.title{
				max-width: 400px;
				line-height: 50px;
				font-size: 22px;
				color: #333333;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
			.btn-list{
				position: absolute;
				right: 10px;
				top: 5px;
				li{
					position: relative;
					display: inline-block;
					margin-left: 10px;
					padding: 7px 0;
					a{
						display: inline-block;
						text-align: center;
						line-height: 36px;
						padding: 0 15px;
						color: #fff;
						border-radius: 30px;
						min-width: 100px;
						background: -webkit-linear-gradient(left, #7F6BFE, #49C1F5);
					}
					.show-box{
						display: none;
						position: absolute;
						top: 100%;
						left: 50%;
						z-index: 1000;
						width: 0;
						transform: translateX(-50%);
						border: 5px solid;
						border-image: -webkit-linear-gradient(left, #7F6BFE, #49C1F5) 1 1 !important;
						img{
							display: block;
							width: 100%;
							height: 100%;
						}
					}
					&:hover{
						.show-box{
							display: block;
							width: 200px;
							height: 200px;
						}
					}

				}
			}
		}
		.mps-box {
			position: relative;
			padding-top: calc(9 / 16 * 100%);
			height: 0;
			background-color: rgba(255, 255, 255, 0.8);
			color: #000000;
			.player-box {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				overflow: hidden;
			}
		}
	}
	.right-box {
		flex: 0 0 340px;
		width: 340px;
		height: 100%;
		background-color: rgba(255,255,255,0.5);
		.chat-box {
			position: relative;
			height: 100%;
			.chat-header {
				position: absolute;
				top: 0;
				left: 0;
				z-index: 3;
				width: 100%;
				height: 60px;
				background-color: rgba(255,255,255,0.5);

				.user-head{
					position: absolute;
					right: 0;
					top: 0;
					padding: 5px 10px 5px 0;
					cursor: pointer;

					.name{
						vertical-align: top;
						display: inline-block;
						height: 20px;
						line-height: 20px;
						margin-top: 15px;
						margin-right: 5px;
						color: #333333;
						font-size: 14px;
					}
					.head{
						vertical-align: top;
						border-radius: 50%;
					}
					// .operation{
					// 	display: none;
					// 	position: absolute;
					// 	right: 0;
					// 	top: 100%;
					// 	z-index: 9999
					// }
					// &:hover{
					// 	.operation{
					// 		display: block;
					// 	}
					// }
				}
				.login-btn{
					position: absolute;
					right: 10px;
					top: 15px;
					display: inline-block;
					padding: 0 10px;
					min-width: 100px;
					line-height: 33px;
					text-align: center;
					color: #fff;
					border-radius: 35px;
					border: 0;
					outline: 0;
					background: -webkit-linear-gradient(left, #7F6BFE, #49C1F5);
					cursor: pointer;
				}
			}
			.chat-body {
				position: relative;
				z-index: 2;
				height: 100%;
				padding: 60px 0 120px 0;

				.chat-list-box{
					height: 100%;
					overflow: hidden;
				}
			}
			.chat-footer {
				position: absolute;
				bottom: 0;
				left: 0;
				z-index: 3;
				width: 100%;
				height: 120px;
			}
		}
	}
}
.camera-box{
	margin-top: 10px;
}
.menu-box{
	margin-top: 10px;
}
</style>



