|
|
@@ -1,18 +1,216 @@
|
|
|
<template>
|
|
|
<div class="home">
|
|
|
- <img alt="Vue logo" src="../assets/logo.png">
|
|
|
- <HelloWorld msg="Welcome to Your Vue.js App"/>
|
|
|
+ <div class="top">
|
|
|
+ <div class="left">珠海高新区中共党史学习教育园地线上展厅</div>
|
|
|
+ <div class="right" @click="cut = !cut">
|
|
|
+ <img src="../assets/user.jpg" alt="" />
|
|
|
+ <p>{{ userName }}</p>
|
|
|
+ <!-- 下箭头 -->
|
|
|
+ <div class="pull_down" v-if="cut"></div>
|
|
|
+ <div class="pull_up" v-else></div>
|
|
|
+ <!-- 点击箭头出来的ul -->
|
|
|
+ <ul class="user_handle" v-show="cut">
|
|
|
+ <li @click="isShow = true">修改密码</li>
|
|
|
+ <li @click="outLogin">退出登录</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 点击修改密码出现弹窗 -->
|
|
|
+ <el-dialog title="修改密码" :visible.sync="isShow" @close="btnX()">
|
|
|
+ <el-form :model="form" label-width="100px" :rules="rules" ref="ruleForm">
|
|
|
+ <el-form-item label="旧密码:" prop="oldPassword">
|
|
|
+ <el-input
|
|
|
+ v-model="form.oldPassword"
|
|
|
+ placeholder="请输入"
|
|
|
+ show-password
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="新密码:" prop="newPassword">
|
|
|
+ <el-input
|
|
|
+ v-model="form.newPassword"
|
|
|
+ placeholder="请输入"
|
|
|
+ show-password
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="确定新密码:" prop="checkPass">
|
|
|
+ <el-input
|
|
|
+ v-model="form.checkPass"
|
|
|
+ placeholder="请输入"
|
|
|
+ show-password
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="btnX">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="btnOk">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-// @ is an alias to /src
|
|
|
-import HelloWorld from '@/components/HelloWorld.vue'
|
|
|
-
|
|
|
+//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
+//例如:import 《组件名称》 from '《组件路径》';
|
|
|
+import { updatePwd } from "../utils/api";
|
|
|
export default {
|
|
|
- name: 'Home',
|
|
|
- components: {
|
|
|
- HelloWorld
|
|
|
+ //import引入的组件需要注入到对象中才能使用
|
|
|
+ components: {},
|
|
|
+ data() {
|
|
|
+ //这里存放数据
|
|
|
+ const validatePass2 = (rule, value, callback) => {
|
|
|
+ if (value !== this.form.newPassword) {
|
|
|
+ callback(new Error('两次输入密码不一致!'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ userName: "",
|
|
|
+ cut: false,
|
|
|
+ isShow: false,
|
|
|
+ // 修改密码
|
|
|
+ form: {
|
|
|
+ oldPassword: "",
|
|
|
+ newPassword: "",
|
|
|
+ checkPass: "",
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ checkPass: [{ validator: validatePass2, trigger: "blur" }],
|
|
|
+ oldPassword: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
|
+ newPassword: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ //监听属性 类似于data概念
|
|
|
+ computed: {},
|
|
|
+ //监控data中的数据变化
|
|
|
+ watch: {},
|
|
|
+ //方法集合
|
|
|
+ methods: {
|
|
|
+ // 修改密码点击取消
|
|
|
+ btnX() {
|
|
|
+ this.$refs.ruleForm.resetFields();
|
|
|
+ this.cut = false;
|
|
|
+ this.isShow = false;
|
|
|
+ this.form = {
|
|
|
+ oldPassword: "",
|
|
|
+ newPassword: "",
|
|
|
+ checkPass: "",
|
|
|
+ };
|
|
|
+ },
|
|
|
+ // 修改密码点击确定
|
|
|
+ async btnOk() {
|
|
|
+ await this.$refs.ruleForm.validate();
|
|
|
+ try {
|
|
|
+ await updatePwd(this.form);
|
|
|
+ this.$message.success("修改成功");
|
|
|
+ localStorage.clear("DSJY_token");
|
|
|
+ localStorage.clear("DSJY_Name");
|
|
|
+ this.$router.push("/");
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("旧密码错误");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ outLogin() {
|
|
|
+ this.cut = false;
|
|
|
+ this.$confirm("确定退出吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ localStorage.clear("DSJY_token");
|
|
|
+ localStorage.clear("DSJY_Name");
|
|
|
+ this.$router.push("/");
|
|
|
+ this.$message.success("退出成功!");
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.info("已取消");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
+ created() {
|
|
|
+ // 获取用户信息
|
|
|
+ this.userName = localStorage.getItem("DSJY_Name");
|
|
|
+ },
|
|
|
+ //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
+ mounted() {},
|
|
|
+ beforeCreate() {}, //生命周期 - 创建之前
|
|
|
+ beforeMount() {}, //生命周期 - 挂载之前
|
|
|
+ beforeUpdate() {}, //生命周期 - 更新之前
|
|
|
+ updated() {}, //生命周期 - 更新之后
|
|
|
+ beforeDestroy() {}, //生命周期 - 销毁之前
|
|
|
+ destroyed() {}, //生命周期 - 销毁完成
|
|
|
+ activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang='less' scoped>
|
|
|
+.home {
|
|
|
+ .top {
|
|
|
+ padding: 0 30px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ height: 100px;
|
|
|
+ background-color: #ac3334;
|
|
|
+ color: #fff;
|
|
|
+ .left {
|
|
|
+ font-weight: 700;
|
|
|
+ font-size: 34px;
|
|
|
+ }
|
|
|
+ .right {
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ img {
|
|
|
+ margin-right: 10px;
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ .pull_down {
|
|
|
+ position: absolute;
|
|
|
+ right: -20px;
|
|
|
+ bottom: 13px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ border-left: 8px solid transparent;
|
|
|
+ border-right: 8px solid transparent;
|
|
|
+ border-bottom: 8px solid #fff;
|
|
|
+ }
|
|
|
+ .pull_up {
|
|
|
+ cursor: pointer;
|
|
|
+ position: absolute;
|
|
|
+ right: -20px;
|
|
|
+ bottom: 13px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ border-left: 8px solid transparent;
|
|
|
+ border-right: 8px solid transparent;
|
|
|
+ border-top: 8px solid #fff;
|
|
|
+ }
|
|
|
+ .user_handle {
|
|
|
+ width: 200px;
|
|
|
+ z-index: 999;
|
|
|
+ padding: 10px 0;
|
|
|
+ position: absolute;
|
|
|
+ right: -30px;
|
|
|
+ bottom: -110px;
|
|
|
+ background-color: #ac3334;
|
|
|
+ li {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ cursor: pointer;
|
|
|
+ margin: 10px 0;
|
|
|
+ }
|
|
|
+ li:hover {
|
|
|
+ color: #dc3545;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-</script>
|
|
|
+</style>
|