<template>
	<!-- 加入志愿者 -->
	<view class="volunteer">
		<navbar title="加入志愿者" leftClick @leftClick="$utils.navigateBack" />
		<view class="volunteer-form">
			<view class="volunteer-form-title">
				<view>志愿者信息</view>
			</view>
			<view class="volunteer-form-sheet">
				<view class="volunteer-form-sheet-cell">
					<view>
						姓名
					</view>
					<input v-model="form.volunteerName" placeholder="请输入您的姓名" />
				</view>
				<view>
					<uv-picker ref="picker" :columns="columns" @confirm="confirm"></uv-picker>
					<view class="volunteer-form-sheet-cell">
						<view @click="openPicker">
							证件类型
						</view>
						<uv-cell :border="false" 
						:title="form.cerType || '选择证件类型'" 
						:isLink="true" arrow-direction="right"
						@click="openPicker" />
					</view>
				</view>
				<view class="volunteer-form-sheet-cell">
					<view>
						证件号码
					</view>
					<input placeholder="请输入证件号码" v-model="form.cerNo" />
				</view>
				<view class="volunteer-form-sheet-cell">
					<view>
						手机号码
					</view>
					<!-- <uv-input 
					v-model="form.volunteerPhone"
					placeholder="请输入手机号码"
					fontSize="24rpx" 
					border="none"
					:custom-style="{backgroundColor: '#fff',
					padding : '0 20rpx'}"> -->
						<!-- <template #suffix>
							<view>
								<text class="yzm">获取验证码</text>
							</view>
						</template> -->
					<!-- </uv-input> -->
					<input placeholder="请输入手机号码" v-model="form.volunteerPhone" />
				</view>
				<!-- <view class="volunteer-form-sheet-cell">
					<view>
						验证码
					</view>
					<input placeholder="请输入验证码" />
				</view> -->
			</view>
			
			<view class="submit" @click="submit">
				<view>
					提交
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				columns: [
					['居民身份证']
				],
				form : {
					cerNo : '',//证件号码
					cerType : '',//证件类型
					volunteerName : '',//志愿者姓名
					volunteerPhone : '',//手机号码
				},
			}
		},
		methods: {
			openPicker() {
				this.$refs.picker.open();
			},
			confirm(e) {
				this.form.cerType = e.value[0]
			},
			submit(){
				if(this.$utils.verificationAll(this.form, {
					volunteerName : '请输入志愿者姓名',//志愿者姓名
					cerType : '请选择证件类型',//证件类型
					cerNo : '请输入证件号码',//证件号码
					volunteerPhone : '请输入手机号码',//手机号码
				})){
					return
				}
				
				if(this.$utils.verificationPhone(this.form.volunteerPhone)){
					uni.showToast({
						title: '请输入正确的手机号码',
						icon : 'none'
					})
				}
				
				this.$api('addVolunteer', this.form, res => {
					if(res.code == 200){
						setTimeout(uni.navigateBack, 800, -1)
						
						uni.showToast({
							title: res.message,
							icon : 'none'
						})
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.volunteer {
		.volunteer-form {
			width: 94%;
			margin-top: 40rpx;
			margin-left: 3%;


			.volunteer-form-title {
				color: #333;
				font-size: 36rpx;
				font-weight: 600;
				padding: 0rpx 0rpx 0rpx 8rpx;
				border-left: 8rpx solid #F6732D;
			}

			.volunteer-form-sheet {
				display: flex;
				height: 500rpx;
				flex-direction: column;
				justify-content: space-around;

				.volunteer-form-sheet-cell {
					display: flex;
					font-size: 28rpx;
					align-items: center;

					.yzm {
						display: inline-block;
						font-size: 22rpx;
						padding: 6rpx;
						border-radius: 20rpx;
						background-color: #ff0829;
						color: #fff;

					}

					/deep/ .uv-cell__title-text {
						font-size: 24rpx;
					}

					/deep/ .uv-cell__body {
						padding: 0;
					}

					/deep/ .uv-cell {
						flex: 1;
					}

					view {
						width: 140rpx;
						padding: 20rpx 0;
					}

					input {
						flex: 1;
						height: 100%;
						color: #000;
						background-color: #fff;
						font-size: 24rpx;
						padding: 0 20rpx;
					}
				}
			}
			.submit{
				position: fixed;
				bottom: 5%;
				background-color: #b12026;
				color: #fff;
				width: 94%;
				padding: 20rpx 0;
				text-align: center;
				border-radius: 40rpx;
			}
		}
	}
</style>