密码找回

This commit is contained in:
zdg 2024-09-11 20:05:18 +08:00
parent 3632beebfa
commit b9014b950a
3 changed files with 77 additions and 39 deletions

View File

@ -88,6 +88,15 @@ export function signIn(data) {
}) })
} }
//登录模块-找回密码
export function retrievePwd(data) {
return request({
url: '/smarttalk/register/authRetrievePwd',
method: 'post',
data
})
}
//注册模块-获取学校 //注册模块-获取学校
export function deptTree(data) { export function deptTree(data) {
return request({ return request({

View File

@ -1,12 +1,12 @@
<template> <template>
<el-dialog <el-dialog
v-model="dialogVisible" v-model="dialogVisible"
title="注册账号" :title="type==1?'注册账号':'找回密码'"
:fullscreen="true" :fullscreen="true"
center center
:before-close="handleClose" :before-close="handleClose"
> >
<el-steps style="max-width: 100%;-webkit-app-region: no-drag;height:35px" :active="activeIndex" finish-status="success" simple> <el-steps v-if="type==1" style="max-width: 100%;-webkit-app-region: no-drag;height:35px" :active="activeIndex" finish-status="success" simple>
<el-step title="1.基本信息" @click="activeIndex=1" /> <el-step title="1.基本信息" @click="activeIndex=1" />
<el-step title="2.在校信息" /> <el-step title="2.在校信息" />
</el-steps> </el-steps>
@ -18,10 +18,10 @@
status-icon status-icon
ref="ruleFormRef" ref="ruleFormRef"
> >
<el-form-item label="姓名" prop="name" v-if="activeIndex==1"> <el-form-item label="姓名" prop="name" v-if="type==1 && activeIndex==1">
<el-input v-model="ruleForm.name" /> <el-input v-model="ruleForm.name" />
</el-form-item> </el-form-item>
<el-form-item label="身份证号" prop="idNumber" v-if="activeIndex==1"> <el-form-item label="身份证号" prop="idNumber" v-if="type==1 && activeIndex==1">
<el-input v-model="ruleForm.idNumber" /> <el-input v-model="ruleForm.idNumber" />
</el-form-item> </el-form-item>
<el-form-item label="手机号" prop="phoneNumber" v-if="activeIndex==1"> <el-form-item label="手机号" prop="phoneNumber" v-if="activeIndex==1">
@ -67,7 +67,7 @@
</el-form-item> </el-form-item>
<el-form-item v-if="activeIndex==1"> <el-form-item v-if="activeIndex==1">
<div class="centerDiv"> <div class="centerDiv">
<el-button type="primary" @click="nextStep(ruleFormRef)">下一步</el-button> <el-button type="primary" @click="nextStep(ruleFormRef)">{{ ['下一步','重置密码'][type-1]||'未知异常' }}</el-button>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-if="activeIndex==2"> <el-form-item v-if="activeIndex==2">
@ -109,7 +109,7 @@
<script setup> <script setup>
import { ref, defineExpose, reactive ,onMounted} from 'vue' import { ref, defineExpose, reactive ,onMounted} from 'vue'
import {captchaImg,sendCode,deptTree,getDept,listClassmain,listEvaluation,signIn} from '@/api/login' import {captchaImg,sendCode,deptTree,getDept,listClassmain,listEvaluation,signIn, retrievePwd} from '@/api/login'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import {setToken, removeToken } from '@/utils/auth' import {setToken, removeToken } from '@/utils/auth'
import { regionData, codeToText } from 'element-china-area-data' import { regionData, codeToText } from 'element-china-area-data'
@ -225,8 +225,12 @@ const rules = reactive({
},] },]
}) })
const dialogVisible = ref(false) const dialogVisible = ref(false)
const type = ref(1) // 1 2
// //
const OpenModel = () =>{ const OpenModel = v =>{
if (!v) return ElMessage.success('操作失败')
type.value = v
dialogVisible.value=true dialogVisible.value=true
} }
// //
@ -241,33 +245,51 @@ const nextStep = (formEl) => {
if (!formEl) return if (!formEl) return
formEl.validate((valid) => { formEl.validate((valid) => {
if (valid) { if (valid) {
activeIndex.value=2 // type 1 2
// if (type.value == 2) {
deptTree({phone:ruleForm.phoneNumber}).then(res=>{ let params = {
optionsSchool.value=res.data mobile:ruleForm.phoneNumber,
optionsSchool.value.forEach(item=>{ code:ruleForm.Code,
item.value=item.id password:ruleForm.password,
if(!item.children){ confirmPassword:ruleForm.confirmPassword,
item.disabled=true }
} retrievePwd(params).then(res=>{
if(item.children){ if(res.code==200){
item.children.forEach(child=>{ ElMessage.success(res.msg)
child.value=child.id handleClose()
if(!child.children){ }else{
child.disabled=true ElMessage.error(res.msg)
}
if(child.children){
child.children.forEach(grandson=>{
grandson.value=grandson.id
})
}
})
} }
}) })
getSubject() } else {
console.log(res) activeIndex.value=2
}) //
console.log('submit!') deptTree({phone:ruleForm.phoneNumber}).then(res=>{
optionsSchool.value=res.data
optionsSchool.value.forEach(item=>{
item.value=item.id
if(!item.children){
item.disabled=true
}
if(item.children){
item.children.forEach(child=>{
child.value=child.id
if(!child.children){
child.disabled=true
}
if(child.children){
child.children.forEach(grandson=>{
grandson.value=grandson.id
})
}
})
}
})
getSubject()
console.log(res)
})
console.log('submit!')
}
} else { } else {
console.log('error submit!') console.log('error submit!')
} }
@ -333,7 +355,7 @@ const sendcaptchaImg=()=>{
if(ruleForm.phoneNumber){ if(ruleForm.phoneNumber){
const pattern = /^1[3-9]\d{9}$/; const pattern = /^1[3-9]\d{9}$/;
if( pattern.test(ruleForm.phoneNumber) ){ if( pattern.test(ruleForm.phoneNumber) ){
captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{ captchaImg({mobile:ruleForm.phoneNumber, type: type.value}).then(res=>{
ruleForm.imgCode=null ruleForm.imgCode=null
isImg.value=true isImg.value=true
isPeopleImg.value='data:image/jpg;base64,'+res.img isPeopleImg.value='data:image/jpg;base64,'+res.img
@ -354,7 +376,7 @@ const sendcaptchaImg=()=>{
} }
// //
const refreshImg=()=>{ const refreshImg=()=>{
captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{ captchaImg({mobile:ruleForm.phoneNumber, type: type.value}).then(res=>{
isPeopleImg.value='data:image/jpg;base64,'+res.img isPeopleImg.value='data:image/jpg;base64,'+res.img
if(res.token){ if(res.token){
setToken(res.token) setToken(res.token)
@ -365,7 +387,14 @@ const refreshImg=()=>{
// //
const sbmitImg=()=>{ const sbmitImg=()=>{
if(ruleForm.imgCode){ if(ruleForm.imgCode){
sendCode({mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}).then(res=>{ // {mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}
const { phoneNumber:mobile,imgCode:code } = ruleForm
const params = {
mobile, code,
uuid: resImg.imgData.uuid,
type: type.value
}
sendCode(params).then(res=>{
if(res.code==200){ if(res.code==200){
ruleForm.Code=res.data ruleForm.Code=res.data
isImg.value=false isImg.value=false

View File

@ -32,9 +32,9 @@
> >
</el-form-item> </el-form-item>
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;"> <div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="RegisterModel">注册账号</a> <a class="hover:text-sky-500" style="margin-right: 10px;" @click="RegisterModel(1)">注册账号</a>
<!-- | --> <!-- | -->
<!-- <a style="margin-left: 10px;">忘记密码</a> --> <a class="hover:text-sky-500" style="margin-left: 10px;" @click="RegisterModel(2)">忘记密码</a>
</div> </div>
</el-form> </el-form>
</div> </div>
@ -98,8 +98,8 @@ ipcRenderer.on('update-app-progress', (e, prop) => {
showDownLoading.value = prop !== 100 showDownLoading.value = prop !== 100
}) })
// //
const RegisterModel = () =>{ const RegisterModel = type =>{
RegModel.value.OpenModel() RegModel.value.OpenModel(type)
} }
// //
const submitForm = async (formEl) => { const submitForm = async (formEl) => {