<template>
	<view v-if="showXtDanmu" class="xt-video-send">
		<view class="xt-video-mask" @click="_hide"></view>
		<view class="xt-video-send-bottom">
			<input v-model="value" class="xt-video-input" placeholder="发条弹幕吧~" placeholder-style="font-size:32rpx;" />
			<view
				class="xt-video-send-btn"
				:style="{
					'backgroundColor': activeColor
				}"
				@click="xtVideoSendDanmu"
			>
				<text>发送</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			activeColor: {
				type: String,
				default: '#03A3F8'
			}
		},
		data() {
			return {
				value: '',
				showXtDanmu: false
			}
		},
		methods: {
			// 展示
			_show() {
				this.showXtDanmu = true
			},
			
			_hide() {
				this.showXtDanmu = false
			},
			
			// 发送弹幕
			xtVideoSendDanmu() {
				this.$emit('onSendDanmu', {
					width: rect.width,
					value: this.value
				})
				this._hide()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.xt-video-send {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 666;
		display: flex;
		flex-direction: column;
		.xt-video-mask {
			flex: 1;
			background-color: rgba(0, 0, 0, 0.5);
		}
		&-bottom {
			box-sizing: border-box;
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 178rpx;
			background-color: #fff;
			display: flex;
			align-items: center;
			padding: 20rpx 24rpx;
		}
		.xt-video-input {
			flex: 1;
			padding: 20rpx;
			background-color: #F6F5F5;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}
		.xt-video-send-btn {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 100rpx;
			height: 58rpx;
			border-radius: 29rpx;
			> text {
				font-size: 28rpx;
				color: #fff;
			}
		}
		.xt-danmu-text {
			display: flex;
		}
	}
</style>