忘记密码国际化换行
continuous-integration/drone/push Build is passing Details

uat_us
DESKTOP-6C3NK6N\WXS 2024-09-18 11:04:07 +08:00
parent 904a764ea5
commit c25183073a
1 changed files with 91 additions and 92 deletions

View File

@ -61,7 +61,7 @@
:disabled="form.VerificationCode === '' || form.EmailOrPhone === ''"
@click="verifyCode"
>
{{ $t("passwordReset:button:verify") }}
{{ $t('passwordReset:button:verify') }}
</el-button>
</div>
<div class="box-wrapper" v-if="active === 1">
@ -69,7 +69,7 @@
ref="resetForm"
v-loading="formLoading"
:model="form"
label-width="100px"
:label-width="$i18n.locale === 'en' ? '180px' : '100px'"
:rules="rules"
class="demo-ruleForm"
size="small"
@ -131,7 +131,7 @@
<div style="width: 50%; margin: auto; display: flex">
<!-- 取消 -->
<el-button size="small" @click="onCancel" style="width: 46%">
{{ $t("passwordReset:button:cancel") }}
{{ $t('passwordReset:button:cancel') }}
</el-button>
<!-- 提交 -->
<el-button
@ -140,17 +140,17 @@
@click="onSubmit"
style="width: 46%"
>
{{ $t("passwordReset:button:submit") }}
{{ $t('passwordReset:button:submit') }}
</el-button>
</div>
</div>
<div class="box-wrapper flexBox" v-if="active === 3">
<svg-icon icon-class="resetSuccess" style="width: 300px; height: 300px" />
<p style="width: 100%; text-align: center">
{{ $t("resetPassword:successTip") }}
{{ $t('resetPassword:successTip') }}
</p>
<el-button size="small" type="primary" @click="goBack">
{{ $t("passwordReset:button:back") }}
{{ $t('passwordReset:button:back') }}
</el-button>
</div>
</div>
@ -160,32 +160,30 @@ import {
anonymousSendVerificationCode,
verifyAnonymousVerifyCode,
anonymousSetPassword,
} from "@/api/user";
import md5 from "js-md5";
import Img from "@/assets/icons/svg/resetSuccess.svg";
var timer = "";
var countdown = 60;
} from '@/api/user'
import md5 from 'js-md5'
import Img from '@/assets/icons/svg/resetSuccess.svg'
var timer = ''
var countdown = 60
export default {
data() {
var validateEmail = (rule, value, callback) => {
if (value === "") {
if (value === '') {
//
callback(new Error(this.$t("passwordReset:formRule:email")));
callback(new Error(this.$t('passwordReset:formRule:email')))
} else {
var reg =
/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/;
/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/
if (this.form.EmailOrPhone && reg.test(this.form.EmailOrPhone)) {
this.sendDisabled = false;
callback();
this.sendDisabled = false
callback()
} else {
//
callback(
new Error(this.$t("passwordReset:formRule:passwordinvalid"))
);
this.sendDisabled = true;
callback(new Error(this.$t('passwordReset:formRule:passwordinvalid')))
this.sendDisabled = true
}
}
};
}
// var validatePass = (rule, value, callback) => {
// if (value === '') {
// //
@ -198,181 +196,182 @@ export default {
// }
// }
var validatePass2 = (rule, value, callback) => {
if (value === "" || value === undefined) {
if (value === '' || value === undefined) {
//
callback(new Error(this.$t("passwordReset:formRule:confirmPassword")));
callback(new Error(this.$t('passwordReset:formRule:confirmPassword')))
} else if (value !== undefined && value !== this.form.NewPwd) {
//
callback(new Error(this.$t("passwordReset:formRule:passwordsDiffer")));
callback(new Error(this.$t('passwordReset:formRule:passwordsDiffer')))
} else {
callback();
callback()
}
};
}
return {
active: 0,
active: 1,
Img,
form: {
EmailOrPhone: "",
VerificationCode: "",
NewPwd: "",
UserId: "",
UserType: "",
EmailOrPhone: '',
VerificationCode: '',
NewPwd: '',
UserId: '',
UserType: '',
},
users: [],
CheckPass: "",
CheckPass: '',
rules: {
EmailOrPhone: [
{
required: true,
validator: validateEmail,
trigger: ["blur", "change"],
trigger: ['blur', 'change'],
},
],
VerificationCode: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: ["blur", "change"],
message: this.$t('common:ruleMessage:specify'),
trigger: ['blur', 'change'],
},
],
NewPwd: [
{
required: true,
validator: this.$validatePassword,
trigger: ["blur", "change"],
trigger: ['blur', 'change'],
},
],
CheckPass: [
{
required: true,
validator: validatePass2,
trigger: ["blur", "change"],
trigger: ['blur', 'change'],
},
],
UserId: [
{
required: true,
message: this.$t("common:ruleMessage:select"),
trigger: ["blur", "change"],
message: this.$t('common:ruleMessage:select'),
trigger: ['blur', 'change'],
},
],
},
sendDisabled: true,
sendTitle: this.$t("passwordReset:button:send"),
sendTitle: this.$t('passwordReset:button:send'),
formLoading: false,
};
}
},
methods: {
onSubmit() {
this.$refs["resetForm"].validate((valid) => {
this.$refs['resetForm'].validate((valid) => {
if (valid) {
this.formLoading = true;
this.formLoading = true
anonymousSetPassword(this.form.UserId, md5(this.form.NewPwd))
.then((res) => {
if (res.IsSuccess) {
//
this.$message.success(
this.$t("passwordReset:message:updatedSuccessfully")
);
this.formLoading = false;
this.active = 3;
this.$t('passwordReset:message:updatedSuccessfully')
)
this.formLoading = false
this.active = 3
// this.goBack();
} else {
this.$alert(res.ErrorMessage);
this.$alert(res.ErrorMessage)
}
})
.catch(() => {
this.formLoading = false;
});
this.formLoading = false
})
}
});
})
},
handleSendCode() {
const that = this;
this.sendDisabled = true;
const that = this
this.sendDisabled = true
// var isReviewer = JSON.parse(zzSessionStorage.getItem('IsReviewer'))
anonymousSendVerificationCode(this.form.EmailOrPhone)
.then((res) => {
if (res.IsSuccess) {
let msg = this.$t('passwordReset:message:tip:sendCode').replace("xxx", this.form.EmailOrPhone)
let msg = this.$t('passwordReset:message:tip:sendCode').replace(
'xxx',
this.form.EmailOrPhone
)
this.$message.success(msg)
that.settime(that);
that.settime(that)
} else {
that.$alert(res.ErrorMessage);
that.$alert(res.ErrorMessage)
}
})
.catch(() => {
this.sendDisabled = false;
});
this.sendDisabled = false
})
},
verifyCode() {
this.formLoading = true;
this.formLoading = true
verifyAnonymousVerifyCode(
this.form.EmailOrPhone,
this.form.VerificationCode
)
.then((res) => {
this.formLoading = false;
this.users = res.Result;
this.formLoading = false
this.users = res.Result
if (this.users.length === 1) {
this.form.UserId = this.users[0].UserId;
this.form.UserType = this.users[0].UserType;
this.form.UserId = this.users[0].UserId
this.form.UserType = this.users[0].UserType
}
//
this.$message.success(
this.$t("passwordReset:message:verifiedSuccessfully")
);
this.active = 1;
this.$t('passwordReset:message:verifiedSuccessfully')
)
this.active = 1
})
.catch(() => {
this.formLoading = false;
});
this.formLoading = false
})
},
handleEmailChange() {
var reg =
/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/;
/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/
if (this.form.EmailOrPhone && reg.test(this.form.EmailOrPhone)) {
this.sendDisabled = false;
this.sendDisabled = false
}
},
handleUserChange(val) {
const seleted = this.users.findIndex((user) => user.UserId === val);
const seleted = this.users.findIndex((user) => user.UserId === val)
if (seleted > -1) {
this.form.UserType = this.users[seleted].UserType;
this.form.UserType = this.users[seleted].UserType
}
},
settime(obj) {
if (countdown === 0) {
obj.sendDisabled = false;
obj.sendTitle = this.$t("passwordReset:button:send");
countdown = 60;
clearTimeout(timer);
return;
obj.sendDisabled = false
obj.sendTitle = this.$t('passwordReset:button:send')
countdown = 60
clearTimeout(timer)
return
} else {
obj.sendDisabled = true;
obj.sendTitle = `${this.$t(
"passwordReset:button:wait"
)}(${countdown}s)`;
countdown--;
obj.sendDisabled = true
obj.sendTitle = `${this.$t('passwordReset:button:wait')}(${countdown}s)`
countdown--
// eslint-disable-next-line no-self-assign
countdown = countdown;
countdown = countdown
timer = setTimeout(function () {
obj.settime(obj);
}, 1000);
obj.settime(obj)
}, 1000)
}
},
onCancel() {
this.$refs["resetForm"].resetFields();
this.$refs['resetForm'].resetFields()
Object.keys(this.form).forEach((key) => {
this.form[key] = "";
});
this.active = 0;
this.form[key] = ''
})
this.active = 0
},
goBack() {
this.$router.push("/login");
this.$router.push('/login')
},
},
};
}
</script>
<style>
.reset-wrapper {