Commit 9c866ac7 authored by tyn's avatar tyn

fix

parent 70d98257
......@@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"test": "vue-cli-service serve --host 192.168.60.48 --development",
"test": "vue-cli-service serve --host 192.168.1.3 --development",
"serve": "vue-cli-service serve --production",
"build": "vue-cli-service build --production"
},
......
......@@ -41,8 +41,8 @@ export const loginApi = (data) => network({
});
export const loginOutApi = () => network({
url: "",
method: "post",
url: "/logOut",
method: "get",
});
export const getUserInfoApi = () => network({
......@@ -65,3 +65,9 @@ export const register = (data) => network({
url: "/register",
method: "post",
});
export const updatePassApi = (data) => network({
url: "/system/userInfo/resetPwd",
method: "post",
data
});
<template>
<div class="update-pass">
<el-dialog :visible.sync="updatePassDialogStatus" width="600px" @close="dialogClose" :close-on-click-modal="false"
custom-class="update-pass-dialog" :show-close="false">
<el-form :model="resetForm" ref="updateForm" :rules="rules" label-width="120px">
<el-form-item label="旧密码" prop="oldPassword">
<el-input v-model="resetForm.oldPassword" placeholder="请输入旧密码" show-password></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newPassword">
<el-input v-model="resetForm.newPassword" placeholder="请输入新密码" show-password></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="resetForm.confirmPassword" placeholder="请确认密码" show-password></el-input>
</el-form-item>
</el-form>
<template slot="title">
<div class="update-pass-header">
<span>修改密码</span>
<i class="el-icon-close" @click="dialogClose"></i>
</div>
</template>
<span slot="footer">
<el-button type="primary" @click="confirm">保存</el-button>
<el-button @click="dialogClose">返回</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { updatePassApi } from "@/api/login";
export default {
name: "updatePass",
props: {
updatePassDialogStatus: {
type: Boolean,
default: false
}
},
model: {
prop: "updatePassDialogStatus",
event: "dialogClose"
},
data() {
const reg = /\s+/g;
const checkPass = str => {
return (rule, value, callback) => {
if (!value && value != "0") {
return callback(new Error(`${str}不能为空`));
}
if (reg.test(value)) {
return callback(new Error(`密码不能包含空格`));
}
if (str === "新密码" && this.resetForm.newPassword == this.resetForm.oldPassword) {
return callback(new Error(`新密码不能跟旧密码相同`));
}
if (str === "确认密码" && this.resetForm.confirmPassword !== this.resetForm.newPassword) {
return callback(new Error(`确认密码跟新密码不相同`));
}
if ((str === "确认密码" || str === "新密码") && (value.length < 8 || value.length > 12)) {
return callback(new Error(`密码长度必须在8到12个字符之间`));
}
callback();
};
};
return {
resetForm: {
oldPassword: "",
newPassword: "",
confirmPassword: ""
},
rules: {
oldPassword: [{ required: true, trigger: "blur", validator: checkPass("旧密码") }],
newPassword: [{ required: true, trigger: "blur", validator: checkPass("新密码") }],
confirmPassword: [{ required: true, trigger: "blur", validator: checkPass("确认密码") }],
}
};
},
//可访问data属性
created() {
},
//计算集
computed: {
},
//方法集
methods: {
dialogClose() {
this.$refs["updateForm"].resetFields();
this.resetForm = this.$options.data.call(this).resetForm;
this.$emit("dialog-close", false);
},
confirm() {
this.$refs["updateForm"].validate(flag => {
if (flag) {
const { oldPassword, newPassword } = JSON.parse(JSON.stringify(this.resetForm));
updatePassApi({ oldPassword, newPassword }).then(res => {
this.$message.success("密码修改成功!");
setTimeout(() => {
this.$store.dispatch("user/loginOut").finally(() => location.href = "/login");
}, 1000);
});
}
});
}
},
}
</script>
<style lang="scss" scoped>
.update-pass {
::v-deep .update-pass-dialog {
margin: 0 !important;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
.el-dialog__header {
padding: 10px 20px;
border-bottom: 1px solid #eeeeee;
}
.el-dialog__body {
padding: 30px 50px;
}
.update-pass-header {
display: flex;
justify-content: space-between;
align-items: center;
& > span:first-of-type {
color: #0081ff;
font-weight: bold;
font-size: 14px;
}
& > i {
&:hover {
cursor: pointer;
color: #0081ff;
}
}
}
.el-dialog__footer {
display: flex;
justify-content: center;
button {
width: 89px;
height: 35px;
line-height: 35px;
padding: 0;
}
}
}
}
</style>
......@@ -10,7 +10,15 @@
<div class="main-container">
<div class="nav-bar">
<el-dropdown class="user-menu">
<span class="user-menu-link">
<span>{{$store.state.user.userInfo.user.phone}}</span><i class="el-icon-caret-bottom el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="updatePass">修改密码</el-dropdown-item>
<el-dropdown-item @click.native="loginOut">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="content-container">
......@@ -19,18 +27,22 @@
</div>
<update-pass v-model="updatePassDialogStatus" @dialog-close="dialogClose"></update-pass>
</div>
</template>
<script>
import SideBar from "@/components/SideBar";
import UpdatePass from "@/components/UpdatePass";
export default {
name: "Home",
components: {
SideBar
SideBar,
UpdatePass
},
data() {
return {
updatePassDialogStatus: false
};
},
//可访问data属性
......@@ -43,7 +55,21 @@ export default {
},
//方法集
methods: {
updatePass() {
this.updatePassDialogStatus = true;
},
loginOut() {
this.$confirm('是否确定退出登录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch("user/loginOut").catch(err => console.log(err)).finally(() => location.href = "/login");
}).catch(err => console.log(err));
},
dialogClose(v) {
this.updatePassDialogStatus = v;
}
},
}
</script>
......@@ -70,8 +96,29 @@ export default {
.nav-bar {
width: 100%;
height: 70px;
border-bottom: 1px solid #EEEEEE;
border-bottom: 1px solid #eeeeee;
box-sizing: border-box;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 16px;
box-sizing: border-box;
.user-menu {
.user-menu-link {
display: flex;
align-items: center;
cursor: pointer;
& > span {
margin-top: 2px;
}
& > i {
font-size: 24px;
}
}
}
}
.content-container {
......
......@@ -54,38 +54,6 @@ export const rolesOfRoutes = [
roles: ["normal"],
},
},
{
path: '/test1',
name: 'test1',
component: "catalogue",
meta: {
title: "测试目录1",
icon: "",
menuType: "M",
inSideBar: true,
inBread: true,
cache: false,
permission: [],
roles: ["normal"],
},
children: [
{
path: '/test2',
name: 'test2',
component: "views/test2",
meta: {
title: "测试菜单2",
icon: "",
menuType: "C",
inSideBar: true,
inBread: true,
cache: false,
permission: [],
roles: ["normal"],
}
}
]
},
]
},
];
\ No newline at end of file
<template>
<div class="test1">
111
</div>
</template>
<script>
export default {
name : "test1",
data() {
return {
}
},
//可访问data属性
created(){
},
//计算集
computed:{
},
//方法集
methods:{
},
}
</script>
<style lang="scss" scoped>
</style>
<template>
<div class="test2">
22
</div>
</template>
<script>
export default {
name : "test2",
data() {
return {
}
},
//可访问data属性
created(){
},
//计算集
computed:{
},
//方法集
methods:{
},
}
</script>
<style lang="scss" scoped>
</style>
......@@ -91,8 +91,8 @@ module.exports = defineConfig({
open: true,
proxy: {
[process.env.VUE_APP_BASE_API]: {
// target: `http://139.9.157.49:8088`,
target: `http://192.168.60.172:8188`,
target: `http://139.9.157.49:8088`,
// target: `http://192.168.60.172:8188`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment