<template>
	<view class="discussion-page">



		<!-- 项目卡片 -->
		<view class="project-card">
			<image class="project-img" src="@/static/crowdFunding/top-img.png" />
			<view class="project-info">
				<view class="project-title two-omit">【Woh】灯塔 塔罗牌 治愈风泛伟特系伟特系伟特系</view>
			</view>
		</view>
		<view class="tabs">
			<view class="tab-item" @click="checkTab(item.id)" v-for="(item, index) in cate" :key="index">

				<view class="tab" :class="{ active: tab === item.id }">
					<text class="left">{{ item.name }}</text>
					<view class="line"></view>
				</view>
			</view> 
		</view>
		 


		<!-- tab内容 -->
		<view v-if="tab === 1" class="update-list">
			<block v-for="(item, idx) in updateList" :key="idx">
				<view class="update-item">
					<view class="update-title">第{{ item.index }}次更新</view>
					<view class="update-content">{{ item.content }}</view>
					<view class="update-user">
						<image class="avatar" :src="item.avatar" />
						<text class="nickname">{{ item.nickname }}</text>
					</view>
					<image class="update-img" :src="'../../static/crowdFunding/top-img.png'" mode="widthFix" />
					<view class="update-footer">
						<text class="update-time">{{ item.time }}</text>
						<view class="update-like">
							<image :src="item.liked ? '/static/icon/icon-18.png' : '/static/icon/icon-19.png'"
								class="like-icon" />
							<text class="like-num">{{ item.likeNum }}</text>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view v-else class="comment-list">
			<block v-for="(item, idx) in commentList" :key="idx">
				<view class="comment-item">
					<image class="avatar" :src="item.avatar" />
					<view class="comment-main">
						<view class="comment-content">{{ item.content }}</view>
						<view class="comment-footer">
							<text class="nickname">{{ item.nickname }}</text>
							<text class="comment-time">{{ item.time }}</text>
						</view>
					</view>
					<view class="comment-like">
						<image :src="item.liked ? '/static/icon/icon-18.png' : '/static/icon/icon-19.png'"
							class="like-icon" />
						<text class="like-num">{{ item.likeNum }}</text>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			tab: 1,
			updateList: [
				{
					index: 2,
					content: '附赠精品灯塔牌包装，附赠精品灯塔牌包装',
					avatar: '/static/crowdFunding/top-img.png',
					nickname: '也许时间是一种解药',
					img: 'https://img.zcool.cn/community/01b6b95d5b2e2fa801216518a7e7e7.jpg',
					time: '2025.5.23 16:23',
					likeNum: 12,
					liked: false
				},
				{
					index: 1,
					content: '附赠精品灯塔牌包装，附赠精品灯塔牌包装',
					avatar: '/static/crowdFunding/top-img.png',
					nickname: '也许时间是一种解药',
					img: 'https://img.zcool.cn/community/01b6b95d5b2e2fa801216518a7e7e7.jpg',
					time: '2025.5.23 16:23',
					likeNum: 12,
					liked: false
				}
			],
			commentList: [
				{
					avatar: '../../static/crowdFunding/top-img.png',
					content: '还是希望签名能签在书上，还是希望签名能签在书上还是希望签名能签在书上还是希望签名能签在书上，还是希望签名能签在书上还是希望签名能签在书上',
					nickname: '也许时间是一种解药',
					time: '2025.5.23 16:23',
					likeNum: 12,
					liked: false
				},
				{
					avatar: '../../static/crowdFunding/top-img.png',
					content: '还是希望签名能签在书上',
					nickname: '也许时间是一种解药',
					time: '2025.5.23 16:23',
					likeNum: 12,
					liked: true
				}
			],
			cate: [
				{
					name: "项目更新",
					id: 1,
				},
				{
					name: "项目讨论",
					id: 2,
				},
			],
		}
	},
	methods: {
		checkTab(tab) {
			this.tab = tab;
		},
	}
}
</script>

<style lang="scss" scoped>
.discussion-page {
	min-height: 100vh;
	background: #f2f6f2;
	padding-bottom: 40rpx;

	.project-card {
		display: flex;
		align-items: center;
		background: #fff;
		width: 100vw;
		height: 184rpx;
		border-bottom: 1px solid #F2F6F2;
		padding: 28rpx;
		.project-img {
			width: 128rpx;
			height: 128rpx;
			border-radius: 6rpx;
			margin-right: 16rpx;
		}

		.project-title {
			font-size: 28rpx;
			font-weight: bold;
			color: #222;
			max-width: 500rpx;
			overflow: hidden;
			text-overflow: ellipsis; 
			line-height: 2;
		}
	}

	.tabs {
		display: flex;
		height: 72rpx;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		background: #fff;
		margin-bottom: 6rpx;
		.tab-item {
			width: 50%;
			display: flex;
			align-items: center;
			justify-content: center;

			.tab {
				position: relative;
				//   width: 96rpx;
				width: 130rpx;
				height: 48rpx;
				font-size: 32rpx;
				font-family: "PingFang SC-Bold";
				color: #999;
				font-weight: 400;
				transition: all .5s;

				::after {
					content: "";
					position: absolute;
					right: -15rpx;
					top: 0;
					width: 96rpx;
					height: 48rpx;
					background-image: url("../../static/me/wd_img_qiehuan.png");
					background-size: auto 100%;
					background-repeat: no-repeat;
					opacity: 0;
				}

				&.active {
					color: #1f1f1f;

					text {
						font-family: "PingFang SC-Bold";
					}

					::after {
						opacity: 0.7;
					}
				}
			}
		}

	}

	.update-list {
		padding: 0 24rpx;

		.update-item {
			background: #fff;
			border-radius: 16rpx;
			margin-bottom: 24rpx;
			padding: 18rpx 20rpx 12rpx 20rpx;

			.update-title {
				font-size: 24rpx;
				color: #999;
				margin-bottom: 8rpx;
			}

			.update-content {
				font-size: 28rpx;
				color: #222;
				margin-bottom: 12rpx;
			}

			.update-user {
				display: flex;
				align-items: center;
				margin-bottom: 12rpx;

				.avatar {
					width: 36rpx;
					height: 36rpx;
					border-radius: 50%;
					margin-right: 8rpx;
				}

				.nickname {
					font-size: 22rpx;
					color: #999;
				}
			}

			.update-img {
				width: 100%;
				height: 160rpx;
				border-radius: 12rpx;
				object-fit: cover;
				margin-bottom: 10rpx;
			}

			.update-footer {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.update-time {
					font-size: 22rpx;
					color: #999;
				}

				.update-like {
					display: flex;
					align-items: center;

					.like-icon {
						width: 28rpx;
						height: 28rpx;
						margin-right: 4rpx;
					}

					.like-num {
						font-size: 22rpx;
						color: #888;
					}
				}
			}
		}
	}

	.comment-list {
		padding: 0 24rpx;

		.comment-item {
			display: flex;
			align-items: flex-start;
			background: #fff;
			border-radius: 16rpx;
			margin-bottom: 24rpx;
			padding: 18rpx 20rpx 12rpx 20rpx;

			.avatar {
				width: 36rpx;
				height: 36rpx;
				border-radius: 50%;
				margin-right: 12rpx;
			}

			.comment-main {
				flex: 1;
				display: flex;
				flex-direction: column;

				.comment-content {
					font-size: 28rpx;
					color: #222;
					margin-bottom: 10rpx;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.comment-footer {
					display: flex;
					align-items: center;

					.nickname {
						font-size: 22rpx;
						color: #999;
						margin-right: 16rpx;
					}

					.comment-time {
						font-size: 22rpx;
						color: #999;
					}
				}
			}

			.comment-like {
				display: flex;
				align-items: center;
				margin-left: 16rpx;

				.like-icon {
					width: 28rpx;
					height: 28rpx;
					margin-right: 4rpx;
				}

				.like-num {
					font-size: 22rpx;
					color: #888;
				}
			}
		}
	}
}
</style>
