<template>
	<view>
		<view class="login">
			<input type="text" class="login_input" placeholder="New password" v-model="query.password1" @input="verificationLogin">
			<input type="text" class="login_input" placeholder="Confirm password" v-model="query.password2" @input="verificationLogin">
			<button class="login_submit" :disabled="isLogin" @click="submit">SUBMIT</button>
		</view>
	</view>
</template>

<script>
	import {defaultRequest} from '../../api/index.js'
	export default {
		data() {
			return {
				query:{
					_action:'resetuserpwd',
					username:'',
					password1:'',
					password2:'',
					resetcode:''
				},
				isLogin:true,
				user_info:{}
			}
		},
		methods:{
			submit(){
				defaultRequest(this.query).then(res=>{
					console.info(res)
					if(res.error==0){
						uni.showToast({
							title:res.message,
							icon:'none'
						})
						setTimeout(function() {
							uni.navigateBack({
								delta:2
							})
						},2000)
						
					}
				})
			},
			// 验证是否填写登录信息
			verificationLogin(){
				if(this.query.password1&& this.query.password2){
					this.isLogin=false
				}else{
					this.isLogin=true
				}
			},
		},
		onLoad(e) {
			console.info(e)
			this.query.username=e.username
			this.query.resetcode=e.resetcode
			this.user_info=uni.getStorageSync('user_info')
		}
	}
</script>
<style lang="scss">
	page{
		border-top: 13.33rpx #F7F7F7 solid;
		padding-top: 48rpx;
	}
</style>
<style lang="scss" scoped>
	
	.login_submit{
		font-size: 26.67rpx;
		color:#fff !important;
	}
</style>