|
@@ -2,7 +2,7 @@
|
|
|
<el-dialog
|
|
|
class="reset-pwd"
|
|
|
:visible.sync="modalIsShow"
|
|
|
- :title="title"
|
|
|
+ title="修改密码"
|
|
|
top="10vh"
|
|
|
width="448px"
|
|
|
:close-on-click-modal="false"
|
|
@@ -16,65 +16,30 @@
|
|
|
:rules="resetRules"
|
|
|
label-position="top"
|
|
|
>
|
|
|
- <template v-if="needResetPwd">
|
|
|
- <el-form-item prop="oldPassword" label="旧密码:">
|
|
|
- <el-input
|
|
|
- type="password"
|
|
|
- v-model="modalForm.oldPassword"
|
|
|
- placeholder="请输入旧密码"
|
|
|
- clearable
|
|
|
- ></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="password" label="新密码:">
|
|
|
- <el-input
|
|
|
- type="password"
|
|
|
- v-model="modalForm.password"
|
|
|
- placeholder="请输入新密码"
|
|
|
- clearable
|
|
|
- ></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="rePassword" label="再次密码:">
|
|
|
- <el-input
|
|
|
- type="password"
|
|
|
- v-model="modalForm.rePassword"
|
|
|
- placeholder="请再次输入新密码"
|
|
|
- clearable
|
|
|
- ></el-input>
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
- <template v-if="needBindMobile">
|
|
|
- <el-form-item prop="mobileNumber" label="手机号:">
|
|
|
- <el-input
|
|
|
- v-model.trim="modalForm.mobileNumber"
|
|
|
- placeholder="请输入账号"
|
|
|
- name="mobileNumber"
|
|
|
- clearable
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="code" label="验证码:">
|
|
|
- <div class="vlcode">
|
|
|
- <div class="vlcode-right">
|
|
|
- <el-button
|
|
|
- style="width:100%;"
|
|
|
- type="text"
|
|
|
- @click="fetchSmsCode"
|
|
|
- :disabled="isFetchingCode"
|
|
|
- >+{{ codeContent }}</el-button
|
|
|
- >
|
|
|
- </div>
|
|
|
- <div class="vlcode-left">
|
|
|
- <el-input
|
|
|
- v-model.trim="modalForm.code"
|
|
|
- placeholder="请输入手机验证码"
|
|
|
- name="code"
|
|
|
- clearable
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
+ <el-form-item prop="oldPassword" label="旧密码:">
|
|
|
+ <el-input
|
|
|
+ type="password"
|
|
|
+ v-model="modalForm.oldPassword"
|
|
|
+ placeholder="请输入旧密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="password" label="新密码:">
|
|
|
+ <el-input
|
|
|
+ type="password"
|
|
|
+ v-model="modalForm.password"
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="rePassword" label="再次密码:">
|
|
|
+ <el-input
|
|
|
+ type="password"
|
|
|
+ v-model="modalForm.rePassword"
|
|
|
+ placeholder="请再次输入新密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer">
|
|
|
<el-button type="primary" :disabled="isSubmit" @click="submit"
|
|
@@ -87,18 +52,14 @@
|
|
|
|
|
|
<script>
|
|
|
import { updatePwd } from "../api";
|
|
|
-import { getSmsCodeForBind } from "@/modules/login/api";
|
|
|
-import { password, phone, smscode } from "@/plugins/formRules";
|
|
|
+import { password } from "@/plugins/formRules";
|
|
|
import { Base64 } from "@/plugins/crypto";
|
|
|
-import fetchSmsMixins from "@/modules/login/fetchSmsMixins";
|
|
|
|
|
|
const initModalForm = {
|
|
|
id: "",
|
|
|
oldPassword: "",
|
|
|
password: "",
|
|
|
- rePassword: "",
|
|
|
- mobileNumber: "",
|
|
|
- code: ""
|
|
|
+ rePassword: ""
|
|
|
};
|
|
|
|
|
|
export default {
|
|
@@ -109,16 +70,11 @@ export default {
|
|
|
default() {
|
|
|
return {
|
|
|
userId: "",
|
|
|
- loginName: "",
|
|
|
- schoolCode: "",
|
|
|
- password: "",
|
|
|
- mobileNumber: "",
|
|
|
- pwdCount: ""
|
|
|
+ password: ""
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- mixins: [fetchSmsMixins],
|
|
|
data() {
|
|
|
const equalToOldPswd = (rule, value, callback) => {
|
|
|
if (value === this.modalForm.oldPassword) {
|
|
@@ -141,8 +97,6 @@ export default {
|
|
|
isFetchingCode: false,
|
|
|
modalForm: { ...initModalForm },
|
|
|
resetRules: {
|
|
|
- code: smscode,
|
|
|
- mobileNumber: phone,
|
|
|
oldPassword: password,
|
|
|
password: [
|
|
|
...password,
|
|
@@ -161,30 +115,14 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
- computed: {
|
|
|
- needBindMobile() {
|
|
|
- return !this.userInfo.mobileNumber;
|
|
|
- },
|
|
|
- needResetPwd() {
|
|
|
- return !this.userInfo.pwdCount;
|
|
|
- },
|
|
|
- title() {
|
|
|
- if (this.needBindMobile && this.needResetPwd)
|
|
|
- return "修改密码与绑定手机号";
|
|
|
- if (this.needBindMobile) return "绑定手机号";
|
|
|
- if (this.needResetPwd) return "修改密码";
|
|
|
-
|
|
|
- return "修改密码";
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
- initData(val) {
|
|
|
+ initData() {
|
|
|
this.modalForm = { ...initModalForm };
|
|
|
this.modalForm.oldPassword = this.userInfo.password || "";
|
|
|
this.modalForm.id = this.userInfo.userId;
|
|
|
},
|
|
|
visibleChange() {
|
|
|
- this.initData(this.instance);
|
|
|
+ this.initData();
|
|
|
},
|
|
|
cancel() {
|
|
|
this.modalIsShow = false;
|
|
@@ -192,44 +130,6 @@ export default {
|
|
|
open() {
|
|
|
this.modalIsShow = true;
|
|
|
},
|
|
|
- checkField(field) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- this.$refs.modalFormComp.validateField(field, unvalid => {
|
|
|
- if (unvalid) {
|
|
|
- reject();
|
|
|
- } else {
|
|
|
- resolve();
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- async fetchSmsCode() {
|
|
|
- // console.log("111");
|
|
|
- let result = true;
|
|
|
- await this.checkField("mobileNumber").catch(() => {
|
|
|
- result = false;
|
|
|
- });
|
|
|
-
|
|
|
- if (!result) return;
|
|
|
-
|
|
|
- this.isFetchingCode = true;
|
|
|
- const data = await getSmsCodeForBind({
|
|
|
- loginName: this.userInfo.loginName,
|
|
|
- schoolCode: this.userInfo.schoolCode,
|
|
|
- password: Base64(this.modalForm.oldPassword),
|
|
|
- mobileNumber: this.modalForm.mobileNumber
|
|
|
- }).catch(() => {
|
|
|
- this.isFetchingCode = false;
|
|
|
- });
|
|
|
- if (!data) return;
|
|
|
-
|
|
|
- this.$message.success(
|
|
|
- `已向手机尾号【${this.modalForm.mobileNumber.slice(
|
|
|
- -4
|
|
|
- )}】成功发送短信,请在2分钟内进行验证!`
|
|
|
- );
|
|
|
- this.changeContent();
|
|
|
- },
|
|
|
async submit() {
|
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
if (!valid) return;
|
|
@@ -238,28 +138,15 @@ export default {
|
|
|
this.isSubmit = true;
|
|
|
let datas = {
|
|
|
id: this.modalForm.id,
|
|
|
- oldPassword: Base64(this.modalForm.oldPassword)
|
|
|
+ oldPassword: Base64(this.modalForm.oldPassword),
|
|
|
+ password: Base64(this.modalForm.password)
|
|
|
};
|
|
|
- if (this.needBindMobile) {
|
|
|
- datas = {
|
|
|
- ...datas,
|
|
|
- mobileNumber: this.modalForm.mobileNumber,
|
|
|
- verifyCode: this.modalForm.code
|
|
|
- };
|
|
|
- }
|
|
|
- if (this.needResetPwd) {
|
|
|
- datas = {
|
|
|
- ...datas,
|
|
|
- password: Base64(this.modalForm.password)
|
|
|
- };
|
|
|
- }
|
|
|
- const data = await updatePwd(datas).catch(() => {
|
|
|
- this.isSubmit = false;
|
|
|
- });
|
|
|
+
|
|
|
+ const data = await updatePwd(datas).catch(() => {});
|
|
|
+ this.isSubmit = false;
|
|
|
|
|
|
if (!data) return;
|
|
|
|
|
|
- this.isSubmit = false;
|
|
|
this.$message.success("修改成功!");
|
|
|
this.$emit("modified", data);
|
|
|
this.cancel();
|