<template>
	<view class="my-registrations">
		<!-- 原生tabs组件 -->
		<view class="custom-tabs">
			<view 
				v-for="(tab, index) in tabList" 
				:key="index" 
				class="tab-item" 
				:class="{ active: currentTab === index }"
				@click="tabChange(index)"
			>
				<text class="tab-text" :class="{ active: currentTab === index }">{{ tab.name }}</text>
				<view v-if="currentTab === index" class="tab-line"></view>
			</view>
		</view>
		
		<!-- 活动列表 -->
		<view class="activity-list">
			<view class="activity-item" v-for="(item, index) in list" :key="index" @click="viewActivityDetail(item)">
				<image class="activity-image" :src="item.communityActivity.image" mode="aspectFill"></image>
				<view class="activity-info">
					<view class="title-row">
						<view class="activity-badge">
							<text class="badge-text">{{item.communityActivity.score}}分</text>
						</view>
						<text class="activity-title">{{item.communityActivity.title}}</text>
					</view>
					<view class="activity-location">
						<uv-icon name="map-fill" size="14" color="#999"></uv-icon>
						<text class="location-text">{{item.communityActivity.address}}</text>
					</view>
					<view class="activity-time">
						<uv-icon name="calendar" size="14" color="#999"></uv-icon>
						<text class="time-text">{{item.communityActivity.activityTime}}</text>
					</view>
					<view class="activity-participants">
						<uv-icon name="account-fill" size="14" color="#999"></uv-icon>
						<text class="participants-text">报名人数：{{item.communityActivity.numActivity}}/{{item.communityActivity.numLimit}}</text>
					</view>
				</view>
				<view class="activity-action">
					<uv-button 
						v-if="item.status === '0'" 
						type="primary" 
						size="mini" 
						shape="circle"
						text="扫码签到" 
					></uv-button>
					<uv-button 
						v-else-if="item.status === '1'" 
						type="success" 
						shape="circle"
						size="mini" 
						text="已签到" 
						disabled
					></uv-button>
					<uv-button 
						v-else 
						type="error" 
						size="mini" 
						text="已取消" 
						disabled
					></uv-button>
				</view>
			</view>
			
			<!-- 空状态 -->
			<view v-if="list.length === 0" class="empty-state">
				<text class="empty-text">暂无相关报名记录</text>
			</view>
		</view>
	</view>
</template>

<script>
import MixinList from '@/mixins/list.js'
	export default {
		mixins: [MixinList],
		name: 'MyRegistrations',
		data() {
			return {
				currentTab: 0,
				tabList: [
					{ name: '未签到' },
					{ name: '已签到' },
					{ name: '系统取消' }
				],
				mixinListApi: 'activity.queryApplyList',

			}
		},
		computed: {


		},
		methods: {
			viewActivityDetail(item) {
				uni.navigateTo({
					url: '/subPages/my/myActivityDetail?id=' + item.communityActivity.id
				})
			},
			tabChange(index) {
				this.currentTab = index
				this.initPage()
				this.getList(true)
			},
			mixinSetParams() {
				return {
					status: this.currentTab
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
.my-registrations {
	background-color: #f5f5f5;
	min-height: 100vh;
	
	.custom-tabs {
		display: flex;
		background-color: #fff;
		border-bottom: 1rpx solid #e5e5e5;
		
		.tab-item {
			flex: 1;
			position: relative;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 30rpx 0;
			cursor: pointer;
			
			.tab-text {
				font-size: 28rpx;
				color: #666;
				transition: color 0.3s;
				
				&.active {
					color: #218cdd;
					font-weight: bold;
				}
			}
			
			.tab-line {
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 60rpx;
				height: 4rpx;
				background-color: #218cdd;
				border-radius: 2rpx;
			}
		}
	}
	
	.activity-list {
		padding: 20rpx;
		
		.activity-item {
			display: flex;
			margin-bottom: 30rpx;
			background: #fff;
			border-radius: 12rpx;
			padding: 20rpx;
			
			.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: 31px;
						height: 20px;
						background: #218cdd;
						border-radius: 3.5px;
						margin-right: 7rpx;
						display: flex;
						align-items: center;
						justify-content: center;

						.badge-text {
							font-size: 18rpx;
							color: #fff;
						}
					}
				}
				
				.activity-title {
					font-size: 28rpx;
					font-weight: bold;
					color: $uni-text-color;
				}
				
				.activity-location, .activity-time, .activity-participants {
					display: flex;
					align-items: center;
					margin-bottom: 6rpx;
					
					.location-text, .time-text, .participants-text {
						font-size: 24rpx;
						color: $uni-text-color-grey;
						margin-left: 6rpx;
					}
				}
			}
			
			.activity-action {
				display: flex;
				align-items: flex-end;
				padding-bottom: 10rpx;
			}
		}
		
		.empty-state {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 400rpx;
			
			.empty-text {
				font-size: 28rpx;
				color: $uni-text-color-grey;
			}
		}
	}
}
</style>