<template>
	<view class="OutermostLayer">
		<h4>登录密码修改</h4>
		<u--form labelPosition="left" labelWidth='180' :model="model1" :rules="rules" ref="form1">
			<u-form-item label="旧登录密码" prop="userInfo.oldpasswoed" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.oldpasswoed" border="surround"></u--input>
			</u-form-item>
			<u-form-item label="新登录密码" prop="userInfo.mewpasswoed1" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.mewpasswoed1" border="surround"></u--input>
			</u-form-item>
			</u-form-item>
			<u-form-item label="请再次输入" prop="userInfo.mewpasswoed2" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.mewpasswoed2" border="surround"></u--input>
			</u-form-item>

		</u--form>
		<view class="tijiao">
			<u-button type="primary" @click="submit">确定修改</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model1: {
					userInfo: {
						oldpasswoed: '',
						mewpasswoed1: '',
						mewpasswoed2: '',
					},
				},
				rules: {
					'userInfo.oldpasswoed': {
						type: 'string',
						required: true,
						message: '请填写旧登录密码',
						trigger: ['blur', 'change']
					},
					'userInfo.mewpasswoed1': {
						type: 'string',
						required: true,
						message: '请填写新登录密码',
						trigger: ['blur', 'change']
					},
					'userInfo.mewpasswoed2': {
						type: 'string',
						required: true,
						message: '请填写新登录密码',
						trigger: ['blur', 'change']
					},

				},


			};
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.form1.setRules(this.rules)
		},
		methods: {
			submit() {
				this.$refs.form1.validate().then(res => {
					if(this.model1.userInfo.mewpasswoed1!=this.model1.userInfo.mewpasswoed2){
						uni.$u.toast('您的新密码不一致，请重新输入')
					}else{
						uni.$u.toast('校验通过')
					}
					
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			}

		}

	}
</script>

<style lang="scss">
	.tijiao {
		margin-top: 50rpx;
	}

	.OutermostLayer h4 {
		font-size: 35rpx;
		margin-bottom: 30rpx;
		text-align: center;
	}
</style>
