Commit 4d81bacbb3e027b001e6ed492c1b71e53a35d9eb
1 parent
167079c6
添加修改密码
Showing
3 changed files
with
142 additions
and
7 deletions
src/api/apis/apis.js
| @@ -1333,4 +1333,14 @@ export default { | @@ -1333,4 +1333,14 @@ export default { | ||
| 1333 | data, | 1333 | data, |
| 1334 | }); | 1334 | }); |
| 1335 | }, | 1335 | }, |
| 1336 | + | ||
| 1337 | + | ||
| 1338 | + //修改密码 | ||
| 1339 | + changePwd(data) { | ||
| 1340 | + return service({ | ||
| 1341 | + url: setUpUrls.changePwd, | ||
| 1342 | + method: "POST", | ||
| 1343 | + data, | ||
| 1344 | + }); | ||
| 1345 | + }, | ||
| 1336 | }; | 1346 | }; |
src/api/urls/apis.js
| @@ -340,4 +340,8 @@ export default { | @@ -340,4 +340,8 @@ export default { | ||
| 340 | pLatestVersion: "/api_html/personal/latestVersion", | 340 | pLatestVersion: "/api_html/personal/latestVersion", |
| 341 | // 载指定版本授课端 | 341 | // 载指定版本授课端 |
| 342 | pGetAppDownloadUrl: "/api_html/personal/getAppDownloadUrl", | 342 | pGetAppDownloadUrl: "/api_html/personal/getAppDownloadUrl", |
| 343 | + | ||
| 344 | + | ||
| 345 | + // 修改密码 | ||
| 346 | + changePwd: "/api_html/changePwd", | ||
| 343 | } | 347 | } |
src/views/layout/header/header.vue
| @@ -9,7 +9,10 @@ | @@ -9,7 +9,10 @@ | ||
| 9 | <!-- <li> | 9 | <!-- <li> |
| 10 | <langSelect></langSelect> | 10 | <langSelect></langSelect> |
| 11 | </li> --> | 11 | </li> --> |
| 12 | - <li class="dropdown-box" v-if="role != 'ROLE_PERSONAL'&&role != 'ROLE_PINGTAI'"> | 12 | + <li |
| 13 | + class="dropdown-box" | ||
| 14 | + v-if="role != 'ROLE_PERSONAL' && role != 'ROLE_PINGTAI'" | ||
| 15 | + > | ||
| 13 | <div class="userInfo"> | 16 | <div class="userInfo"> |
| 14 | <img :src="avatar" /> | 17 | <img :src="avatar" /> |
| 15 | <div class="txt"> | 18 | <div class="txt"> |
| @@ -35,14 +38,18 @@ | @@ -35,14 +38,18 @@ | ||
| 35 | </el-dropdown> | 38 | </el-dropdown> |
| 36 | </li> | 39 | </li> |
| 37 | <li class="dropdown-box" v-if="role == 'ROLE_PINGTAI'"> | 40 | <li class="dropdown-box" v-if="role == 'ROLE_PINGTAI'"> |
| 38 | - <div class="userInfo"> | 41 | + <div class="userInfo"> |
| 39 | <img :src="avatar" /> | 42 | <img :src="avatar" /> |
| 40 | <div class="txt"> | 43 | <div class="txt"> |
| 41 | <p>{{ `${this.$store.getters.info.name}` }}</p> | 44 | <p>{{ `${this.$store.getters.info.name}` }}</p> |
| 42 | </div> | 45 | </div> |
| 43 | </div> | 46 | </div> |
| 44 | </li> | 47 | </li> |
| 45 | - <li class="dropdown-box" v-if="role == 'ROLE_PERSONAL'" @click="linkToUserInfo"> | 48 | + <li |
| 49 | + class="dropdown-box" | ||
| 50 | + v-if="role == 'ROLE_PERSONAL'" | ||
| 51 | + @click="linkToUserInfo" | ||
| 52 | + > | ||
| 46 | <div class="userInfo"> | 53 | <div class="userInfo"> |
| 47 | <img :src="avatar" /> | 54 | <img :src="avatar" /> |
| 48 | <div class="txt"> | 55 | <div class="txt"> |
| @@ -51,6 +58,16 @@ | @@ -51,6 +58,16 @@ | ||
| 51 | </div> | 58 | </div> |
| 52 | </div> | 59 | </div> |
| 53 | </li> | 60 | </li> |
| 61 | + | ||
| 62 | + <li class="fullScreen" v-if="role != 'ROLE_PERSONAL'" @click="openPwd"> | ||
| 63 | + <el-tooltip | ||
| 64 | + class="item" | ||
| 65 | + effect="dark" | ||
| 66 | + content="修改密码" | ||
| 67 | + placement="bottom" | ||
| 68 | + ><i class="el-icon el-icon-key"></i | ||
| 69 | + ></el-tooltip> | ||
| 70 | + </li> | ||
| 54 | <li class="fullScreen" @click="fullScreen"> | 71 | <li class="fullScreen" @click="fullScreen"> |
| 55 | <el-tooltip | 72 | <el-tooltip |
| 56 | class="item" | 73 | class="item" |
| @@ -83,10 +100,53 @@ | @@ -83,10 +100,53 @@ | ||
| 83 | </ul> | 100 | </ul> |
| 84 | </el-header> | 101 | </el-header> |
| 85 | <!-- <tabNav></tabNav> --> | 102 | <!-- <tabNav></tabNav> --> |
| 103 | + <el-dialog title="修改密码" :visible.sync="diaPass" width="400"> | ||
| 104 | + <el-form | ||
| 105 | + v-loading="loading" | ||
| 106 | + ref="formPass" | ||
| 107 | + class="form-box" | ||
| 108 | + :model="password" | ||
| 109 | + :rules="rulesPassword" | ||
| 110 | + label-width="160px" | ||
| 111 | + > | ||
| 112 | + <el-form-item label="旧密码:" prop="oldPassword" | ||
| 113 | + ><el-col :span="10" | ||
| 114 | + ><el-input | ||
| 115 | + maxlength="30" | ||
| 116 | + v-model="password.oldPassword" | ||
| 117 | + placeholder="请输入密码" | ||
| 118 | + show-password | ||
| 119 | + ></el-input></el-col | ||
| 120 | + ></el-form-item> | ||
| 121 | + <el-form-item label="新密码:" prop="password" | ||
| 122 | + ><el-col :span="10" | ||
| 123 | + ><el-input | ||
| 124 | + maxlength="30" | ||
| 125 | + v-model="password.password" | ||
| 126 | + placeholder="请输入新密码" | ||
| 127 | + show-password | ||
| 128 | + ></el-input></el-col | ||
| 129 | + ></el-form-item> | ||
| 130 | + <el-form-item label="确认密码:" prop="resetPassword" | ||
| 131 | + ><el-col :span="10" | ||
| 132 | + ><el-input | ||
| 133 | + maxlength="30" | ||
| 134 | + v-model="password.resetPassword" | ||
| 135 | + placeholder="请输入新密码" | ||
| 136 | + show-password | ||
| 137 | + ></el-input></el-col | ||
| 138 | + ></el-form-item> | ||
| 139 | + </el-form> | ||
| 140 | + <div class="dialog-footer" slot="footer"> | ||
| 141 | + <el-button @click="editPass">确 定</el-button> | ||
| 142 | + <el-button @click="diaPass = false">取 消</el-button> | ||
| 143 | + </div> | ||
| 144 | + </el-dialog> | ||
| 86 | </div> | 145 | </div> |
| 87 | </template> | 146 | </template> |
| 88 | 147 | ||
| 89 | <script> | 148 | <script> |
| 149 | +import { encryptLoginPassword } from "@/utils"; | ||
| 90 | import langSelect from "../../../components/lang/langSelect"; | 150 | import langSelect from "../../../components/lang/langSelect"; |
| 91 | import tabNav from "./tabNav"; | 151 | import tabNav from "./tabNav"; |
| 92 | import _ from "lodash"; | 152 | import _ from "lodash"; |
| @@ -100,6 +160,7 @@ export default { | @@ -100,6 +160,7 @@ export default { | ||
| 100 | }, | 160 | }, |
| 101 | data() { | 161 | data() { |
| 102 | return { | 162 | return { |
| 163 | + loading: false, | ||
| 103 | code: "", | 164 | code: "", |
| 104 | role: "", | 165 | role: "", |
| 105 | isfullScreen: true, | 166 | isfullScreen: true, |
| @@ -109,11 +170,30 @@ export default { | @@ -109,11 +170,30 @@ export default { | ||
| 109 | title: "", | 170 | title: "", |
| 110 | userId: "", | 171 | userId: "", |
| 111 | isCollapse: false, | 172 | isCollapse: false, |
| 173 | + diaPass: false, | ||
| 174 | + password: { | ||
| 175 | + oldPassword: "", | ||
| 176 | + password: "", | ||
| 177 | + resetPassword: "", | ||
| 178 | + }, | ||
| 179 | + rulesPassword: { | ||
| 180 | + oldPassword: [ | ||
| 181 | + { required: true, message: "请输入旧密码", trigger: "blur" }, | ||
| 182 | + ], | ||
| 183 | + password: [ | ||
| 184 | + { required: true, message: "请输入新密码", trigger: "blur" }, | ||
| 185 | + ], | ||
| 186 | + resetPassword: [ | ||
| 187 | + { required: true, message: "请输入新密码", trigger: "blur" }, | ||
| 188 | + ], | ||
| 189 | + }, | ||
| 112 | }; | 190 | }; |
| 113 | }, | 191 | }, |
| 114 | created() { | 192 | created() { |
| 115 | this.code = localStorage.getItem("csCode") || ""; | 193 | this.code = localStorage.getItem("csCode") || ""; |
| 116 | - this.role = this.$store.getters.info.showRole || this.$store.getters.info.permissions[0].role; | 194 | + this.role = |
| 195 | + this.$store.getters.info.showRole || | ||
| 196 | + this.$store.getters.info.permissions[0].role; | ||
| 117 | this.isCollapse = this.$store.getters.isCollapse; | 197 | this.isCollapse = this.$store.getters.isCollapse; |
| 118 | }, | 198 | }, |
| 119 | methods: { | 199 | methods: { |
| @@ -129,10 +209,51 @@ export default { | @@ -129,10 +209,51 @@ export default { | ||
| 129 | 2000, | 209 | 2000, |
| 130 | { leading: true, trailing: false } | 210 | { leading: true, trailing: false } |
| 131 | ), | 211 | ), |
| 212 | + openPwd() { | ||
| 213 | + this.password.password = ""; | ||
| 214 | + this.password.oldPassword = ""; | ||
| 215 | + this.password.resetPassword = ""; | ||
| 216 | + this.diaPass = true; | ||
| 217 | + }, | ||
| 218 | + editPass() { | ||
| 219 | + if (this.loading) { | ||
| 220 | + return; | ||
| 221 | + } | ||
| 222 | + this.$refs.formPass.validate(async (valid) => { | ||
| 223 | + if (valid) { | ||
| 224 | + if (this.password.password != this.password.resetPassword) { | ||
| 225 | + this.$message.warning("两次输入密码不一致请检查!"); | ||
| 226 | + return; | ||
| 227 | + } | ||
| 228 | + this.loading = true; | ||
| 229 | + const { data, status, info } = await this.$request.changePwd({ | ||
| 230 | + oldPassword: encryptLoginPassword(this.password.oldPassword), | ||
| 231 | + password: encryptLoginPassword(this.password.password), | ||
| 232 | + }); | ||
| 233 | + this.loading = false; | ||
| 234 | + if (status === 0) { | ||
| 235 | + this.$message.success("密码修改成功~"); | ||
| 236 | + this.diaPass = false; | ||
| 237 | + const res = await this.$request.logout(); | ||
| 238 | + this.$store.commit("setToken", ""); | ||
| 239 | + this.$store.commit("setInfo", {}); | ||
| 240 | + this.$store.commit("setRouters", []); | ||
| 241 | + this.$store.commit("resetTabnavBox"); | ||
| 242 | + this.$router.push({ | ||
| 243 | + path: "/login", | ||
| 244 | + }); | ||
| 245 | + } else { | ||
| 246 | + this.$message.error(info); | ||
| 247 | + } | ||
| 248 | + } else { | ||
| 249 | + this.$message.error("数据有误,请检查!"); | ||
| 250 | + } | ||
| 251 | + }); | ||
| 252 | + }, | ||
| 132 | linkToUserInfo() { | 253 | linkToUserInfo() { |
| 133 | this.$router.push({ | 254 | this.$router.push({ |
| 134 | - path:'/userInfo' | ||
| 135 | - }) | 255 | + path: "/userInfo", |
| 256 | + }); | ||
| 136 | }, | 257 | }, |
| 137 | collapse() { | 258 | collapse() { |
| 138 | this.isCollapse = !this.isCollapse; | 259 | this.isCollapse = !this.isCollapse; |
| @@ -180,7 +301,7 @@ export default { | @@ -180,7 +301,7 @@ export default { | ||
| 180 | if (data) { | 301 | if (data) { |
| 181 | window.location.href = data; | 302 | window.location.href = data; |
| 182 | } else { | 303 | } else { |
| 183 | - localStorage.setItem("token","") | 304 | + localStorage.setItem("token", ""); |
| 184 | this.$store.commit("setToken", ""); | 305 | this.$store.commit("setToken", ""); |
| 185 | this.$store.commit("setInfo", {}); | 306 | this.$store.commit("setInfo", {}); |
| 186 | this.$store.commit("setRouters", []); | 307 | this.$store.commit("setRouters", []); |