| | |
| | | </div> |
| | | <el-dialog v-model="isShow"> |
| | | <div class="title">修改密码</div> |
| | | <el-form model="pwdForm" :rules="rules"> |
| | | <el-form :model="pwdForm" ref="formRef" :rules="rules"> |
| | | <el-form-item prop="oldPassword" label="旧密码"> |
| | | <el-input v-model="pwdForm.oldPassword" placeholder="请输入旧密码"></el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="newPassword" label="新密码"> |
| | | <el-input v-model="pwdForm.newPassword" placeholder="请输入新密码"></el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="confirmPassword" label="确认密码"> |
| | | <el-input v-model="pwdForm.confirmPassword" placeholder="再次输入新密码"></el-input> |
| | | </el-form-item> |
| | | <el-form-item class="handel-btn"> |
| | | <el-button @click="cancel()">取消</el-button> |
| | |
| | | import {userDetail} from '@/api/login' |
| | | const { proxy } = getCurrentInstance(); |
| | | const form = ref({}) |
| | | import { PREURL } from "@/config/index"; |
| | | const preUrl = ref(PREURL) |
| | | const preUrl = ref(import.meta.env.VITE_APP_IMG_BASEURL) |
| | | const getUserInfo = async () =>{ |
| | | let id = JSON.parse(localStorage.getItem('id')) |
| | | await userDetail().get(id).then(res => { |
| | | form.value = res.data |
| | | }) |
| | | } |
| | | |
| | | const confirmPass = (rule, value, callback) => { |
| | | if (value === '') { |
| | | callback(new Error('请再次输入密码')); |
| | | } else if (value !== pwdForm.value.newPassword) { |
| | | callback(new Error('两次输入密码不一致!')); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | |
| | | //修改密码 |
| | | const rules = ref({ |
| | | oldPassword: [{ required: true, trigger: "blur", message: "请输入旧密码" }], |
| | | newPassword: [{ required: true, trigger: "blur", message: "请输入新密码" }], |
| | | }) |
| | | const rules = { |
| | | oldPassword: [ |
| | | { required: true, message: "密码不能为空", trigger: "blur" }, |
| | | ], |
| | | newPassword: [ |
| | | {required: true, pattern: /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[\W_]).{8,}$/, message: "密码必须是8位以上的英文数字字符组合", trigger: "blur" } |
| | | ], |
| | | confirmPassword: [ |
| | | { required: true, validator: confirmPass, message: "两次密码不一致", trigger: "blur" } |
| | | ] |
| | | } |
| | | const formRef = ref() |
| | | const isShow = ref(false) |
| | | const pwdForm = ref({ |
| | | oldPassword:'', |
| | | newPassword:'', |
| | | confirmPassword:'', |
| | | }) |
| | | const modifyPwd = async () =>{ |
| | | await userDetail().setPsw(pwdForm.value).then(res => { |
| | | if(res.code == 200){ |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | const modifyPwd = () =>{ |
| | | formRef.value.validate(async (valid) => { |
| | | if(valid){ |
| | | const data = { |
| | | oldPassword: pwdForm.value.oldPassword, |
| | | newPassword: pwdForm.value.newPassword |
| | | } |
| | | await userDetail().setPsw(data).then(res => { |
| | | if(res.code == 200){ |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |