<template>
	<page-meta :page-style="themeColor"></page-meta>
	<div class="view">

		<div class="content">
			<u-input @blur="one" v-model="valueone" placeholder="请输入旧密码" type="password"></u-input>
			<u-input @blur="two" v-model="valuetwo" placeholder="请输入新密码，6-30位数字和字母" type="password"></u-input>
			<u-input @blur="sui" v-model="valuesui" maxlength="30" placeholder="请确认新密码，6-30位数字和字母"
				type="password"></u-input>
			<div class="btn" @click="btn">
				确认修改
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				valueone: '',
				valuetwo: '',
				valuesui: ''
			}
		},
		methods: {
			one() {

			},
			two() {

			},
			sui() {

			},
			btn() {
				let _this = this
				if (this.valueone.length == 0) {
					this.$util.showToast({
						title: '请输入旧密码'
					});
					return
				}
				if (!this.valuetwo) {
					this.$util.showToast({
						title: '请输入新密码'
					});
					return
				}
				if (this.valuetwo.length < 6) {
					this.$util.showToast({
						title: '请输入6-30位数字和字母密码'
					});
					return
				}
				if (this.valuesui.length == 0) {
					this.$util.showToast({
						title: '请再次输入新密码'
					});
					return
				}
				if (this.valuesui.length < 6) {
					console.log(this.valuesui.length);
					this.$util.showToast({
						title: '请输入请输入6-30位数字和字母密码'
					});
					return
				}
				if (this.valuetwo !== this.valuesui) {
					this.$util.showToast({
						title: '两次密码不一致，请重新输入'
					});
					return
				}
				_this.$api.sendRequest({
					url: '/api/salasman/modifypassword',
					data: {
						old_password: _this.valueone,
						new_password: _this.valuesui
					},
					success: res => {
						this.$util.showToast({
							title: '修改成功'
						});
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages_tool/login/login'
							})
						}, 1000)
					}
				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.view {
		min-height: 100vh;
		background-color: white;

		.content {
			padding: 40rpx;

			::v-deep {
				.u-input--radius {
					height: 92rpx;
					background: #F6F6F6;
					border-radius: 16rpx;
					border: 0;
					margin-bottom: 30rpx;
					padding: 12rpx 32rpx !important;
				}

				.uni-input-placeholder {
					// margin-left: 38rpx;
				}
			}

			.suffix {
				width: 140rpx;
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #EF6154;
				line-height: 40rpx;
				margin-right: 24rpx;
			}

			.btn {
				margin-top: 80rpx;
				height: 80rpx;
				background: $base-color;
				border-radius: 50rpx;

				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 600;
				color: #FFFFFF;

				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}
</style>