<template>
    身份证号
    <el-input v-model="form.userName" @input="getSecret"></el-input>
    新密码
    <el-input type="password" v-model="form.password"></el-input>
    确认新密码
    <el-input type="password" v-model="form.reppassword"></el-input>
    通过您的密保问题验证身份
    保密问题
    <el-input v-model="form.secretQuestion"></el-input>
    保密答案
    <el-input v-model="form.secretAnswer"></el-input>
    <el-button @click="changePass">确认修改</el-button>
</template>

<script setup>
    import {getSecretByUser,changPasswordBySecret} from '@/api/xjc-platform/xjc_index.js'

    const loading = ref(false)
    const router = useRouter()
    const route = useRoute()
    const {proxy} = getCurrentInstance()

    const params = route.query

    const form = ref({
        userName: '',
        password: '',
        reppassowrd: '',
        secretQuestion: '',
        secretAnswer: ''
    })

    function getSecret() {
        if (form.value.userName.length == 15 || form.value.userName.length == 18) {
            getSecretByUser(form.value.userName).then(resp => {
                form.value.secretQuestion = resp.question
            })
        }
    }
    function  changePass() {
        changPasswordBySecret(form.value).then(resp =>{
            proxy.$modal.msgSuccess("修改密码成功")
            //跳转到主页
            router.push({
                path : '/xjc_login',
                query :{
                    userName : form.value.userName,
                    password : form.value.password,
                    modulePath : params.modulePath
                }
            })
        })
    }


</script>

<style scoped>


</style>
