<template>
	<view class="matchmaker-message">
		<!-- 顶部导航栏 -->
		<view class="header">
			<view class="back-btn" @click="goBack"></view>
			<text class="header-title">消息</text>
			<view class="placeholder"></view>
		</view>

		<scroll-view scroll-y class="content">
			<!-- 系统通知 -->
			<view class="message-item system-notification active">
				<text class="message-type">系统通知</text>
				<text class="message-time">刚刚</text>
				<text class="message-content">您的线索审核已通过，获得20积分奖励，当前积分可兑换【资源查看权限】x1</text>
				<text class="message-footer">完成线索采集，积分+20 (距黄金级还差72分)</text>
			</view>

			<!-- 撮合成功通知 -->
			<view class="message-item match-success">
				<view class="message-icon heart"></view>
				<view class="message-body">
					<text class="message-type">撮合成功通知</text>
					<text class="message-content">您推荐的王先生和刘女士已成功匹配，获得50积分+100元现金奖励</text>
				</view>
				<text class="message-time">10分钟前</text>
			</view>

			<!-- 今天分组 -->
			<view class="time-group">
				<text class="time-label">今天</text>
			</view>

			<!-- 魏先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">魏</view>
				<view class="message-body">
					<text class="message-type">魏先生</text>
					<text class="message-content">您好，想了解一下李女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>

			<!-- 昨日分组 -->
			<view class="time-group">
				<text class="time-label">昨日</text>
			</view>

			<!-- 张先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">张</view>
				<view class="message-body">
					<text class="message-type">张先生</text>
					<text class="message-content">您好，想了解一下王女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>

			<!-- 更早分组 -->
			<view class="time-group">
				<text class="time-label">更早</text>
			</view>

			<!-- 高先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">高</view>
				<view class="message-body">
					<text class="message-type">高先生</text>
					<text class="message-content">您好，想了解一下陈女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>
		</scroll-view>

		<!-- 底部导航 -->
		<view class="tabbar">
			<view class="tabbar-item home" @click="navigateToWorkbench">
				<view class="tabbar-icon"></view>
				<text class="tabbar-text">工作台</text>
			</view>
			<view class="tabbar-item resources" @click="navigateToMyResources">
				<view class="tabbar-icon"></view>
				<text class="tabbar-text">我的资源</text>
			</view>
			<view class="tabbar-item trophy" @click="navigateToRanking">
				<view class="tabbar-icon"></view>
				<text class="tabbar-text">排行榜</text>
			</view>
			<view class="tabbar-item message active" @click="navigateToMessage">
				<view class="tabbar-icon">
					<view class="badge">3</view>
				</view>
				<text class="tabbar-text">消息</text>
			</view>
			<view class="tabbar-item mine" @click="navigateToMine">
				<view class="tabbar-icon"></view>
				<text class="tabbar-text">我的</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				messages: [
					{
						id: 1,
						type: 'system',
						title: '系统通知',
						content: '您的线索审核已通过，获得20积分奖励，当前积分可兑换【资源查看权限】x1',
						footer: '完成线索采集，积分+20 (距黄金级还差72分)',
						time: '刚刚',
						isNew: true
					},
					{
						id: 2,
						type: 'matchSuccess',
						title: '撮合成功通知',
						content: '您推荐的王先生和刘女士已成功匹配，获得50积分+100元现金奖励',
						time: '10分钟前',
						isNew: false
					},
					{
						id: 3,
						type: 'user',
						title: '王先生',
						content: '您好，想了解一下李女士的详细情况，方便沟通吗？',
						time: '1小时前',
						isNew: false
					}
				]
			}
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack()
			},
			// 导航到工作台
			navigateToWorkbench() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/index'
				})
			},
			// 导航到我的资源
			navigateToMyResources() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/my-resources'
				})
			},
			// 导航到排行榜
			navigateToRanking() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/ranking'
				})
			},
			// 导航到消息
			navigateToMessage() {
				// 已在消息页面，无需跳转
			},
			// 导航到我的
			navigateToMine() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/mine'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.matchmaker-message {
		min-height: 100vh;
		background: #FFF9F9;
		display: flex;
		flex-direction: column;
	}

	/* 顶部导航栏 */
	.header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 25rpx 30rpx;
		padding-top: calc(25rpx + env(safe-area-inset-top));
		background: #FFF9F9;
		border-bottom: 1rpx solid #F0F0F0;

		.back-btn {
			width: 70rpx;
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: rgba(240, 240, 240, 0.5);
			border-radius: 50%;
			background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>');
			background-size: 40rpx 40rpx;
			background-repeat: no-repeat;
			background-position: center;
		}

		.header-title {
			font-size: 38rpx;
			font-weight: bold;
			color: #333;
		}

		.placeholder {
			width: 70rpx;
		}
	}

	.content {
		flex: 1;
		padding: 20rpx 20rpx 120rpx;
	}

	/* 消息项 */
	.message-item {
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 25rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		position: relative;

		&.system-notification {
			background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
			border: 2rpx solid #F8BBD0;

			&.active {
				border-color: #E91E63;
			}

			.message-type {
				display: block;
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 15rpx;
			}

			.message-time {
				display: block;
				font-size: 24rpx;
				color: #999;
				margin-bottom: 15rpx;
				text-align: right;
			}

			.message-content {
				display: block;
				font-size: 28rpx;
				color: #333;
				line-height: 1.5;
				margin-bottom: 15rpx;
			}

			.message-footer {
				display: block;
				font-size: 24rpx;
				color: #666;
				line-height: 1.4;
			}
		}

		&.match-success {
			display: flex;
			background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
			border: 2rpx solid #D1C4E9;

			.message-icon {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				margin-right: 20rpx;
				background-size: 40rpx 40rpx;
				background-repeat: no-repeat;
				background-position: center;
			}

			.message-icon.heart {
				background-color: #F8BBD0;
				background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23E91E63"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
			}

			.message-body {
				flex: 1;
			}

			.message-type {
				display: block;
				font-size: 30rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 10rpx;
			}

			.message-content {
				display: block;
				font-size: 26rpx;
				color: #666;
				line-height: 1.4;
			}

			.message-time {
				font-size: 24rpx;
				color: #999;
				margin-top: auto;
			}
		}

		&.user-message {
			display: flex;
			background: #FFFFFF;
			border: 2rpx solid #E0E0E0;

			.message-avatar {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
				color: #FFFFFF;
				font-size: 28rpx;
				font-weight: bold;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 20rpx;
			}

			.message-body {
				flex: 1;
			}

			.message-type {
				display: block;
				font-size: 30rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 10rpx;
			}

			.message-content {
				display: block;
				font-size: 26rpx;
				color: #666;
				line-height: 1.4;
			}

			.message-time {
				font-size: 24rpx;
				color: #999;
				margin-top: auto;
			}
		}
	}

	/* 时间分组 */
	.time-group {
		display: flex;
		justify-content: center;
		margin: 20rpx 0;

		.time-label {
			display: inline-block;
			background: #FFF3E0;
			color: #FF9800;
			font-size: 24rpx;
			padding: 8rpx 20rpx;
			border-radius: 20rpx;
			font-weight: bold;
		}
	}

	/* 底部导航 */
	.tabbar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
		background: #FFFFFF;
		border-top: 1rpx solid #F0F0F0;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding-bottom: env(safe-area-inset-bottom);

		.tabbar-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: 8rpx;
			padding: 10rpx 0;

			.tabbar-icon {
				width: 44rpx;
				height: 44rpx;
				background-size: contain;
				background-repeat: no-repeat;
				background-position: center;
				position: relative;

				.badge {
					position: absolute;
					top: -8rpx;
					right: -8rpx;
					background: #FF4444;
					color: #FFFFFF;
					font-size: 20rpx;
					font-weight: bold;
					width: 32rpx;
					height: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 16rpx;
				}
			}

			.tabbar-text {
				font-size: 20rpx;
				color: #999;
			}

			&.active .tabbar-text {
				color: #9C27B0;
				font-weight: bold;
			}

			&.home .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
			}
			&.home.active .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>');
			}

			&.resources .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
			}
			&.resources.active .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
			}

			&.trophy .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
			}
			&.trophy.active .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2zM5 8V7h2v3.82C5.84 10.4 5 9.3 5 8zm14 0c0 1.3-.84 2.4-2 2.82V7h2v1z"/></svg>');
			}

			&.message .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
			}
			&.message.active .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>');
			}

			&.mine .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
			}
			&.mine.active .tabbar-icon {
				background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239C27B0"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
			}
		}
	}
</style>