新增客户修改密码功能

dev_2022-05-11
yujialong 3 years ago
parent c7822e3235
commit 5e7b10c65c
  1. 84
      src/layouts/header/index.vue

@ -2,25 +2,54 @@
<div class="header"> <div class="header">
<div style="line-height: 60px"> <div style="line-height: 60px">
<img class="logo" :src="logoUrl" /> <img class="logo" :src="logoUrl" />
<span class="title">{{title}}</span> <span class="title">{{ title }}</span>
</div> </div>
<div class="action"> <div class="action">
<div class="user" @click="toPersonal"> <el-dropdown class="user-wrap" @command="userCommand">
<div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar> <el-avatar :size="40" :src="avatar"></el-avatar>
<span class="m-l-10">{{ customer ? customerName : userName }}</span> <span class="m-l-10">{{ customer ? customerName : userName }}</span>
</div> </div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="!customer" command="person">个人中心</el-dropdown-item>
<el-dropdown-item v-else command="resetPw">修改密码</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<el-button type="text" class="ml20" @click="loginout">退出</el-button> <el-button type="text" class="ml20" @click="loginout">退出</el-button>
</div> </div>
<el-dialog title="修改密码" :visible.sync="passwordVisible" :close-on-click-modal="false" :append-to-body="true" @close="resetPassword" width="30%">
<el-form ref="passwordForm" label-width="82px">
<el-form-item label="原密码">
<el-input type="password" v-model="passwordForm.password" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码"></el-input>
</el-form-item>
<el-form-item label="确认新密码">
<el-input type="password" v-model="passwordForm.reNewPassword" placeholder="请确认新密码" @keyup.enter.native="submitPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="passwordVisible = false"> </el-button>
<el-button type="primary" @click="submitPassword"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from "vuex";
import util from "@/libs/util";
export default { export default {
data() { data() {
return { return {
passwordVisible: false,
passwordForm: {
password: "",
newPassword: "",
reNewPassword: ""
}
}; };
}, },
computed: { computed: {
@ -37,31 +66,55 @@ export default {
"setTitle", "setLogoUrl", "setAvatar", "setUserName" "setTitle", "setLogoUrl", "setAvatar", "setUserName"
]), ]),
loginout() { // 退 loginout() { // 退
this.$router.push('/login'); this.$router.push("/login");
localStorage.clear(); localStorage.clear();
sessionStorage.clear() sessionStorage.clear();
location.reload(); location.reload();
}, },
toPersonal() { // () getSystemDetail() { // logo
if (!this.customer) {
this.$router.push("/setting/person");
}
},
getSystemDetail () { // logo
this.$get(this.api.logoDetail).then(res => { this.$get(this.api.logoDetail).then(res => {
if (res.data) { if (res.data) {
this.setTitle(res.data.title); this.setTitle(res.data.title);
this.setLogoUrl(res.data.logoUrl); this.setLogoUrl(res.data.logoUrl);
} }
}).catch(res => {}); }).catch(res => {
});
}, },
getUserDetail () { // getUserDetail() { //
this.$get(this.api.queryUserInfoDetails).then(res => { this.$get(this.api.queryUserInfoDetails).then(res => {
let {userAvatars, userName} = res.result.hrUserInfo; let { userAvatars, userName } = res.result.hrUserInfo;
userAvatars && this.setAvatar(userAvatars); userAvatars && this.setAvatar(userAvatars);
this.setUserName(userName); this.setUserName(userName);
}).catch(res => {}); }).catch(res => {
});
},
userCommand(command) { //
if (command == "person") {
this.$router.push("/setting/person");
} else {
this.passwordVisible = true;
}
},
resetPassword() { //
this.passwordForm = {
password: "",
newPassword: "",
reNewPassword: ""
};
}, },
submitPassword() { //
if (!this.passwordForm.password) return util.warningMsg("请输入原密码");
if (!this.passwordForm.newPassword) return util.warningMsg("请输入新密码");
if (!this.passwordForm.reNewPassword) return util.warningMsg("请确认新密码");
if (this.passwordForm.newPassword.length < 6 || this.passwordForm.reNewPassword.length < 6) return util.warningMsg("请输入6位数以上的密码");
if (this.passwordForm.newPassword !== this.passwordForm.reNewPassword) return util.warningMsg("输入的新密码不一致,请重新确认");
if (this.passwordForm.password === this.passwordForm.newPassword) return util.warningMsg("原密码跟新密码不能一致");
this.$post(this.api.examinePassword, this.passwordForm).then(res => {
util.successMsg("修改成功");
this.passwordVisible = false;
}).catch(err => {
});
}
} }
}; };
</script> </script>
@ -80,6 +133,7 @@ export default {
height: 50px; height: 50px;
margin: 0 20px; margin: 0 20px;
} }
.title { .title {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;

Loading…
Cancel
Save