<template>
	<view>
		<top-return></top-return>
		<view class="top">
			<view class="title" style="color: #4169E1;">选择您的孩子</view>
		</view>

		<!-- 孩子选择界面 -->
		<view class="card_box">
			<view class="card" v-for="(item,index) in childrenData" :key="index" @click="chooseChild(item)">
				<view class="flex_row" style="width: 100%;">
					<view class="front-tag"></view>
					<view class="card-title">{{item.name}}</view>
				</view>
				<view class="avatar_box">
						<image class="avatar" v-if="item.avatar === '默认'" :src="item.gender==='男'?'/static/default_icons/boy_avatar.svg':'/static/default_icons/girl_avatar.svg'"></image>
						<image class="avatar" v-if="item.avatar != '默认'" :src="item.avatar"></image>
				</view>
			</view>
		</view>

		<!-- 动画 -->
		<view class="ocean"></view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_parent', ['childrenData'])
		},
		data() {
			return {

			};
		},
		onLoad() {},
		methods: {
			...mapMutations('m_children', ['updateChildInfo']),
			//选择孩子并跳转首页传入id查询显示孩子信息
			async chooseChild(item) {
				this.updateChildInfo(item)
				await this.$initTab()
				uni.switchTab({
					url: '/pages/tab_home/tab_home'
				})
			},


		}
	}
</script>

<style lang="scss">
	@import 'startup_pages.scss';

	.card_box {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap; //元素换行
		margin: 250rpx 0 0 0;

		.card {
			width: 280rpx;
			height: 280rpx;
			margin: 20rpx;
			padding: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			box-shadow: $box-shadow;
			background-color: #FFFFFF;
			border-radius: $border-radius;
			z-index: 99;

			.card-title {
				line-height: 35rpx;
				font-size: 35rpx;
				font-weight: bold;
				color: $title;
			}

			.avatar_box {
				padding-top: 10rpx;
				.avatar {
					width: 240rpx;
					height: 240rpx;
				}
			}
		}
	}
</style>
