<template>
	<view class="container">
		<uni-card :is-shadow="false" :border="false" is-full>
			<view class="form">
				<view class="line">
					<uni-data-checkbox v-model="myVal" :localdata="checkList" @change="myChange"></uni-data-checkbox>
					<text>我的邮箱</text>
					<uni-easyinput v-model="form.contact" disabled />
				</view>
				<view class="line">
					<uni-data-checkbox v-model="otherVal" :localdata="checkList" @change="otherChange"></uni-data-checkbox>
					<text>其他邮箱</text>
					<uni-easyinput v-model="form.contact" placeholder="请输入其他邮箱" />
				</view>
				<button type="primary" @click="submit('valiForm')">确认</button>
			</view>
		</uni-card>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myVal: 1,
				otherVal: 2,
				checkList: [{
					text: '',
					value: 1
				}],
				form: {
					name: '',
					provience: '',
					city: '',
					industryId: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				}
			}
		},
		onLoad() {
			console.log(getApp())
		},
		methods: {
			myChange(e) {
				this.otherVal = ''
				console.log('---------onchange:', e);
			},
			otherChange(e) {
				this.myVal = ''
				console.log('---------onchange:', e);
			},
			submit(ref) {
				this.$refs[ref].validate().then(res => {
					console.log('success', res);
					uni.showToast({
						title: `校验通过`
					})
				}).catch(err => {
					console.log('err', err);
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.form {
	padding: 15px;
	background-color: #fff;
}
.line {
	display: flex;
	align-items: center;
	margin-bottom: 15px;
	text {
		margin: 0 10px 0 -20px;
	}
}
</style>
