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