| | |
| | | <div class="name">密码:</div> |
| | | <div class="info pwd"> |
| | | ******** |
| | | <el-button type="plain" @click="isShow = true">修改密码</el-button> |
| | | <el-button type="default" @click="isShow = true">修改密码</el-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </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> |
| | |
| | | |
| | | <script setup> |
| | | import {userDetail} from '@/api/login' |
| | | import {removeToken} from '@/utils/auth' |
| | | import {ElMessageBox} from "element-plus"; |
| | | |
| | | 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 loginOut = () => { |
| | | ElMessageBox.confirm('确定注销并退出系统吗?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then((e) => { |
| | | removeToken() |
| | | window.location.reload(); |
| | | |
| | | }) |
| | | } |
| | | |
| | | //修改密码 |
| | | 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("修改成功"); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |