<template>
	<view class="wf-item-page" @click="gogogo(item)">



		<image :src="item.image[0]" mode="widthFix" class="item-img" />

		<view class="goods_item_img" v-if="item.video_link.length>0">
			<image src="@/static/images/sp.png" mode="aspectFill"></image>
		</view>
		<view class="title">{{item.title}}</view>
		<view class="item-info">
			<image :src="(item.author && item.author.avatar) || '/static/images/f.png'" mode="aspectFill"
				class="info-avatar" />
			<view class="info-nickname">{{ item.author.nickname }}</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo
	} from '@/api/user.js';
	export default {
		props: {
			item: {
				type: Object,
				require: true
			}
		},



		data() {
			return {
				user_id: ''
			}
		},

		mounted() {
			this.getUserInfo()
		},


		methods: {
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					this.user_id = res.data.uid
				});
			},
			gogogo(item) {
				if (item.video_link.length > 0) {
					uni.navigateTo({
						// #ifdef MP || H5
						url: `/pages/short_video/nvueSwiper/index?id=${item.community_id}&uid=${this.user_id}&user=1`
						// #endif
						// #ifdef APP
						url: `/pages/short_video/appSwiper/index?id=${item.community_id}&uid=${this.user_id}&user=1`
						// #endif
					})

				} else {
					uni.navigateTo({
						url: `/pages/plantGrass/plant_detail/index?id=${item.community_id}`
					})
				}
			},

		}

	}
</script>

<style lang="scss" scoped>
	.wf-item-page {
		background: #fff;
		overflow: hidden;
		border-radius: 5px;

		position: relative;
	}

	.item-img {
		width: 100%;
	}

	.item-info {
		display: flex;
		align-items: center;
		padding: 5px;
	}

	.goods_item_img {
		position: absolute;
		top: 20rpx;
		right: 18rpx;
		width: 52rpx;
		height: 52rpx;
		z-index: 1 !important;


		image {
			width: 100%;
			height: 100%;
		}
	}

	.title {
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		margin: 12px 0;
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		padding: 0 5px;
	}

	.info-avatar {
		width: 49rpx;
		height: 49rpx;
		border-radius: 50%;
		margin-right: 5px;
	}

	.info-nickname {
		font-size: 12px;
		color: #333;
	}
</style>