<template>
	<view class="content">
		<view class="updatePassword-wrap">
			<view class="username item">
				<text>新密码：</text>
				<uni-easyinput :inputBorder="false" v-model="password"
					class="input" 
					type="text"  
					placeholder="请输入新密码" />
			</view>
			<view class="password item">
				<text>确认密码：</text>
				<uni-easyinput v-model="rePassword"
				 :inputBorder="false" 
				 class="input"
				 type="text"  placeholder="请确认密码">
				</uni-easyinput>
			</view>
			<button type="primary" @click="submit" class="submit-BT">提交</button>
		</view>
	</view>
</template>

<script>
	import {updatePwd} from '@/api/system.js'
	export default {
		data() {
			return {
				password: "",
				rePassword: "",
			}
		},
		methods: {		
			submit() {		
				let rePassword = (this.rePassword).trim();
				let password = (this.password).trim();

				if (password.length < 1) {
					uni.showToast({
						title: '请填写新密码',
						icon: "error"
					})
					return;
				}
				if (rePassword!==password) {
					uni.showToast({
						title: '两次密码不一致',
						icon: "error"
					})					
					return;
				}
				updatePwd({
					password,
					rePassword
				}).then(()=>{
					uni.showToast({
						title:'修改成功',
						duration:2000,
						complete() {
							uni.reLaunch({
								url:'/pages/login/index'
							})
						}
					})					
				})

			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.head {
			font-size: 50upx;
			text-align: center;
			padding: 40upx 0;
			letter-spacing: 2upx;
		}
		.updatePassword-wrap {
			margin: 100upx auto 0;
			box-sizing: border-box;
			padding: 20upx 30upx;
			border-radius: 8upx;
			.item {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				height: 90upx;
				font-size: 32upx;
				line-height: 90upx;
				background-color: #fff;
				border-radius: 50upx;
				padding: 0 20upx;
				.input{
					width: 520upx;
					border: none;
				}
				&.password {
					margin-top: 40upx;
				}
			}
			.tip {
				text-align: right;
				padding: 18upx 0;
				font-size: 28upx;
			}
			.submit-BT {
				width: 600rpx;
				height: 72rpx;
				line-height: 72rpx;	
				text-align: center;							
				background:#3D90F4;
				border-radius: 42rpx;	
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				z-index: 999;
				margin: 100rpx auto;
			}
		}
	}
</style>
