<template>
	<view>
		<form class="padding-lr cu-form-group flex-direction">
			<view class="cu-form-group flex flex-direction padding-tb">
				<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>姓名</view>
				<input placeholder="请输入真实姓名" name="input" type="text" v-model="name" />
			</view>
			<view class="cu-form-group flex flex-direction padding-tb">
				<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>身份证</view>
				<input placeholder="请输入身份证号" name="input" type="text" v-model="IDcard" />
			</view>
			<view class="cu-form-group flex flex-direction padding-tb">
				<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>联系方式</view>
				<input placeholder="请输入手机号码" name="input" type="number" v-model="phone" />
			 </view>
			<view class="cu-form-group flex flex-direction padding-tb">
				<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>身份</view>
				<radio-group class="block" @change="RadioChange">
					<view class="flex">
						<view class="flex-sub margin-tb-sm" v-for="(identity,index) in identitys" :key="index">
							<label class="flex justify-between align-center">
								<radio class="round margin-right-xs" :checked="index === current" :value="identity.value"></radio>
								<text class="flex-sub" style="font-size: 34rpx;">{{ identity.name }}</text>
							</label>
						</view>
					</view>
				</radio-group>
			</view>
			<view class="cu-form-group flex flex-direction padding-tb">
				<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>学号</view>
				<input placeholder="请输入学号" name="input" type="text" v-model="studentID" />
			</view>
		</form>
		<button class="bg-cyan margin primary-btn" hover-class="cc-active" @tap="confirm">确认提交</button>
  </view>
</template>

<script>
import { showToast } from 'common/script/util';

export default {
  data() {
    return {
		name: '',
		IDcard: '',
		phone: '',
		identitys: [
			{
				value: '0',
				name: '学生',
			},
			{
				value: '1',
				name: '教师',
			},
			{
				value: '2',
				name: '工作人员',
			},
		],
		studentID: '',
		current: 0
	};
  },
  methods: {
	RadioChange: function(evt) {
		for (let i = 0; i < this.identitys.length; i++) {
			if (this.identitys[i].value === evt.target.value) {
				this.current = i;
				break;
			}
		}
	},
	
	/**
	 * 提交基本信息
	*/
	confirm() {
		if (!this.name) {
		  showToast('请输入姓名');
		  return;
		}
		if (!this.IDcard) {
		  showToast('请输入身份证号');
		  return;
		}
		if (!this.phone) {
		  showToast('请输入手机号');
		  return;
		}
		if (!this.identitys) {
		  showToast('请选择身份');
		  return;
		}
		if (!this.studentID) {
		  showToast('请输入学号');
		  return;
		}
	    console.log('信息提交');
		uni.reLaunch({
			url: `/pages/index/components/mine`,
		});
	},
	
  },
};
</script>

<style lang="scss" scoped>
	.primary-btn{
		border-radius: 15rpx;
	}
</style>