<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>
		<!-- 评论区域 -->
		<CommentSection v-else-if="  articleInfo.title" class="comment" ref="commentSection"
			:myInfo="myInfo"  :articleId="arcID" @totalNumberOfComments="totalNumberOfComments"
			:articleInfo="articleInfo" :author="author" find="work">
		</CommentSection>

	</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,
				},
			],
			myInfo: {
				"user_id": 1349,
				"user_name": "??????????????????????????????",
				"user_avatar": "http://e.zhichao.art/upload/2025-04/0a7d9b922ac8307a6f988d17b3dd7805_new.jpg"
			},
			articleInfo: {
				"id": 574,
				"task_type": 1,
				"queue_id": 0,
				"article_id": 0,
				"sso_id": 1458,
				"images": "http://c.zhichao.art/upload/2025-05/9cc4c00bab5ae9be6486d95c31d2d720_new.jpg",
				"content": "非常喜欢这个手办图片",
				"lyrics": "",
				"result_audio": "",
				"title": "这个手办感觉不错呀",
				"style": "",
				"num_like": 12,
				"num_comment": 0,
				"num_view": 84,
				"city": "",
				"tdate": "2025-05-26",
				"reason": "",
				"can_comment": 1,
				"can_view_comment": 1,
				"create_time": "2025-05-26 12:02:22",
				"status": 1,
				"video_url": "",
				"video_width": 1080,
				"video_height": 1920,
				"nickname": "",
				"age": 0,
				"avator": "",
				"author": "",
				"xinzuo": "",
				"sex": 0,
				"dtime": "",
				"is_like": 0,
				"is_vip": 0,
				"userID": 0,
				"like_count": 0,
				"sms_id": 0
			},
			articleId: 574,
			arcID: 574,
			type: 'work',
			find: 'work',
			author: {
				"id": 1458,
				"nickname": "时光慢递员∞",
				"avator": "https://c.zhichao.art/upload/plat/10000000062.jpg",
				"is_attention": 0
			}
		}
	},
	onLoad(options) {
		if (options.tags) {
			this.tab = options.tags === 'update' ? 1 : options.tags === 'comment' ? 2 : 1;
		}
	},
	methods: {
		checkTab(tab) {
			this.tab = tab;
		}, totalNumberOfComments(tableTotal) {
			this.tableTotal = tableTotal;
		},
	}
}
</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 {
		background: #fff;
		border-top-left-radius: 32rpx;
		border-top-right-radius: 32rpx;
	}
}
</style>
