<template>
	<view class="waterfall-item" :style="{width,...customStyle}" @click="goWork(item)">
		<view class="waterfall-item__image" :style="{width,backgroundColor:item.backgroundColor}">
			<image :src="item.image" mode="widthFix" style="border-radius: 20rpx;"></image>
		</view>
		<view class="waterfall-item__ft">
			<view class="waterfall-item__ft__title">
				<text class="value" :style="{color:textColor}">{{item.title}}</text>
			</view>
			<view class="waterfall-item__ft__desc">
				<view class="user">
					<image :src="item.avator" mode="aspectFill" class="avater">
					</image>
					<text class="name" :style="{color:textColor}">{{item.nickname}}</text>
				</view>
				<view class="like" @click="changeLike">
					<image class="like-icon" :src="isLike ?'/static/icon/icon-18.png':'/static/icon/icon-19.png'" mode="">
					</image>
					<text class="value" :style="{color:textColor}">{{item.num_like}}</text>
				</view>
			</view>
			 
		</view>
		<view class="waterfall-item__tips">
			<view class="item">
				<image class="look-icon" src="@/static/icon/icon-17.png" mode=""></image>
				<text class="value" style="color: #fff;">{{item.num_view}}</text>
			</view>
			<view class="item" style="background-color: #1F1F1F;">
				<text class="value" style="color: #ACF934;">精选</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "meCard",
		props: {
			width: {
				type: String,
				default: ''
			},
			item: {
				type: Object,
				default: () => ({})
			},
			textColor: {
				type: String,
				default: '#ff0000'
			},
			customStyle: {
				type: Object,
				default: () => ({
					background: '#3F4141',
				})
			}
		},
		data() {
			return {
				isLike: false,
			};
		},
		methods: {
			changeLike() {
				this.isLike = !this.isLike
			},
			goWork(item) {
				uni.$emit('check_login', () => {
					uni.navigateTo({
						url: '/pages/index/workDetail?id=' + item.id
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.waterfall-item {
		margin-bottom: 20rpx;
		border-radius: 30rpx;
		position: relative;

		// #ifndef APP-NVUE
		.waterfall-item__image {
			width: 100%;
			height: auto;
			box-sizing: border-box;
			padding: 28rpx 20rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}

		// #endif
		.waterfall-item__tips {
			position: absolute;
			top: 10rpx;
			padding: 0rpx 10rpx;
			// #ifndef APP-NVUE
			box-sizing: border-box;
			// #endif
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;

			.item {
				// #ifndef APP-NVUE
				// #endif
				display: flex;
				flex-direction: row;
				align-items: center;
				background: rgba(0, 0, 0, 0.2);
				padding: 4rpx 14rpx;
				border-radius: 12rpx;

				.look-icon {
					width: 26rpx;
					height: 26rpx;
					margin-right: 10rpx;
				}

				.value {
					font-size: 20rpx;
				}
			}
		}

		.waterfall-item__ft {
			padding: 10rpx 20rpx;

			&__title {
				line-height: 48rpx;
				font-weight: 700;

				.value {
					font-size: 30rpx;
				}
			}

			&__desc {
				width: 100%;
				// #ifndef APP-NVUE
				display: flex;
				// #endif
				// #ifdef APP-NVUE
				// #endif
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				margin: 20rpx 0;

				.user {
					// #ifndef APP-NVUE
					display: flex;
					// #endif
					// #ifdef APP-NVUE
					flex-direction: row;
					// #endif
					align-items: center;

					.avater {
						width: 36rpx;
						height: 36rpx;
						border-radius: 18rpx;
						margin-right: 10rpx;
					}

					.name {
						font-size: 24rpx;
					}
				}

				.like {
					// #ifndef APP-NVUE
					display: flex;
					// #endif
					// #ifdef APP-NVUE
					flex-direction: row;
					// #endif
					align-items: center;

					.like-icon {
						width: 30rpx;
						height: 30rpx;
						margin-right: 10rpx;
					}

					.value {
						font-size: 24rpx;
					}
				}
			}

			&__btn {
				height: 65rpx;
				border-radius: 18px;
				background-image: linear-gradient(to bottom, #BFFE9C, #AEE75D);
				// #ifndef APP-NVUE
				background: linear-gradient(180deg, #BFFE9C 0%, #AEE75D 62%, #AEE75D 100%);
				display: flex;
				// #endif
				justify-content: center;
				align-items: center;

				&__icon {
					width: 155rpx;
					height: 32rpx;
				}
			}
		}
	}
</style>