<template>
	<view class="df jcc fdc">
		<view class="login-righttitle">重置密码</view>
		<view class="fdc df jcc resetPWD-listbox">
			<!-- 手机号 -->
			<view class="df resetPWD-inputbox aic">
				<view class="resetPWD-inputbox-icon">
					<img class="df" src="../../assets/login/loginIcon4.png" />
				</view>
				<input @input="onPhoneNumInput" class="resetPWD-inputbox-input" type="text" placeholder="手机号" />
			</view>
			<!-- 横线 -->
			<view class="resetPWD-line"></view>
			<!-- 验证码 -->
			<view class="df resetPWD-inputbox aic">
				<view class="resetPWD-inputbox-icon">
					<img class="df" src="../../assets/login/loginIcon6.png" />
				</view>
				<input @input="onCodeInput" class="resetPWD-inputbox-input" type="text" placeholder="验证码" />
				<view class="resetPWD-sendcodebtn df jcc aic">获取验证码</view>
			</view>
			<!-- 横线 -->
			<view class="resetPWD-line"></view>
			<!-- 新密码 -->
			<view class="df resetPWD-inputbox aic">
				<view class="resetPWD-inputbox-icon">
					<img class="df" src="../../assets/login/loginIcon1.png" />
				</view>
				<input @input="onNewPWDInput" class="resetPWD-inputbox-input" type="password" placeholder="新密码：6-16位字符，包含字母和数字" />
			</view>
			<!-- 横线 -->
			<view class="resetPWD-line"></view>
			<!-- 登录按钮 -->
			<view class="resetPWD-loginbtn df jcc aic btn-hover" @click="onLogin">登录</view>
			<!-- 注册账号 -->
			<view class="df fdr resetPWD-registerOrForgetBox  jcc aic">
				<a :href="regURL" class="loginByPWD-register">注册实验空间账号</a>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneNum: '',
				code:'',
				newPassword: '',
				regURL: 'http://www.ilab-x.com/register',
			}
		},
		methods: {
			onPhoneNumInput: function(event) {
				this.phoneNum = event.target.value
			},
			onCodeInput: function(event) {
				this.code = event.target.value
			},
			onNewPWDInput: function(event) {
				this.newPassword = event.target.value
			},
			onLogin: function(type) {
				// this.$emit("onLogin", "onLogin")
				this.findUser();
				
				// let url = "http://39.105.166.141:8085/user/addusers";
				// uni.request({
				// 	header: {
				// 		'Content-Type': 'application/json;charset=UTF-8'
				// 	},
				// 	url: url,
				// 	method: 'POST',
				// 	data: {
				// 		"IlabAccount": this.account,
				// 		"Password": this.password
				// 	},
				// 	dataType: 'json',
				// 	success: (res) => {
				// 		// let data = res.data;
				// 		// //登录成功
				// 		// if (data.Code == 100) {
				// 		// 	this.$emit("onLogin")
				// 		// }
				// 		// //密码错误
				// 		// else {
				// 		// 	this.isShowTip=1;
				// 		// }
				// 		console.log("success+++**+*", res)
				// 	},
				// 	fail: (res) => {
				// 		console.log("fail+**+*", res)
				// 	}
				// });
			},
			findUser(){
				console.log(this.phoneNum);
				let url = "http://39.105.166.141:8085/user/finduser";
				uni.request({
					header: {
						'Content-Type': 'application/json;charset=UTF-8'
					},
					url: url,
					method: 'POST',
					data: {
						"IlabAccount": this.phoneNum,
					},
					dataType: 'json',
					success: (res) => {
						let data = res.data;
						if (data.Code == 100) {
							// this.$emit("onLogin")
							console.log("userinfo",data);
						}
						else {
							// this.isShowTip=1;
							console.log("用户未注册");
						}
						console.log("success+++**+*", res)
					},
					fail: (res) => {
						console.log("fail+**+*", res)
					}
				});
			}
		}
	}
</script>

<style>
	.resetPWD-listbox {
		margin-top: 2.19vw;
	}

	.resetPWD-inputbox {
		margin-top: 2.5vw;
	}

	.resetPWD-inputbox-icon {
		margin-left: 0.47vw;
	}

	.resetPWD-inputbox-input {
		font-size: 1.04vw;
		border: none;
		margin-left: 1.25vw;
		flex-grow: 1;
	}

	.resetPWD-line {
		margin-top: 0.73vw;
		width: 23.54vw;
		height: 0.104vw;
		background-color: #E6E6E6;
	}

	.resetPWD-sendcodebtn {
		width: 5.26vw;
		height: 1.979vw;
		background: #F4F4F4;
		border-radius: 7px;
		font-size: 0.729vw;
		font-family: MicrosoftYaHei;
		color: #999999;
		line-height: 0.989vw;
	}

	.resetPWD-loginbtn {
		height: 3.125vw;
		font-size: 0.989vw;
		font-family: MicrosoftYaHei;
		line-height: 1.302vw;
		margin-top: 2.083vw;
		border-radius: 8px;
	}

	.resetPWD-registerOrForgetBox {
		margin-top: 1.56vw;
		font-size: 0.78vw;
		font-family: MicrosoftYaHei;
		color: #EA252C;
		line-height: 1.04vw;
	}

	.resetPWD-register {
		margin-left: 2px;
	}
</style>
