<template>
	<view class="page">
		<!-- 导航栏 -->

		<!-- 签到列表 -->
		<view class="content">
			<view v-if="checkinList.length > 0" class="list">
				<view v-for="item in checkinList" :key="item.id" class="activity-item" @click.stop="checkinActivity(item)" >
					<image class="activity-image" :src="item.image" mode="aspectFill"></image>
					<view class="activity-info">
						<view class="title-row">
							<view class="activity-badge">
								<text class="badge-text">{{ item.points }}分</text>
							</view>
							<text class="activity-title">{{ item.title }}</text>
						</view>
						<view class="activity-location">
							<uv-icon name="map-fill" size="14" color="#999"></uv-icon>
							<text class="location-text">{{ item.location }}</text>
						</view>
						<view class="activity-time">
							<uv-icon name="calendar" size="14" color="#999"></uv-icon>
							<text class="time-text">{{ item.time }}</text>
						</view>
						<view class="activity-participants">
							<uv-icon name="account-fill" size="14" color="#999"></uv-icon>
							<text class="participants-text">{{ item.participants }}人已报名</text>
						</view>
					</view>
					<view class="activity-action">
						<uv-button 
							type="primary" 
							shape="circle"
							size="small"
							text="签到码" 
							
						></uv-button>
					</view>
				</view>
			</view>
			<view v-else class="empty">
				<uv-empty mode="data" text="暂无可签到活动"></uv-empty>
			</view>
		</view>

		<!-- 操作菜单 -->
		<uv-action-sheet :show="showActionSheet" :actions="actions" @close="showActionSheet = false" @select="onActionSelect"></uv-action-sheet>
	</view>
</template>

<script>
export default {
	data() {
		return {
			showActionSheet: false,
			actions: [
				{ name: '刷新列表', color: '#218cdd' }
			],
			checkinList: [
				{
					id: 1,
					title: '关爱自闭儿童活动',
					image: '/static/bannerImage.png',
					location: '七步沙社区文化中心',
					time: '2025-06-12 14:30',
					participants: 12,
					points: 30,
					status: 'pending' // pending: 待签到, checked: 已签到
				},
				{
					id: 2,
					title: '社区环保志愿活动',
					image: '/static/bannerImage.png',
					location: '绿园社区广场',
					time: '2025-06-13 09:00',
					participants: 25,
					points: 25,
					status: 'checked'
				},
				{
					id: 3,
					title: '老年人关爱服务',
					image: '/static/bannerImage.png',
					location: '夕阳红养老院',
					time: '2025-06-14 15:00',
					participants: 8,
					points: 35,
					status: 'pending'
				},
				{
					id: 4,
					title: '青少年心理健康讲座',
					image: '/static/bannerImage.png',
					location: '市图书馆报告厅',
					time: '2025-06-15 19:30',
					participants: 45,
					points: 20,
					status: 'pending'
				}
			]
		}
	},
	methods: {
		// 查看活动详情
		viewActivityDetail(item) {
			uni.navigateTo({
				url: `/subPages/index/activityDetail?id=${item.id}`
			})
		},
		// 跳转到签到码界面
		checkinActivity(item) {
			uni.navigateTo({
				url: `/subPages/my/checkinCode?id=${item.id}&title=${item.title}&points=${item.points}`
			})
		},
		// 操作菜单选择
		onActionSelect(item) {
			if (item.name === '刷新列表') {
				uni.showToast({
					title: '刷新成功',
					icon: 'success'
				})
			}
			this.showActionSheet = false
		}
	}
}
</script>

<style lang="scss" scoped>
.page {
	background-color: #f5f5f5;
	min-height: 100vh;
}

.content {
	padding: 20rpx;
}

.list {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.activity-item {
	display: flex;
	// margin-bottom: 30rpx;
	background: #fff;
	border-radius: 12rpx;
	padding: 20rpx;
	box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.activity-image {
	width: 180rpx;
	height: 180rpx;
	border-radius: 8rpx;
	margin-right: 20rpx;
}

.activity-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.title-row {
	display: flex;
	align-items: center;
	margin-bottom: 10rpx;
}

.activity-badge {
	width: 62rpx;
	height: 40rpx;
	background: #218cdd;
	border-radius: 7rpx;
	margin-right: 14rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.badge-text {
	font-size: 18rpx;
	color: #fff;
}

.activity-title {
	font-size: 28rpx;
	font-weight: bold;
	color: #333;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

.activity-location, .activity-time, .activity-participants {
	display: flex;
	align-items: center;
	margin-bottom: 6rpx;
}

.location-text, .time-text, .participants-text {
	font-size: 24rpx;
	color: #999;
	margin-left: 6rpx;
}

.activity-action {
	display: flex;
	align-items: flex-end;
	padding-bottom: 10rpx;
}

.empty {
	margin-top: 200rpx;
}
</style>