<template>
	<view class="updata-psw">
		<custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
		<view class="content">
			<view style="width: 100%; padding-left: 24px;">设置密码：</view>
			<view style="height: 12px;"></view>
			<input type="text" maxlength="16" v-model="psw1" placeholder="请输入密码" />
			<view style="height: 24px;"></view>
			<view style="width: 100%; padding-left: 24px;">确认密码：</view>
			<view style="height: 12px;"></view>
			<input type="text" maxlength="16" v-model="psw2" placeholder="请再次输入密码" />
			<view class="big-btn bg" @tap="updata">修改密码</view>
			<view style="height: 12x;"></view>
			<view class="basecolor">* 密码为6至16位任意数字字母组合</view>
		</view>
	</view>
</template>

<script>
	import { _API_UpdataPsw } from '@/apis/verify.js'
 	export default {
		data() {
			return {
				psw1: '',
				psw2: '',
			};
		},
		methods: {
			updata() {
				if (this.psw1.trim().length != this.psw2.trim().length) { uni.toast('两次输入的密码不一致，请确认'); return }
				console.log(this.psw1.trim()  === this.$store.state.userinfo.mobile.toString())
				if (this.psw1.trim()  === this.$store.state.userinfo.mobile.toString()) { uni.toast('新密码不能与原密码一致'); return }
				if (this.psw1.length >= 6 && this.psw1.length <= 16) {
					uni.showLoading({ mask: true })
					_API_UpdataPsw({ password: this.psw1 }).then(res => {
						this.$store.commit('app/LOGOUT')
						uni.reLaunch({ url: '../login-psw/login-psw' })
					})
				} else {
					uni.toast('密码格式错误')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.updata-psw {
		@include page();
		.content {
			@include flex(column);
			justify-content: flex-start;
			padding-top: 98rpx;
			input {
				width: 666rpx;
				height: 98rpx;
				font-size: 45rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 24rpx;
			}
		}
	}
</style>
