<template>
	<view class="application-detial">
		<u-navbar
			back-icon-color="#fff" 
			:back-text="$t('common.Back')" 
			:is-back="true" 
			:background="{background:'#1777FE'}"
			:back-text-style="{color:'#fff'}" 
			:border-bottom="true"
			title-color="#fff"
			:title="title"
			:custom-back="back"
			>
		</u-navbar>
		<view class="pagetitle" v-if="pageTitle">{{pageTitle}}</view>
		<!-- 选项卡的内容区 -->
		<view class="applicationDetial">
			<view class="form" v-if="temarray.length>0">
				<view class="radioitem" v-for="(item, index) in temarray" :key="index" >
					<u-checkbox v-model="item.checked" :name="item.id" disabled></u-checkbox>
					<text>{{item.leagueName}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.numberOfVisitors">
				<view class="label">
					<text class="need">*</text>
					<text>{{$t('common.resourceAttendance')}}</text>
				</view>
				<view class="value">
					<text v-if="detial.numberOfVisitors">{{detial.numberOfVisitors}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.startDateOfVisitors || detial.endDateOfVisitors">
				<view class="label">
					<text class="need">*</text>
					<text>{{$t('common.resourceVisitTime')}}</text>
				</view>
				<view class="value">
					<text v-if="detial.startDateOfVisitors">{{formatDate(detial.startDateOfVisitors)}}</text>
					<text class="space"> ~ </text>
					<text v-if="detial.endDateOfVisitors">{{formatDate(detial.endDateOfVisitors)}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.contactsName || detial.applyUserName">
				<view class="label">
					<text class="need">*</text>
					<text>{{$t('common.fullName')}}</text>
				</view>
				<view class="value">
					<text v-if="detial.contactsName">{{detial.contactsName}}</text>
					<text v-if="detial.applyUserName">{{detial.applyUserName}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.unitZhName || detial.unitEnName || detial.affiliatedUnitName">
				<view class="label"><text class="need">*</text><text>{{$t('common.NameoftheEntity')}}</text></view>
				<view class="value">
					<text v-if="detial.unitZhName || detial.unitEnName">
						{{this.$i18n.locale.toUpperCase()=='ZH'?(detial.unitZhName?detial.unitZhName:detial.unitEnName):
																(detial.unitEnName?detial.unitEnName:detial.unitZhName)}}
					</text>
					<text v-if="detial.affiliatedUnitName">{{detial.affiliatedUnitName}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.serviceType && (detial.supportWay||detial.childType)">
				<view class="label"><text class="need">*</text><text>{{$t('common.Applicationtype')}}</text></view>
				<view class="value">
					<text v-if="detial.serviceType">{{detial.serviceType}}</text> - 
					<text v-if="detial.supportWay">{{detial.supportWay}}</text>
					<text v-if="detial.childType">{{detial.childType}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.email || detial.linkEmail || detial.contactsEmail">
				<view class="label">
					<text class="need">*</text>
					<text>{{$t('common.Email')}}</text>
				</view>
				<view class="value">
					<text v-if="detial.email">{{detial.email}}</text>
					<text v-if="detial.linkEmail">{{detial.linkEmail}}</text>
					<text v-if="detial.contactsEmail">{{detial.contactsEmail}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.mobilePhone || detial.linkNumber || detial.contactsNumber">
				<view class="label"><text class="need">*</text><text>{{$t('common.ContactPhoneNumber')}}</text></view>
				<view class="value">
					<text v-if="detial.mobilePhone">{{detial.mobilePhone}}</text>
					<text v-if="detial.linkNumber">{{detial.linkNumber}}</text>
					<text v-if="detial.contactsNumber">{{detial.contactsNumber}}</text>
				</view>
			</view>
			<view class="item" v-if="detial.otherInstructions">
				<view class="label">
					<text>{{$t('common.resourceOtherInstructions')}}</text>
				</view>
				<view class="value">
					<text v-if="detial.otherInstructions">{{detial.otherInstructions}}</text>
				</view>
			</view>
		</view>
		<!-- 页面优化提示 -->
		<view class="loading" v-if="showLoading">
			<u-loadmore :status="status" iconType="flower" :load-text="{loading: this.$t('common.Nodata')}" margin-top="200" />
		</view>
		<view class="nodata" v-if="!showLoading&&!detial" style="text-align: center;margin-top: 120upx;">
			<view class="imgBox" style="height:600upx;margin-bottom:60upx">
				<image src="../../../static/img/public/7.png" style="width: 80%;margin:0 10%" mode="widthFix"></image>
			</view>
			<text style="font-size: 30upx;color:#ccc">{{$t('common.Nodata')}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		name:'ApplicationDetial',
		data(){
			return {
				title:'',
				type:'',
				pageTitle:'',
				currentItemId:'',
				detial:{},
				showLoading:true,
				status:'loading',
				temarray:[],
				mlchecked:[],
			}
		},
		onLoad(e){
			this.currentItemId=e.id;
			this.type=e.type;
			this.pageTitle=decodeURIComponent(e.title)+this.$t('common.Information');
			this.title= this.$i18n.locale == 'zh'? '我的申请': 'My Application'
		},
		onShow(){
			this.showDetialData();
		},
		methods:{
			// 获取当前进入页面的详情
			showDetialData(){
				this.type==0?this.getSelfMemberApply():
				this.type==1?this.getSelfAllianceApply():
				this.type==2?this.getCoopCustomServices(this.currentItemId):
				this.type==3?this.getCoopCustomServices(this.currentItemId):
				this.type==4?this.resourceShare(this.currentItemId):this.getSelfMemberApply();
			},
			// 入会详情
			async getSelfMemberApply(){
				this.detial=new Object();
				let res = await this.$myRequest({
					url:'/project/baseMemberApplys/getSelfMemberApply',
				})
				this.showLoading=false;
				var data = res.data;
				if(data){
					this.detial = {...data.baseMemberApplies[0],...data.baseContactsInfo}
				}
			},
			// 入盟详情
			async getSelfAllianceApply(){
				this.detial=new Object();
				let res = await this.$myRequest({
					url:'/project/baseLeagueApplys/getSelfAllianceApply',
				})
				this.showLoading=false;
				var data = res.data;
				if(data){
					this.mlchecked=data.leagueType;
					this.detial = {...data.baseLeagueApplyList[0],...data.baseContactsInfo}
				}
				this.getBaseLeagues();
				
			},
			//入盟申请表单
			async getBaseLeagues(){
				let res = await this.$myRequest({
					url:'project/baseLeagueInfos/getBaseLeagues',
					data:{language:this.$i18n.locale.toUpperCase()}
				})
				this.showLoading=false;
				if(res.status==200){
					var data = res.data;
					if(data.baseLeagueInfos && data.baseLeagueInfos.length>0) {
						for(let i=0;i<data.baseLeagueInfos.length;i++){
							if(this.mlchecked.indexOf(data.baseLeagueInfos[i]['baseEntityId'])>-1) this.$set(data.baseLeagueInfos[i],'checked',true)
							else this.$set(data.baseLeagueInfos[i],'checked',false)
						}
						this.temarray=data.baseLeagueInfos;
					}
				}
			},
			// 定制服务+资助洽商详情
			async getCoopCustomServices(id){
				this.detial=new Object();
				let res = await this.$myRequest({url:'/project/coopCustomServices/'+id})
				this.showLoading=false;
				if(res.status==200){
					let data = res.data;
					if(data.coopCustomService){
						this.detial=data.coopCustomService;
					}
				}
			},
			// 资源共享申请详情
			async resourceShare(id){
				this.detial = new Object();
				let res = await this.$myRequest({url:'/resourceshare/baseResearchApplications/?id='+id})
				this.showLoading=false;
				if(res.status==200){
					let data = res.data;
					if(data.baseResearchApplications && data.baseResearchApplications.length>0){
						this.detial=data.baseResearchApplications[0];
					}
				}
			},
			
			//路由后退一步
			back(){
				// #ifdef H5
				history.back()
				// #endif
				// #ifndef H5
				uni.navigateBack()
				// #endif
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-checkbox__icon-wrap--disabled{
		background-color: #2979ff;
		border-color: #2979ff;
	}
	.application-detial{
		height:100%;
		background:#fdfdfd;
		position:absolute;
		bottom:0;
		left:0;
		right:0;
		color:#666;
		.line-h{
			width:100%;
			height:2upx;
			background:#eee;
		}
		.pagetitle{
			margin-top:30upx;
			height:100upx;
			line-height:100upx;
			color:#333;
			padding:0 3%;
			font-size:32upx;
		}
		//内容
		.applicationDetial{
			.form{
				padding:0 30upx;
			}
			.item{
				position:relative;
				border-bottom:2upx solid #eee;
				padding:2% 0;
				.label,.value{
					padding:0 30upx;
					line-height:50upx;
				}
				.label{
					font-size:28upx;
					display:flex;
					align-items:center;
					color:#333;
					
					.need{
						color:#f20;
						margin-right:10upx;
					}
				}
				.value{
					font-size:24upx;
					color:#888;
					.space{
						padding:0 10upx;
					}
				}
			}
		}
	}
</style>
