<template>
	<Container backBtn logoutBtn @handleBack="handleBack">
		<template #main>
			<view class="theme-page">
				<view class="card">
					<view class="title">主题取号</view>
					<view class="btn-group">
						<view class="btn-item" v-for="(item, index) in themeList" :key="index"
							@click="handleSelect(item)">
							{{ item.subjectName }}
						</view>
					</view>
				</view>
			</view>
		</template>
	</Container>
</template>

<script>
	import Container from '@/components/container/container.vue'
	import {
		getThemeList,
	} from '@/api/ticket.js'

	export default {
		components: {
			Container
		},
		data() {
			return {
				themeList: [],
				idcard: ''
			}
		},
		onLoad(options) {
			this.idcard = options.idcard || ''
		},
		mounted() {
			this.fetchThemeList()
		},
		methods: {
			handleBack() {
				uni.navigateBack()
			},

			handleSelect(item) {
				uni.navigateTo({
					url: `/pages/home/businessList?source=subject&subjectId=${item.id}&subjectName=${item.subjectName}&idcard=${this.idcard}`
				})
			},

			async fetchThemeList() {
				try {
					const res = await getThemeList({ status: 1 })
					if (res.success && res.data) {
						this.themeList = res.data.records || []
					}
				} catch (e) {
					console.error('获取主题列表失败', e)
				}
			}
		}
	}
</script>

<style scoped>
	.theme-page {
		width: 100%;
		height: 100%;
		padding: 200px 60px 150px;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
	}

	.card {
		width: 100%;
		height: 740px;
		background: #fff;
		border-radius: 60px;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 40px;
	}

	.title {
		font-size: 40px;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
		margin-bottom: 60px;
	}

	.btn-group {
		width: 100%;
		flex: 1;
		display: flex;
		flex-wrap: wrap;
		align-content: flex-start;
		gap: 40px;
	}

	.btn-item {
		padding: 17px 25px;
		width: 400px;
		height: 140px;
		text-align: center;
		background: rgba(236, 243, 255, 1);
		border-radius: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 40px;
		color: rgba(51, 51, 51, 1);
		cursor: pointer;
	}
</style>
