登录修改

qianlishi 3 years ago
parent ce6efacbbb
commit bb7cc9e56f

@ -51,7 +51,7 @@ service.interceptors.response.use(
} }
else { else {
Message({ Message({
message: res.repMsg, message: res.repMsg || res.message,
type: 'error', type: 'error',
duration: 3 * 1000 duration: 3 * 1000
}) })

@ -1,23 +1,21 @@
<template> <template>
<div> <div>
<el-menu class="navbar" <el-menu class="navbar" mode="horizontal">
mode="horizontal"> <hamburger
<hamburger :toggle-click="toggleSideBar" :toggle-click="toggleSideBar"
:is-active="sidebar.opened" :is-active="sidebar.opened"
class="hamburger-container" /> class="hamburger-container"
/>
<breadcrumb /> <breadcrumb />
<el-dropdown class="avatar-container" <el-dropdown class="avatar-container" trigger="click">
trigger="click">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<i class="icon iconfont iconyonghu user" /> <i class="icon iconfont iconyonghu user" />
<span class="user-name">{{userName}}</span> <span class="user-name">{{ userName }}</span>
<i class="el-icon-caret-bottom" /> <i class="el-icon-caret-bottom" />
</div> </div>
<el-dropdown-menu slot="dropdown" <el-dropdown-menu slot="dropdown" class="user-dropdown">
class="user-dropdown">
<el-dropdown-item divided> <el-dropdown-item divided>
<span style="display:block;" <span style="display:block;" @click="logout"></span>
@click="logout">注销登录</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -26,21 +24,21 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from "vuex";
import Breadcrumb from '@/components/Breadcrumb' import Breadcrumb from "@/components/Breadcrumb";
import Hamburger from '@/components/Hamburger' import Hamburger from "@/components/Hamburger";
import { getItem, delItem, getStorageItem } from "@/utils/storage" import { getItem, delItem, getStorageItem } from "@/utils/storage";
import { aesEncrypt } from '@/utils/aes' import { aesEncrypt } from "@/utils/aes";
import { reqUpdatePassword } from "@/api/login" import { reqUpdatePassword } from "@/api/login";
export default { export default {
data () { data() {
// //
var validatePass3 = (rule, value, callback) => { var validatePass3 = (rule, value, callback) => {
if (value === '') { if (value === "") {
callback(new Error('请再次输入密码')); callback(new Error("请再次输入密码"));
} else if (value !== this.form.password) { } else if (value !== this.form.password) {
callback(new Error('两次输入密码不一致!')); callback(new Error("两次输入密码不一致!"));
} else { } else {
callback(); callback();
} }
@ -54,105 +52,103 @@ export default {
// }; // };
const validateOldPass = (rule, value, callback) => { const validateOldPass = (rule, value, callback) => {
if (value.length < 6 || value.length > 30) { if (value.length < 6 || value.length > 30) {
callback(new Error('请输入原密码')) callback(new Error("请输入原密码"));
} else { } else {
callback() callback();
} }
}; };
return { return {
userName: '', userName: "",
wordVisible: false, // wordVisible: false, //
form: { form: {
oldPassword: '', oldPassword: "",
password: '', password: "",
confirmPassword: '' confirmPassword: ""
}, },
rules: { rules: {
oldPassword: [ oldPassword: [
{ required: true, validator: validateOldPass, trigger: 'blur' } { required: true, validator: validateOldPass, trigger: "blur" }
], ],
password: [ password: [
{ required: true, message: '请选择新密码', trigger: 'blur' } { required: true, message: "请选择新密码", trigger: "blur" }
], ],
confirmPassword: [ confirmPassword: [
{ required: true, validator: validatePass3, trigger: 'blur' } { required: true, validator: validatePass3, trigger: "blur" }
] ]
} }
} };
}, },
components: { components: {
Breadcrumb, Breadcrumb,
Hamburger Hamburger
}, },
computed: { computed: {
...mapGetters([ ...mapGetters(["sidebar"])
'sidebar'
])
}, },
created () { created() {
this.userName = "admin" this.userName = getItem("username");
}, },
methods: { methods: {
toggleSideBar () { toggleSideBar() {
this.$store.dispatch('ToggleSideBar') this.$store.dispatch("ToggleSideBar");
}, },
logout () { logout() {
this.$confirm('确定要退出吗', '温馨提示', { this.$confirm("确定要退出吗", "温馨提示", {
confirmButtonText: '确定', confirmButtonText: "确定",
cancelButtonText: '取消', cancelButtonText: "取消",
type: 'warning' type: "warning"
}).then(() => { }).then(() => {
delItem('token') delItem("token");
sessionStorage.clear() sessionStorage.clear();
localStorage.clear() localStorage.clear();
this.$router.push('/login') this.$router.push("/login");
}) });
}, },
// //
updatePassword () { updatePassword() {
this.wordVisible = true this.wordVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.form && this.$refs.form.resetFields(); this.$refs.form && this.$refs.form.resetFields();
}) });
}, },
// //
confrimUpdate () { confrimUpdate() {
this.$refs.form.validate((valid) => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
const { oldPassword, password, confirmPassword } = this.form const { oldPassword, password, confirmPassword } = this.form;
let data = { let data = {
oldPassword: aesEncrypt(oldPassword), oldPassword: aesEncrypt(oldPassword),
password: aesEncrypt(password), password: aesEncrypt(password),
confirmPassword: aesEncrypt(confirmPassword), confirmPassword: aesEncrypt(confirmPassword)
} };
reqUpdatePassword(data).then(res => { reqUpdatePassword(data).then(res => {
if (res.repCode == "0000") { if (res.repCode == "0000") {
this.wordVisible = false this.wordVisible = false;
this.$message.success("修改密码成功,请重新登录") this.$message.success("修改密码成功,请重新登录");
sessionStorage.clear() sessionStorage.clear();
localStorage.clear() localStorage.clear();
delItem('token') delItem("token");
this.$router.push('/login') this.$router.push("/login");
} }
}) });
} else { } else {
return false; return false;
} }
}); });
}, },
helpCenter () { helpCenter() {
let helpCategory = JSON.parse(localStorage.getItem('helpCategory')) let helpCategory = JSON.parse(localStorage.getItem("helpCategory"));
this.$router.push({ this.$router.push({
path: '/helpCenList/list', path: "/helpCenList/list",
query: { query: {
id: 0, id: 0,
val: helpCategory[0].value, val: helpCategory[0].value,
title: helpCategory[0].label title: helpCategory[0].label
} }
}) });
} }
} }
} };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
@ -224,4 +220,3 @@ export default {
margin-top: 0; margin-top: 0;
} }
</style> </style>

@ -230,8 +230,10 @@ export default {
verifyCode: "" verifyCode: ""
}; };
const { code, data } = await login(obj); const { code, data } = await login(obj);
console.log(data);
if (code != "200") return; if (code != "200") return;
setItem("token", data.token); setItem("token", data.token);
setItem("username", data.username);
this.loading = false; this.loading = false;
// cookie,15 // cookie,15
this.rememberPsw && this.rememberPsw &&

Loading…
Cancel
Save