<template>
	<view>
		<!-- 头部 -->
		<headContent>
			<template #left>
				<view class="head-revers-back iconfont" @click.stop="reversBackBtn()">&#xe604;</view>
			</template>
		</headContent>

		<view class="page-content">
			<text class="login-title">重置密码</text>
			<setPswd @submitPswd="submitPswd" />
		</view>

		<load ref="loadRef" />
	</view>
</template>

<script>
	import setPswd from "./modules/set-pswd.vue"
	import {
		reverseBack
	} from "@/utils/common.js"
	import {
		Api_setPassword
	} from "@/api/index.js"
	export default {
		name: 'reset-pswd',
		components: {
			setPswd
		},
		data() {
			return {
				account: '',
				code: '',

			};
		},

		onLoad(opt) {
			this.account = opt?.account;
			this.code = opt?.code;
		},
		mounted() {

		},
		methods: {
			reversBackBtn() {
				reverseBack()
			},

			submitPswd(e) {
				uni.showLoading({
					title: ''
				})
				const obj = {
					account: this.account,
					code: this.code || -1,
					password: e.newPassword,
					repassword: e.confirmPassword
				}
				Api_setPassword(obj).then(res => {
						uni.showToast({
							title: '重置成功',
							icon: 'none'
						})
					setTimeout(() => {
						reverseBack('pages/login/index')
					}, 200)
				}).catch(err => {}).finally(() => {
					uni.hideLoading()
				})



			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "~./common.scss";
</style>