<template>
	<view class="container">
		<!-- tab选项 -->
		<view class="tabTitle">
			<text :class="{'actived': tabType===1}" @click="switchTab(1)">报名项目</text>
			<text :class="{'actived': tabType===2}" @click="switchTab(2)">获得认证</text>
		</view>
		<!-- tab内容 -->
		<view class="tabContent">
			<!-- 报名项目 -->
			<view class="signItemsInfoBox" v-if="tabType===1">
				<view class="signListsBox" v-if="signupInfos.length>0">
					<view class="signItem" v-for="item in signupInfos" :key="item.cerNo">
						<view class="seriesNo">{{item.cerNo}}</view>
						<view class="certifyInfo">
							<text>报名时间：{{item.signupDate}}</text>
							<view>
								<text>认证方向：{{item.cerName}}</text>
								<i class="iconfont icon-youjiantou"></i>
							</view>
						</view>
					</view>
				</view>
				<!-- 没有报名项目 -->
				<view class="noSign" v-if="signupInfos.length==0">
					<h4>暂没有报名项目！</h4>
				</view>
			</view>
			<view class="getCertifyListsBox" v-if="tabType===2">
				<view class="certifyListContent" v-if="userCertificates.length>0">
					<view class="certifyInfoItem" v-for="item in userCertificates" :key="item.cerNo">
						<h4>{{item.cerName}}</h4>
						<view class="certifyImgBox">
							<img :src="item.cerUrl" alt="" srcset="">
							<view>认证编号：{{item.authenticationCode}}</view>
							<view>有效期至：{{item.endDate}}</view>
						</view>
					</view>
				</view>
				<!-- 没有证书 -->
				<view class="noSign" v-if="userCertificates.length==0">
					<h4>暂没有取得证书！</h4>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from "../../api/api";
	export default {
		data() {
			return {
				tabType:1,
				signupInfos:[],
				userCertificates:[]
			};
		},
		methods:{
			switchTab(type){
				this.tabType = type;
				if(type===1){
					this.querySignupList();
				}else{
					this.userCertificateList();
				}
			},
			querySignupList(){
				api.querySignupList({user_id:1}).then(res=>{
					console.log(res);
					if(res['success']){
						this.signupInfos = res['data']['signupInfos']
					}
				})
			},
			userCertificateList(){
				const param = {
					queryType:1,
					userId:1
				}
				api.userCertificateList(param).then(res=>{
					console.log(res);
					if(res['success']){
						this.userCertificates = res['data']['userCertificates']
					}
				})
			}
		},
		onLoad(){
			this.querySignupList();
		},
		
	}
</script>

<style lang="scss">
	.container{
		position: relative;
		height: 100%;
		.tabTitle{
			color: #666666;
			background-color:#fff;
			display: flex;
			align-items: center;
			justify-content: space-around;
			padding: 30rpx 60rpx 0;
			text{
				&.actived{
					color: #333;
					border-bottom: 4rpx solid #20269B;
				}
			}
		}
		.tabContent{
			.signListsBox{
				width: 95%;
				margin: 0 auto;
				.signItem{
					margin-top: 20rpx;
					display: flex;
					align-items: center;
					background-color: #fff;
					padding:20rpx 20rpx 20rpx 50rpx;
					border-radius: 10rpx;
					.seriesNo{
						width: 0;
						height: 56rpx;
						flex: 0 0 56rpx;
						border-radius: 50%;
						background:linear-gradient(137deg, #E1B972 0%, #CDA464 100%);
						color: #fff;
						display: flex;
						justify-content: center;
						align-items: center;
						margin-right: 60rpx;
					}
					.certifyInfo{
						width: 0;
						flex: 1;
						
						view{
							display: flex;
							justify-content: space-between;
							align-items: baseline;
						}
					}
					
				}
			}
			.noSign{
				text-align: center;
				margin-top: 10%;
			}
			.getCertifyListsBox{
				.certifyInfoItem{
					background-color: #fff;
					margin-bottom: 10rpx;
					padding: 20rpx 0;
					width: 100%;
					display: flex;
					flex-direction: column;
					align-items: center;
					img{
						max-width: 60%;
						height: auto;
					}
				}
			}
		}
	}
</style>
