<template>
    <view class="video-item" v-if="item" @click="toDetailsPage(item.article_id,item.video_path)">
        <image class="head" :src="item.article_pic" v-if="item.type == 1" ></image>
		<view class="header_fist" v-else>
			<view class="backes">
                <u-icon name="play-circle-fill" color="#ffffff" size="20"></u-icon>
                <text>视频</text>
            </view>
			<image class="head" :src="item.article_pic"></image>
		</view>
        <view class="title" v-if="">{{ item.article_title }}</view>
        <view class="jianjie">{{ item.article_content }}</view>
        <view class="user">
            <view class="info">
                <image :src="item.member_avatar"></image>
                <text>{{ item.member_nickname }}</text>
            </view>
            <image src="/static/image/common/4.png" @click.stop="showAction"></image>
			<view class="action" v-if="show == item.article_id">
				<view class="bubble">
					<view @click.stop="articleLike">
						<image src="/static/image/common/5.png" v-if="item.is_like == 0"></image>
						<image src="/static/image/common/8.png" v-else></image>
						<text>点赞</text>
					</view>
					<view @click.stop="articleCollect">
						<image src="/static/image/common/6.png" v-if="item.is_collect == 0"></image>
						<image src="/static/image/common/9.png" v-else></image>
						<text>收藏</text>
					</view>
					<view @click.stop="articleAddShield">
						<image src="/static/image/common/7.png"></image>
						<text>屏蔽用户</text>
					</view>
				</view>
			</view>
			<view class="layer" v-if="show == item.article_id" @click.stop="show=-1"></view>
        </view>
    </view>
</template>
<style lang="scss" scoped>
.video-item{
    flex-shrink: 0;
    width: 335rpx;
    padding-bottom: 20rpx;
    margin-top: 20rpx;
    overflow: hidden;
    border-radius: 20rpx;
    box-shadow:0 3rpx 7rpx 0 rgba(153, 153, 153, 0.35);
    .head{
        width: 100%;
        height: 334rpx;
    }
    .title{
        margin:0 auto;
        margin-top: 4rpx;
        font-size: 28rpx;
        color: #333;
        font-weight: 500;
        line-height: 40rpx;
        width: 300rpx;
        overflow:hidden; 
        text-overflow:ellipsis;
        display:-webkit-box; 
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2; 
    }
    .jianjie{
        margin:0 auto;
        margin-top: 10rpx;
        font-size: 22rpx;
        color: #666;
        line-height: 30rpx;
        width: 300rpx;
        margin-left: 18rpx;
        overflow:hidden; 
        text-overflow:ellipsis;
        display:-webkit-box; 
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2; 
    }
    .user{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin:0 auto;
        margin-top: 20rpx;
        width: 300rpx;
		position: relative;
        .info {
            display: flex;
            align-items: center;
            >image{
                width: 38rpx;
                height: 38rpx;
                border-radius: 50%;

            }
            >text{
                font-size: 20rpx;
                color:#333;
                margin-left: 9rpx;
            }
        }
        >image{
            width: 37rpx;
            height: 8rpx;
        }
		.action {
			z-index: 19;
			position: absolute;
			right: -10rpx;
			bottom: 60rpx;
			// width: 234rpx;
			border-radius: 6rpx;
			background: rgba(255,255,255,1);
			box-shadow: 0rpx 0rpx 6rpx 0rpx rgba(35,24,21,0.12);
			.bubble {
				position: relative;
                border-radius: 20rpx;
				background-color: #fff;
				&::after {
					position: absolute;
					right: 10rpx;
					bottom: 0;
					content: '';
					width: 60rpx; 
					height: 40rpx;
					background-color: inherit;
					transform: rotate(45deg);
					margin-top: -10rpx;
					z-index: -1;
					box-shadow: 0rpx 0rpx 6rpx 0rpx rgba(35,24,21,0.12);
				}
				> view {
					display: flex;
					align-items: center;
					padding: 20rpx 30rpx;
					&:not(:last-child) {
						border-bottom: 2rpx #ECECEC solid;
					}
					@mixin image-class($width, $height, $right) {
						width: $width;
						height: $height;
						margin-right: $right;
					}
					> image {
						&:first-child {
							@include image-class($width: 30rpx, $height: 30rpx, $right: 12rpx);
						}
						&:nth-child(2) {
							@include image-class($width: 30rpx, $height: 30rpx, $right: 12rpx);
						}
						&:last-child {
							@include image-class($width: 30rpx, $height: 30rpx, $right: 9rpx);
						}
					}
					> text {
						font-size: 24rpx;
						color: rgba(51,51,51,1);
					}
				}
			}
		}
		.layer {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: 9;
			background-color: transparent;
		}
    }
	.header_fist{
		position: relative;
		.backes{
            z-index: 99;
			position: absolute;
            display: flex;
            align-items: center;
            justify-content: space-around;
			top: 10rpx;
            left: 10rpx;
			width: 80rpx;
			height: 30rpx;
            padding: 0 10rpx;
            border-radius: 30rpx;
			background-color: rgba(0,0,0,0.5);
            & > text {
                color: #fff;
                font-size: 18rpx;
            }
		}
		
	}
}
</style>
<script>
export default {
    name:"index-item",
    data(){
        return {
			show: -1,
        }
    },
	props:["isguanzhu", "item"],
	mounted() {
		// console.log(this.item);
		this.show = -1;
	},
    watch: {
        item(newVal, old) {
            // console.log(newVal);
            this.item = newVal;
        },
        deep: true
    },
	methods: {
		showAction() {
			this.show = this.show > 0 ? -1 : this.item.article_id;
		},
        // 点赞
		articleLike() {
            this.item.is_like = !this.item.is_like;
			this.$u.api.articleLike({
				article_id: this.item.article_id,
			}).then(res => {
				console.log(res)
				if(res.errCode == 0) {
                    this.$u.toast(res.message);
					// this.$emit("getArticlelist");
				}
			})
		},
        // 收藏
		articleCollect() {
            this.item.is_collect = !this.item.is_collect;
			this.$u.api.articleCollect({
				article_id: this.item.article_id,
			}).then(res => {
				console.log(res);
				if(res.errCode == 0) {
                    this.$u.toast(res.message);
					// this.$emit("getArticlelist");
				}
			})
		},
        // 屏蔽
		articleAddShield() {
			this.$u.api.articleAddShield({
				article_id: this.item.article_id,
				member_id: this.item.member_id,
			}).then(res => {
				// console.log(res)
				if(res.errCode == 0) {
                    this.$u.toast(res.message);
					this.$emit("updateList");
				} else {
                    this.$u.toast(res.message);
                }
			})
		},
		toDetailsPage(id,type) {
            if (type) {
                uni.navigateTo({
                	url: '/pageB/video/video?id=' + id
                });
            } else {
                 uni.navigateTo({
                	url: '/pageB/photo/index?id=' + id
                });
            }
		},
	},
}
</script>