忘记密码代码提交

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

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

Loading…
Cancel
Save