<template>
	<view class="children-container">
		<!-- 标题 -->
		<view class="tips">
			<view class="title">选择您的孩子</view>
		</view>
		<!-- 孩子选择界面 -->
		<view class="children-item">
			<view class="com-box">
				<view class="item" v-for="(item,index) in parentdetail.childrenList" :key="index" @click="chooseChildren(item)">
					<view class="item-text">{{item.name}}</view>
					<view class="avatar-box">
						<u-avatar size="120" class="item-avatar" :src="item.avatar" mode="aspectFill"></u-avatar>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	
	export default {
		data() {
			return {
				
			};
		},
		computed:{
			...mapState('m_parent',['parentdetail'])
		},
		onLoad(){
			//获得家长详细信息
			// if(parentdetail === '')
			// this.getParentDetail();
		},
		methods:{
			...mapMutations('m_children',['updateChildrenInfo']),
			
			// async getParentDetail(){
			// 	const res = await uni.$http.post('',);
			// }
			//选择孩子并跳转首页传入id查询显示孩子信息
			chooseChildren(item){
				console.log(item.tmdid);
				this.updateChildrenInfo(item)
				uni.switchTab({
					url:'/pages/home/home'
				})
			}
		}
	}
</script>

<style lang="scss">
	.children-container{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		
		.tips {
			width: 100%;
			padding-top: 100rpx;
			padding-left: 80rpx;
			display: flex;
			flex-direction: column;
			margin-bottom: 100rpx;
		
			.title {
				line-height: 70rpx;
				font-weight: bold;
				font-size: 50rpx;
			}
		}
		.children-item{
			.com-box{
				display: flex;
				flex-direction: row;
				justify-content: center;
				align-items: center;
				flex-wrap: wrap;//元素换行
				
				.item{
					margin: 10px;
					padding: 10px;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					background-color: #FFFFFF;
					border-radius: 10px;
					width: 140px;
					height: 160px;
					
					.item-text{
						margin: -7rpx 0 20rpx 20rpx;
						width: 100%;
						line-height: 40rpx;
						font-weight: bold;
						font-size: 30rpx;
						color: #696969;
					}
					.avatar-box{
						.item-avatar{
							width: 220rpx;
							height: 220rpx;
						}
					}
				}
			}
		}
	}
</style>
