<template>
	<view class="container">
		<view class="desc-box">
			请输入个人邮箱，个人信息副本将于5个工作日内完成导出，结果将发送至您的个人邮箱，每日限提交一次
		</view>
		<view class="form-box">
			<u-form :model="formData.form" ref="formRef" label-width="120" :label-style="{fontWeight: 'bold', fontSize: '26rpx'}">
				<u-form-item prop="email">
					<u-input v-model="formData.form.email" :border="true"  type="text" placeholder="请输入电子邮箱"/>
				</u-form-item>
			</u-form>
		</view>
		<view class="bottom-box">
			<u-button type="primary" shape="circle" @click="onSubmit">提交</u-button>
		</view>
	</view>
</template>

<script setup>
	import { ref, reactive } from 'vue'
	import { onLoad, onReady } from '@dcloudio/uni-app'
	
	const formRef = ref()
	const formData = reactive({
		form: {
			phone: null,
			code: null
		},
		rules: {
			phone: [
				{ 
					required: true, 
					message: '请输入绑定手机号', 
					// 可以单个或者同时写两个触发验证方式 
					trigger: 'blur',
				}
			],
			code: [
				{ 
					required: true, 
					message: '请输入验证码', 
					// 可以单个或者同时写两个触发验证方式 
					trigger: 'blur',
				}
			],
		}
	})
	
	function onSubmit() {
		formRef.value.validate((valid) => {
			if (valid) {
				// 提交
			}
		})
	}
	
	onReady(() => {
		formRef.value.setRules(formData.rules)
	})
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		width: 100vw;
		background-color: $uni-bg-color;
		padding: 20rpx;
		
		.desc-box {
			text-indent: 2em;
			line-height: 60rpx;
			padding: 20rpx 0;
			margin-bottom: 20rpx;
		}
		
		.form-box {
			padding: 20rpx 0;
			
			.input-code {
				display: flex;
				align-items: center;
				gap: 20rpx;
				.input {
					width: 70%;
				}
				.btn {
					width: 30%;
					text-align: center;
				}
			}
		}
		.bottom-box {
			margin-top: 50rpx;
			padding: 0 50rpx;
		}
	}
</style>