<template>
	<view class="container main">
		<view class="one">
			<view class="text">参赛结果信息</view>
			<view class="list">
				<view class="value">
					<view class="title">编号：</view>
					<view class="label"> <text :user-select="true">{{info.no||'暂无'}}</text> </view>
				</view>
				<view class="value">
					<view class="title">报名时间：</view>
					<view class="label">{{info.time||'暂无'}}</view>
				</view>
				<view class="value" v-if="info.start_time">
					<view class="title">初审时间：</view>
					<view class="label">{{info.start_time||'暂无'}}</view>
				</view>
				<view class="value" v-if="info.score">
					<view class="title">初审分数：</view>
					<view class="label">{{info.score||'暂无'}}</view>
				</view>
				<view class="value" v-if="info.final_start_time">
					<view class="title">决赛时间：</view>
					<view class="label">{{info.final_start_time||'暂无'}}</view>
				</view>
				<view class="value" v-if="info.final_score">
					<view class="title">决赛分数：</view>
					<view class="label">{{info.final_score||'暂无'}}</view>
				</view>
				<view class="value">
					<view class="title">是否进入决赛：</view>
					<view class="label">{{getDict(info,'final_confirm')||'暂无'}}</view>
				</view>
				<view class="value" v-if="info.last_order_no">
					<view class="title">最后名次：</view>
					<view class="label">{{info.last_order_no||'暂无'}}</view>
				</view>
				<view class="value">
					<view class="title">流程状态：</view>
					<view class="label">{{getDict(info,'ext_status')||'暂无'}}</view>
				</view>
				<view class="value">
					<view class="title">状态：</view>
					<view class="label">{{getDict(info,'status')||'暂无'}}</view>
				</view>
			</view>
		</view>
		<view class="one">
			<view class="text">项目详情信息</view>
			<view class="list" v-for="(item, index) in investigate" :key="index">
				<view class="value_1">
					<view class="title">{{item.problem}}：</view>
					<view class="label"
						v-if="item.type == '0' || item.type == '2' || item.type == '3' || item.type == '4' || item.type == '5'">
						{{item.reply||'暂无'}}
					</view>
					<view class="label" v-if="item.type == '1' && item.reply">
						{{ item.reply.join(',')||'暂无' }}
					</view>
					<view class="label" v-if="item.type == '6'">
						<div v-for="(as, img) in item.reply" :key="img">
							<uni-link :href="getUrl(as)" color="#007BFF">{{ as.name }}</uni-link>
						</div>
					</view>
					<view class="label" v-if="item.type == '7'">
						<div class="arr">
							<div v-for="(aa, ina) in item.answer" :key="ina" class="name">{{ aa.text }}</div>
						</div>
						<div class="arr" v-for="(gg, inx) in item.reply" :key="inx">
							<div v-for="(aa, ina) in item.answer" :key="ina" class="input">
								{{ gg[aa.text] }}
							</div>
						</div>
					</view>
					<view class="label" v-if="item.type == '8'">
						<div v-for="(as, img) in item.answer" :key="img">
							<uni-link :href="getUrl(as)" color="#007BFF">{{ as.name }}</uni-link>
						</div>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import upload from '../../components/upload/index.vue';
	import moment from 'moment';
	export default {
		components: {
			upload
		},
		data() {
			return {
				id: '',
				user: {},
				info: {},
				investigate: [],
				statusList: [{
						value: '0',
						label: '待审核'
					}, {
						value: '1',
						label: '已通过'
					},
					{
						value: '-1',
						label: '已退回'
					}
				],
				isList: [{
					value: '0',
					label: '是'
				}, {
					value: '1',
					label: '否'
				}],
				extList: [],
			}
		},
		onLoad: async function(e) {
			const that = this;
			that.$set(that, `id`, e && e.id || '');
			await that.searchToken();
			await that.searchOther();
			await that.search();
		},
		methods: {
			// 用户信息
			searchToken() {
				const that = this;
				try {
					const res = uni.getStorageSync('token');
					if (res) {
						const user = that.$jwt(res);
						that.$set(that, `user`, user);
					}
				} catch (e) {}
			},
			async searchOther() {
				const that = this;
				let res;
				// 查询证件类型
				res = await that.$api(`/dictData`, 'GET', {
					code: 'extStatus',
					is_use: '0',
				})
				if (res.errcode == '0') {
					that.$set(that, `extList`, res.data)
				}
			},
			// 查询
			async search() {
				const that = this;
				if (that.id) {
					let res;
					res = await that.$api(`/matchReg/${that.id}`, 'GET', {})
					if (res.errcode == '0') {
						that.$set(that, `info`, res.data)
						if (res.data.info && res.data.info.length > 0) {
							for (let val of res.data.info) {
								if (val.type == '2') {
									for (let s of val.answer) {
										s.value = s.text
									}
								}
							}
							that.$set(that, `investigate`, res.data.info)
						}
					} else {
						uni.showToast({
							title: res.errmsg,
							icon: 'none'
						});
					}
				}
			},
			// 图片处理
			getUrl(e) {
				const that = this;
				if (e && e.length > 0) return that.$config.serverFile + e.uri
			},
			// 处理字典表
			getDict(item, model) {
				if (item) {
					const that = this;
					let res;
					if (model == 'status') res = that.statusList.find(i => i.value == item.status)
					if (model == 'ext_status') res = that.extList.find(i => i.value == item.ext_status)
					if (model == 'final_confirm') res = that.isList.find(i => i.value == item.final_confirm)
					if (res) return res.label
					else return '暂无'
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.one {
			padding: 2vw;

			.text {
				margin: 2vw 4vw;
				text-indent: 10px;
				border-left: 3px solid var(--f3CColor);
				font-weight: bold;
				font-size: var(--font16Size);
			}

			.list {
				background-color: var(--mainColor);
				border: 1px solid var(--f5Color);
				margin: 2vw 2vw 0 2vw;
				border-radius: 4px;
				padding: 3vw;


				.value {
					display: flex;
					align-items: center;

					.title {
						min-width: 70px;
						font-size: var(--font14Size);
						font-weight: bold;
					}

					.label {
						font-size: var(--font12Size);
						color: var(--f85Color);
					}
				}

				.value_1 {
					.title {
						font-size: var(--font14Size);
						font-weight: bold;
					}

					.label {
						margin: 10px 0 0 0;
						font-size: var(--font12Size);
						color: var(--f85Color);

						.arr {
							display: flex;
							align-items: center;
							justify-content: center;
							margin: 10px 0;

							.name {
								width: 50%;
								text-align: center;
							}

							.input {
								width: 50%;
								margin: 0 5px 0 0;
								border: 1px solid #e5e5e5;
								border-radius: 5px;
								text-align: center;

								.name {
									width: 50%;
									text-align: center;
									margin: 0 0 10px 0;
								}
							}
						}
					}
				}
			}
		}
	}
</style>