From 30ffaeb88975bc31bc660a970f5cd450809fd3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=B2=BB=E7=9A=93?= Date: Sat, 10 Apr 2021 10:39:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=AE=A1=E7=90=86=E5=92=8C=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/header/header.vue | 196 +++++++++++++++++++++++++++++-- 1 file changed, 188 insertions(+), 8 deletions(-) diff --git a/src/components/header/header.vue b/src/components/header/header.vue index 45b3800..0c46890 100644 --- a/src/components/header/header.vue +++ b/src/components/header/header.vue @@ -22,8 +22,8 @@ {{ username }} - 个人资料 - 修改密码 + 个人资料 + 修改密码 退出登录 @@ -40,6 +40,66 @@ v-model="notes"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -49,14 +109,67 @@ export default { inject: ['reload'], data () { return { - teacher: `{"teacher":{"id":2,"password":"","status":2,"phone":"213231231","name":"超管","introduce":"213","account":"sj123"}}`, + profile: { + collegeName:"", + groupName:"", + phone:"", + teacher: { + id:"", + status:"", + name:"", + account:"", + } + + }, + password: { + account:"", + oldPas:"", + newPas:"", + newPas2:"", + }, + phoneRules: { + phone: [ + { required: true, message: "电话号码不能为空", trigger: "blur" }, + { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '非法手机号', trigger: 'blur' ,required: true}, + ] + }, + passwordRules: { + newPas: [ + { pattern:/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$)([^\u4e00-\u9fa5\s]){6,20}$/, message:'6-20位英文字母、数字或者符号(除空格),且字母、数字和标点符号至少包含两种', trigger: 'blur',required: true}, + ], + newPas2: [ + { pattern:/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$)([^\u4e00-\u9fa5\s]){6,20}$/, message:'6-20位英文字母、数字或者符号(除空格),且字母、数字和标点符号至少包含两种', trigger: 'blur',required: true}, + ] + }, + roles:[ + "专职教师", + "坐班教师", + "教研主任", + "", + "超管" + ], + dialogTitle: "", + profileFormVisible: false, + passwordFormVisible: false, Utils: Utils, isCollapse: false, dialogVisible: false, notes: localStorage.getItem('notes') || '便签中的内容会存储在本地,这样即便你关掉了浏览器,在下次打开时,依然会读取到上一次的记录。是个非常小巧实用的本地备忘录' } }, - methods: { + created() { + let userInfo = JSON.parse(sessionStorage.getItem('userInfo')); + this.profile.collegeName = userInfo.college.name; + if(userInfo.group != null){ + this.profile.groupName = userInfo.group.name; + } + this.password.account = userInfo.teacher.account; + this.profile.teacher.status = userInfo.teacher.status; + this.profile.teacher.name = userInfo.teacher.name; + this.profile.phone = userInfo.teacher.phone; + this.profile.teacher.id = userInfo.teacher.id; + }, + methods: { collapse () { this.$store.commit('switchCollapse') }, @@ -69,16 +182,83 @@ export default { handleCommand (command) { switch (command) { case 'logout': - this.$router.replace({ path: '/login' }) - break + this.$router.replace({ path: '/login' }); + break; + case 'profile': + this.dialogTitle = "用户信息"; + this.profileFormVisible = true; + break; + case 'updatepwd': + this.dialogTitle = "修改密码"; + this.passwordFormVisible = true; + break; } - } + }, + resetForm(formName) { + this.$refs[formName].clearValidate(); + }, + submitProfile(formName) { + // 表单验证 + this.$refs[formName].validate((valid) => { + if (valid) { + this.$http + .get("/api/teacher/resetPhone?id=" + this.profile.teacher.id + "&number=" + this.profile.teacher.phone) + .then(res =>{ + let userInfo = JSON.parse(sessionStorage.getItem('userInfo')); + userInfo.teacher.phone = this.profile.teacher.phone; + sessionStorage.setItem("userInfo",JSON.stringify(userInfo)); + }); + + this.profileFormVisible = false; + this.$message({ + type: "success", + message: "修改成功!", + }); + } + }); + }, + + submitPassword(formName) { + // 表单验证 + this.$refs[formName].validate((valid) => { + if (valid) { + if (this.password.newPas == this.password.newPas2){ + this.$http + .post("/api/teacher/editPassword", this.password) + .then(res => { + if (res.data.code == 200){ + this.passwordFormVisible = false; + this.$message({ + type: "success", + message: "修改成功" , + }); + }else{ + this.$message({ + type: "warning", + message: res.data.msg, + }); + } + }); + }else { + console.log("两次新密码输入不一致"); + this.$message({ + type: "warning", + message: "两次新密码输入不一致!", + }); + } + + } + }); + }, + + + }, computed: { username () { if(sessionStorage.getItem('userInfo') == "undefined") - + return "超管" let userInfo = JSON.parse(sessionStorage.getItem('userInfo')) -- Gitee From 88b80364d968d3056260c1717bb988c12bf0a71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=B2=BB=E7=9A=93?= Date: Sat, 10 Apr 2021 10:41:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=AE=A1=E7=90=86=E5=92=8C=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index b53f44f..1ca72c5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -13,6 +13,7 @@ import Course from '@/pages/Course' import Program from "../pages/Program"; + Vue.use(Router) export default new Router({ @@ -68,6 +69,8 @@ export default new Router({ name: 'program', component: Program }, + + ] } ] -- Gitee