zdg #197

Merged
zhengdegang merged 4 commits from zdg into main 2024-09-11 20:06:22 +08:00
3 changed files with 79 additions and 41 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) {
return request({

View File

@ -1,12 +1,12 @@
<template>
<el-dialog
v-model="dialogVisible"
title="注册账号"
:title="type==1?'注册账号':'找回密码'"
:fullscreen="true"
center
: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="2.在校信息" />
</el-steps>
@ -18,10 +18,10 @@
status-icon
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-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-form-item>
<el-form-item label="手机号" prop="phoneNumber" v-if="activeIndex==1">
@ -67,7 +67,7 @@
</el-form-item>
<el-form-item v-if="activeIndex==1">
<div class="centerDiv">
<el-button type="primary" @click="nextStep(ruleFormRef)">下一步</el-button>
<el-button type="primary" @click="nextStep(ruleFormRef)">{{ ['下一步','重置密码'][type-1]||'未知异常' }}</el-button>
</div>
</el-form-item>
<el-form-item v-if="activeIndex==2">
@ -109,7 +109,7 @@
<script setup>
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 {setToken, removeToken } from '@/utils/auth'
import { regionData, codeToText } from 'element-china-area-data'
@ -225,8 +225,12 @@ const rules = reactive({
},]
})
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
}
//
@ -241,6 +245,23 @@ const nextStep = (formEl) => {
if (!formEl) return
formEl.validate((valid) => {
if (valid) {
// type 1 2
if (type.value == 2) {
let params = {
mobile:ruleForm.phoneNumber,
code:ruleForm.Code,
password:ruleForm.password,
confirmPassword:ruleForm.confirmPassword,
}
retrievePwd(params).then(res=>{
if(res.code==200){
ElMessage.success(res.msg)
handleClose()
}else{
ElMessage.error(res.msg)
}
})
} else {
activeIndex.value=2
//
deptTree({phone:ruleForm.phoneNumber}).then(res=>{
@ -268,6 +289,7 @@ const nextStep = (formEl) => {
console.log(res)
})
console.log('submit!')
}
} else {
console.log('error submit!')
}
@ -296,7 +318,7 @@ const submitForm = async (formEl) => {
schoolId:ruleForm.school[2],
classIds:ruleForm.class.join(','),
subjectIds:ruleForm.discipline.map(o=>o.id).join(','),
subject:ruleForm.discipline.map(o=>o.itemtitle).join(','),
subject:ruleForm.discipline.map(o=>`${o.edustage}-${o.edusubject}`).join(','),
areaIds:ruleForm.address.join(','),
area:araname
}
@ -333,7 +355,7 @@ const sendcaptchaImg=()=>{
if(ruleForm.phoneNumber){
const pattern = /^1[3-9]\d{9}$/;
if( pattern.test(ruleForm.phoneNumber) ){
captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
captchaImg({mobile:ruleForm.phoneNumber, type: type.value}).then(res=>{
ruleForm.imgCode=null
isImg.value=true
isPeopleImg.value='data:image/jpg;base64,'+res.img
@ -354,7 +376,7 @@ const sendcaptchaImg=()=>{
}
//
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
if(res.token){
setToken(res.token)
@ -365,7 +387,14 @@ const refreshImg=()=>{
//
const sbmitImg=()=>{
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){
ruleForm.Code=res.data
isImg.value=false

View File

@ -32,9 +32,9 @@
>
</el-form-item>
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
<a 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>
</el-form>
</div>
@ -98,8 +98,8 @@ ipcRenderer.on('update-app-progress', (e, prop) => {
showDownLoading.value = prop !== 100
})
//
const RegisterModel = () =>{
RegModel.value.OpenModel()
const RegisterModel = type =>{
RegModel.value.OpenModel(type)
}
//
const submitForm = async (formEl) => {