<template>
	<view class="page">
		<navbar
		title="需提交的材料"
		leftClick 
		@leftClick="$utils.navigateBack"
		/>
		
		<view class="form">
			<!-- <view class="form-item">
				<view class="title">
					请提交所需要的相对于的材料
				</view>
				<view class="tips">
					信息仅用于考证咨询方面，保证您的信息安全
				</view>
			</view>
			
			<view class="form-item">
				<uv-upload 
				:fileList="fileList" 
				:maxCount="1" 
				width="690rpx"
				height="280rpx" 
				multiple 
				@afterRead="afterRead" 
				@delete="deleteImage">
					<view class="upload">
						<image src="../static/auth/cart.png"
						mode="aspectFit"
						style="width: 390rpx;height: 280rpx;" />
						<view class="btn-add">
							点击上传
						</view>
					</view>
				</uv-upload>
			</view>
			<view class="form-item">
				<view class="tips"
				style="text-align: center;padding: 20rpx 0;">
					(确保文字清晰、可辨、避免遮挡、不全、反光)
				</view>
			</view> -->
			
			<!-- <view class="form-item">
				<view class="label">
					头像
				</view>
				<view class="input">
					<image src="../static/postConsult/4.png" mode="aspectFill"></image>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view> -->
			
			<view class="form-item">
				<view class="label">
					真实姓名
				</view>
				<view class="input">
					<input type="text" 
					placeholder="请输入真实姓名"
					v-model="form.name"/>
				</view>
			</view>
			
			<view class="form-item">
				<view class="label">
					手机号
				</view>
				<view class="input">
					<input type="text" 
					placeholder="请输入手机号"
					v-model="form.phone"/>
				</view>
			</view>
			
			<view class="form-item">
				<view class="label">
					身份证号码
				</view>
				<view class="input">
					<input type="text" 
					placeholder="请输入身份证号码"
					v-model="form.phone"/>
				</view>
			</view>
			
			<view class="form-item">
				<view class="label">
					工作单位
				</view>
				<view class="input">
					<input type="text" 
					placeholder="请输入工作单位"
					v-model="form.phone"/>
				</view>
			</view>
			
			
			<view class="form-item">
				<view class="label required">
					个人信息<text>（用于下载学时证明、考试使用）</text>
				</view>
			</view>
			
			<view class="form-item">
				<view class="label required">
					个人免冠照<text>（白底彩照1张）</text>
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileList" 
					name="fileList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/4.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<view class="form-item">
				<view class="label required">
					身份证正面
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileFrontList" 
					name="fileFrontList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/2.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<!-- 身份证反面 -->
			<view class="form-item">
				<view class="label required">
					身份证反面
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileReverseList" 
					name="fileReverseList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/3.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<!-- 申请表电子表格 -->
			<view class="form-item">
				<view class="label required">
					申请表电子表格<text>（申请表电子表格填写完打印出来，本人签字及日期，单位右边加盖公章1份）</text>
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileReverseList" 
					name="fileReverseList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/1.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<!-- 初中以上学历证书 -->
			<view class="form-item">
				<view class="label required">
					初中以上学历证书<text>（或户口本本人那页复印件1份)</text>
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileEducationalList" 
					name="fileEducationalList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/5.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<!-- 营业执照复印件1份 -->
			<view class="form-item">
				<view class="label required">
					营业执照复印件1份
				</view>
				<view class="input">
					<uv-upload
					:fileList="fileBusinessList" 
					name="fileBusinessList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/postConsult/6.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
			<!-- 个人健康书面承诺 -->
			<view class="form-item">
				<view class="label required">
					个人健康书面承诺1份
				</view>
				<view class="input">
					<uv-upload
					:fileList="filePromiseList" 
					name="filePromiseList"
					:maxCount="1" 
					width="120rpx"
					height="120rpx" 
					multiple 
					@afterRead="afterRead" 
					@delete="deleteImage">
						<view class="upload">
							<image src="../static/auth/cart.png"
							mode="aspectFit"
							style="width: 120rpx;height: 120rpx;" />
						</view>
					</uv-upload>
				</view>
				<view class="icon">
					<uv-icon
					name="arrow-right"
					size="30rpx"
					></uv-icon>
				</view>
			</view>
			
		</view>
		
		<view class="uni-color-btn" @click="addMaterial()">
			提交
		</view>
		
		<view class="uni-uncolor-btn"
		@click="$refs.customerServicePopup.open()">
			联系客服
		</view>
		
		<view class="form-item">
			<view class="tips"
			style="text-align: center;padding: 20rpx 0;">
				如有疑问请联系客服
			</view>
		</view>
		
		<customerServicePopup ref="customerServicePopup"/>
	</view>
</template>

<script>
	import customerServicePopup from '@/components/config/customerServicePopup.vue'
	export default {
		components : {
			customerServicePopup
		},
		data() {
			return {
				form : {
					name : ''
				},
				fileList : [],//个人免冠照
				fileFrontList : [],//身份证正面
				fileReverseList : [],//身份证反面 
				fileApplicationList : [],//申请表电子表格 
				fileEducationalList : [],//初中以上学历证书
				fileBusinessList : [],//营业执照复印件1份
				filePromiseList : [],//个人健康书面承诺1
			}
		},
		methods: {
			deleteImage(e){
				this[e.name].splice(e.index, 1)
			},
			afterRead(e){
				let self = this
				e.file.forEach(file => {
					self.$Oss.ossUpload(file.url).then(url => {
						self[e.name].push({
							url
						})
					})
				})
				
			},
			addMaterial(){
				
				this.form.imageCardFront = this.fileFrontList.map((item) => item.url).join(",")
				this.form.imageCardfBack = this.fileReverseList.map((item) => item.url).join(",")
				
				if(this.$utils.verificationAll(this.form,{
					name:'请输入用户名称',
					phone:'请输入电话',
					imageCardFront:'请选择身份证正面照复印件',
					imageCardfBack:'请选择身份证反面照复印件'
					
				})) {
					return
				}
				this.$api('addMaterial',this.form, res =>{
					if(res.code == 200){
						uni.showToast({
							title:'提交成功！等待审核',
							icon: 'none'
						})	
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.page{
	min-height: 100vh;
	.required::before{
		content: '*';
		color: #f00;
	}
	.form-item{
		padding: 30rpx 0;
		display: flex;
		align-items: center;
		border-bottom: 1rpx solid #00000009;
		font-size: 28rpx;
		.label{
			font-weight: 600;
			margin-right: 50rpx;
			text{
				font-size: 24rpx;
				font-weight: 500;
			}
		}
		.input{
			margin-left: auto;
			flex-shrink: 0;
			image{
				
			}
			input{
				text-align: right;
			}
		}
		.icon{
			margin-left: 10rpx;
		}
	}
	.tips{
		font-size: 26rpx;
		color: #777;
		padding-bottom: 20rpx;
	}
	.form {
		padding: 0 30rpx;
		background-color: #fff;
		margin: 20rpx;
		border-radius: 20rpx;
		.upload{
			display: flex;
			justify-content: center;
			align-items: center;
			// width: 690rpx;
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			overflow: hidden;
			background-color: #f3f3f3;
			border-radius: 10rpx;
			// .btn-add{
			// 	margin: auto;
			// 	padding: 10rpx 20rpx;
			// 	background-color: $uni-color;
			// 	color: #fff;
			// 	border-radius: 10rpx;
			// }
		}
	}
}
</style>
