<template>
	<view class="wrapper">
		<view class="">
			查询类型
		</view>
		<view class="content">
			<view class="item" v-for="(item,idx) in authenticationList" @click="selectType(item)" :class="{'selected':item.selected == true}">
				<text class="iconfont icon-yuanxingweixuanzhong" :class="{'icon-selected-copy':item.selected==true}"></text>
				<view>
					<view class="name">
						{{item.name}}
					</view>
					<view class="des">
						{{item.des}}
					</view>
				</view>
			</view>
		</view>
		<view class="others" v-if="queryType == '2'">
			<view class="others_item">
				<text>姓名：</text><input class="uni-input" type="text" placeholder="请输入姓名" v-model="userName"/>
			</view>
			<view class="others_item">
				<text>认证编号：</text><input class="uni-input" type="text" placeholder="请输证书编号" v-model="authenticationCode"/>
			</view>
		</view>
		<view class="search_btn" @click="confirmSearch()">
			确认查询
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				authenticationList:[
					{name:'本人认证查询',id:1,des:'查询本人的考试和认证结果'},
					{name:'他人认证查询',id:2,des:'帮助用人单位鉴别证书是否真实有效'}
				],
				userName:null,
				authenticationCode:null,
				queryType:null
			}
		},
		components:{},
		onLoad(){
			
		},
		methods:{
			selectType(item){
				this.queryType = item.id;
				for(let i=0;i<this.authenticationList.length;i++){
					this.authenticationList[i]['selected'] = false;
					if(item.id == this.authenticationList[i]['id']){
						this.authenticationList[i]['selected'] = true;
					}
				}
				if(this.queryType == 1){
					this.authenticationCode = null;
					this.userName =  null;
				}
			},
			confirmSearch(){
				if(this.queryType == null) {
					uni.showToast({
						title: '请选择查询类型',
						duration: 2000,
						icon: 'none'
					})
					return;
				}
				if(this.queryType == 2){
					if(!this.userName){
						uni.showToast({
							title: '请输入姓名',
							duration: 2000,
							icon: 'none'
						})
						return;
					}
					if(!this.authenticationCode){
						uni.showToast({
							title: '请输入证书编号',
							duration: 2000,
							icon: 'none'
						})
						return;
					}
				}
				uni.navigateTo({
					url:`../authentication-query/authentication-result?queryType=${this.queryType}&userName=${this.userName}&authenticationCode=${this.authenticationCode}`
				})
			}
		}
	}
</script>

<style lang="scss">
	.wrapper{
		padding: 30rpx;
		.content{
			.item{
				border:2rpx solid #E4E4E4;
				border-radius: 10rpx;
				margin: 20rpx;
				padding: 30rpx;
				display:flex;
				align-items: center;
				.iconfont{
					margin-right: 20rpx;
					font-size: 48rpx;
				}
				.icon-selected-copy{
					color: #3671F4;
				}
				.name{
						color: #666666;
						margin-bottom: 20rpx;
				}
				.des{
					color: #999999;
				}
			}
			.selected {
				border:2rpx #3671F4 solid;
				.name,.des{
					color: #3671F4;
				}
			}
		}
		.others{
			.others_item{
				display: flex;	
				margin-bottom: 20rpx;
				border-bottom: 2rpx #CECECE solid;
				height: 80rpx;
				align-items: center;
				.uni-input{
					height: 80rpx;
				}
			}
		}
		.search_btn{
			background: #3671F4;
			color: #fff;
			width: 80%;
			margin: 0 auto;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-radius: 40rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
		}
	}
	
</style>