<template>
	<view class="content inputClass bgfff">
		<view class="lanBox">
			<view class="lan">
				<view class="left">旧密码</view>
				<view class="right">
					<input type="text" v-model="oldPassword" placeholder="请输入您的旧密码" />
					<uni-icons type="close" v-if="oldPassword" size="22" @click="oldPassword=' ' " />
				</view>
			</view>
			<view class="lan">
				<view class="left">新密码</view>
				<view class="right">
					<input type="text" v-model="newPassword" placeholder="请输入您的新密码" />
					<uni-icons type="close" size="22" v-if="newPassword" @click="newPassword=' ' " />
				</view>
			</view>
		</view>
		<view class="btn mt-15" @click="confirmInfo">确定</view>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		data() {
			return {
				oldPassword: "",
				newPassword: ""
			}
		},
		methods: {
			// 提交
			confirmInfo() {
				let that = this
				if (!this.oldPassword) {
					this.$tools.msg("请输入旧密码")
					return;
				}
				if (!this.newPassword) {
					this.$tools.msg("请输入新密码")
					return;
				}
				that.$model.getChangePassword({
					oldPassword: this.oldPassword,
					newPassword: this.newPassword
				}).then(res => {
					if (res.code == 0) {
						that.$tools.msg("密码修改成功，请重新登录");
						setTimeout(function() {
							uni.redirectTo({
								url: "/pageTwo/login/login"
							})
						}, 1500)
					} else {
						that.$tools.msg(res.message);
					}
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	.left {
		margin-top: 20px;
		font-weight: bold;
		width: 85px !important;
	}

	.right {
		width: calc(100% - 95px) !important;
		background-color: #f7f7f7;
		margin-top: 20px;
		border: none !important;

		uni-icons {
			position: absolute;
			right: 0;
			color: #dfdfdf;
			z-index: 9999;
		}
	}

	.btn {
		margin-top: 50px !important;
	}
</style>