<template>
	<view class="content">
		<view class="item">
			<view class="title"> 旧密码 </view>
			<view class="flex">
				<input v-model="state.password" class="uni-input"  placeholder="请输入旧密码" />
				<view @click="$util.navTo('/login/forget-pwd-step1',true)" forget-password class="resetPassword">
					忘记旧密码
				</view>
			</view>
		</view>
		<view style="margin-top: 80rpx" class="item">
			<view class="title"> 新密码 </view>
			<input v-model="state.newPassword" class="uni-input"  placeholder="请输入新密码" />
		</view>
		<view style="margin-top: 80rpx" class="item">
			<view class="title"> 再次确认 </view>
			<input v-model="state.affirmNewPassword" class="uni-input"  placeholder="请再次输入新密码" />
		</view>

		<view class="action">
			<button type="default" class="button" @click="savaHandle()">
				确认修改
			</button>
		</view>
	</view>
</template>

<script setup lang="ts">
	import {changePassword} from "@/utils/network/api.js";
	import {request} from "@/utils/network/request.js";
	import {stringToJson} from "@/utils/network/encryption";
	import {reactive} from "vue";
	import {onLoad} from "@dcloudio/uni-app";
	import {msg} from "@/utils/utils";
	
	const state = reactive({
		password: "",
		newPassword: "",
		affirmNewPassword: "",
	});

	onLoad(() => {});
	const savaHandle = () => {
		const options = {
			type: 2,
			data: state,
			method: "POST",
			showLoading: true,
		};
		request(changePassword, options).then((res) => {
			msg("登录成功！");
			uni.navigateBack();
		});
	};
</script>

<style lang="scss" scoped>
	.content {
		padding: 80rpx 30rpx 30rpx 30rpx;

		.flex {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		.item {
			border-bottom: 1px solid #dcdcdc;

			.title {
				font-size: 28rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #777777;
				line-height: 58rpx;
			}

			.uni-input {
				height: 60rpx;
			}

			.resetPassword {
				font-size: 28rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #00b38b;
				line-height: 28rpx;
			}
		}

		.action {
			margin-top: 60rpx;
			padding-left: 20rpx;
			padding-right: 20rpx;
			padding-bottom: 30rpx;

			.button {
				height: 80rpx;
				background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
				border-radius: 40rpx;
				font-size: 32rpx;
				font-weight: 400;
				color: #ffffff;
				line-height: 80rpx;
			}
		}
	}
</style>
