忘记密码代码提交

master
zhangdi 1 year ago
parent 7cf8d2e151
commit 2eb9cb1dc9
  1. 16
      src/api/user.js
  2. 297
      src/page/login/forgetPassword.vue

@ -157,3 +157,19 @@ export const sendSms = (tenantId, phone) => request({
phone,
},
});
export const resetPwd = (refresh_token, tenantId, deptId, roleId) => request({
url: '/api/blade-system/user/register/reset-pwd',
method: 'post',
headers: {
'Tenant-Id': tenantId,
'Dept-Id': (website.switchMode ? deptId : ''),
'Role-Id': (website.switchMode ? roleId : '')
},
params: {
tenantId,
refresh_token,
grant_type: "refresh_token",
scope: "all",
}
});

@ -1,159 +1,172 @@
<template>
<div class="container">
<div class="top_box">
科研医疗建筑运维平台
<div class="container">
<div class="top_box">
科研医疗建筑运维平台
</div>
<div class="bottom_box">
<div class="bottom_tit">
<div>忘记密码</div>
</div>
<div class="bottom_box">
<div class="bottom_tit">
<div>忘记密码</div>
</div>
<div class="bottom_con">
<el-form ref="form" :model="loginForm" :rules="loginRules" label-width="100px" style="width: 28%;margin: 0 auto;">
<el-form-item label="手机号" prop="phoneNumber">
<el-input v-model="loginForm.phoneNumber"></el-input>
</el-form-item>
<el-form-item label="手机验证码" prop="valiNum">
<el-input v-model="loginForm.valiNum" style="width:60%" :disabled="!isShowValite"></el-input>
<el-button style="width:38%;margin-left:2%;" :disabled="!/^1[3-9][0-9]{9}$|^15[0-9]{2}[0-9]{8}$|^17[0-9]{2}[0-9]{7}$|^18[0-9]{3}[0-9]{6}$/.test(loginForm.phoneNumber)" @click="getVerfyCode">获取验证码</el-button>
</el-form-item>
<el-form-item label="设置密码" prop="password">
<el-input v-model="loginForm.password"></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="comfirmPassword">
<el-input v-model="loginForm.comfirmPassword"></el-input>
</el-form-item>
<el-button class="next_box" @click="handleRegsiter">下一步</el-button>
</el-form>
</div>
<div class="bottom_con">
<el-form ref="form" :model="loginForm" :rules="loginRules" label-width="100px"
style="width: 28%;margin: 0 auto;">
<el-form-item label="手机号" prop="phoneNumber">
<el-input v-model="loginForm.phoneNumber"></el-input>
</el-form-item>
<el-form-item label="手机验证码" prop="valiNum">
<el-input v-model="loginForm.valiNum" style="width:60%" :disabled="!isShowValite"></el-input>
<el-button style="width:38%;margin-left:2%;"
:disabled="!/^1[3-9][0-9]{9}$|^15[0-9]{2}[0-9]{8}$|^17[0-9]{2}[0-9]{7}$|^18[0-9]{3}[0-9]{6}$/.test(loginForm.phoneNumber)"
@click="getVerfyCode">获取验证码</el-button>
</el-form-item>
<el-form-item label="设置密码" prop="password">
<el-input v-model="loginForm.password"></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="comfirmPassword">
<el-input v-model="loginForm.comfirmPassword"></el-input>
</el-form-item>
<el-button class="next_box" @click="handleRegsiter">确定</el-button>
</el-form>
</div>
</div>
</template>
<script>
export default {
data() {
var validatePass2 = (rule, value, callback) => {
console.log('value============>',value)
if(!value){
callback(new Error('请确认密码'));
}else if (value && value == '') {
callback(new Error('请确认密码'));
} else if (value !== this.loginForm.password) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
};
return {
loginForm:{},
options:[],
dialogVisible:false,
keyword:'',
positionList:[],
showPositionList:false,
center:{ lng: 116.404, lat: 39.915},
BMap:null,
points:[],
showInfowindow:false,
infoPosition:{lng:'',lat:''},
infoName:'',
infoAddress:'',
address:'',
province:'',
city:'',
district:'',
isMarker:false,
loginRules:{
phoneNumber:[
{required:true,message:'请输入手机号',trigger:'blur'},
{pattern:/^1[3-9][0-9]{9}$|^15[0-9]{2}[0-9]{8}$|^17[0-9]{2}[0-9]{7}$|^18[0-9]{3}[0-9]{6}$/,message:'请输入正确的手机号格式'}
],
password:{required:true,message:'请设置密码',trigger:'blur'},
comfirmPassword:{ validator: validatePass2, trigger: 'blur' },
valiNum:{required:true,message:'请输入手机验证码',trigger:'blur'},
},
isShowValite:false
</div>
</template>
<script>
import {resetPwd} from "@/api/user";
export default {
data() {
var validatePass2 = (rule, value, callback) => {
console.log('value============>', value)
if (!value) {
callback(new Error('请确认密码'));
} else if (value && value == '') {
callback(new Error('请确认密码'));
} else if (value !== this.loginForm.password) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
},
mounted() {},
methods: {
//
trunLogin(){
this.$router.push({path: "/login"});
};
return {
loginForm: {},
options: [],
dialogVisible: false,
keyword: '',
positionList: [],
showPositionList: false,
center: { lng: 116.404, lat: 39.915 },
BMap: null,
points: [],
showInfowindow: false,
infoPosition: { lng: '', lat: '' },
infoName: '',
infoAddress: '',
address: '',
province: '',
city: '',
district: '',
isMarker: false,
loginRules: {
phoneNumber: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ pattern: /^1[3-9][0-9]{9}$|^15[0-9]{2}[0-9]{8}$|^17[0-9]{2}[0-9]{7}$|^18[0-9]{3}[0-9]{6}$/, message: '请输入正确的手机号格式' }
],
password: { required: true, message: '请设置密码', trigger: 'blur' },
comfirmPassword: { validator: validatePass2, trigger: 'blur' },
valiNum: { required: true, message: '请输入手机验证码', trigger: 'blur' },
},
//
getVerfyCode(){
verifycode({phone:this.loginForm.phoneNumber}).then(res =>{
console.log('res===========>',res)
if(res.data.code == 200){
this.$message.success('验证码已发送,请填写验证码')
this.isShowValite = true
}
})
},
//
handleRegsiter(){
this.$refs.form.validate((valid) =>{
if(valid){
isShowValite: false
}
},
mounted() { },
methods: {
//
trunLogin() {
this.$router.push({ path: "/login" });
},
//
getVerfyCode() {
verifycode({ phone: this.loginForm.phoneNumber }).then(res => {
console.log('res===========>', res)
if (res.data.code == 200) {
this.$message.success('验证码已发送,请填写验证码')
this.isShowValite = true
}
})
},
//
handleRegsiter() {
this.$refs.form.validate((valid) => {
if (valid) {
let query = {
phone: this.loginForm.phoneNumber,
password: this.loginForm.password,
verifyCode: this.loginForm.valiNum,
}
})
},
resetPwd(query).then(res => {
this.$message.success('修改成功,请登录')
setTimeout(()=>{
this.$router.push({ path: "/login" });
},500)
})
}
})
},
},
}
</script>
<style lang="scss" scoped>
.container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
background: rgb(207, 207, 207);
.top_box {
width: 98%;
height: 15%;
font-size: 40px;
font-weight: bold;
display: flex;
align-items: center;
padding-left: 2%;
background: #fff;
}
</script>
<style lang="scss" scoped>
.container{
width: 100%;
height: 100%;
position: absolute;
top: 0;
background: rgb(207, 207, 207);
.top_box{
width: 98%;
height: 15%;
font-size: 40px;
font-weight: bold;
.bottom_box {
width: 85%;
height: 80%;
background: #fff;
margin: 1% auto;
.bottom_tit {
height: 8%;
width: 95%;
padding: 1% 2.5%;
display: flex;
align-items: center;
padding-left: 2%;
background: #fff;
justify-content: space-between;
}
.bottom_box{
width: 85%;
height:80%;
background: #fff;
margin: 1% auto;
.bottom_tit{
height: 8%;
width: 95%;
padding: 1% 2.5%;
.bottom_con {
width: 100%;
height: 85%;
// background: red;
margin: 0 auto;
overflow-y: auto;
.next_box {
width: 80%;
display: flex;
align-items: center;
justify-content: space-between;
}
.bottom_con{
width: 100%;
height: 85%;
// background: red;
margin: 0 auto;
overflow-y: auto;
.next_box{
width: 80%;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10%;
margin-top: 10%;
}
justify-content: center;
margin-left: 10%;
margin-top: 10%;
}
}
}
</style>
}
</style>

Loading…
Cancel
Save