20261008
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<el-form ref="resetForm" :model="formData" label-width="100px" :rules="rules">
|
||||
<el-form-item label="原密码" prop="oldPassword">
|
||||
<el-input type="password" v-model="formData.oldPassword" clearable
|
||||
placeholder="请输入原密码"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input type="password" v-model="formData.newPassword" clearable
|
||||
placeholder="请输入新密码"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="passwordConfirmation">
|
||||
<el-input type="password" v-model="formData.passwordConfirmation" clearable
|
||||
placeholder="请再次输入新密码"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click.native="submit">确定</el-button>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "pwd",
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
oldPassword: null,
|
||||
newPassword: null,
|
||||
passwordConfirmation: null,
|
||||
},
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{required: true, message: '请输入原密码', trigger: 'blur'},
|
||||
],
|
||||
newPassword: [
|
||||
{required: true, message: '请输入新密码', trigger: 'blur'},
|
||||
{min: 6, max: 16, message: '密码长度在 6 到 16 个字符', trigger: 'blur'},
|
||||
],
|
||||
passwordConfirmation: [
|
||||
{required: true, message: '请再次输入新密码', trigger: 'blur'},
|
||||
{validator: this.checkPassword, trigger: 'blur'},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
if (!this.formData.oldPassword) return this.$message.error('请输入原密码');
|
||||
if (!this.formData.newPassword) return this.$message.error('请输入原密码');
|
||||
if (!this.formData.passwordConfirmation) return this.$message.error('请输入原密码');
|
||||
if (this.formData.newPassword !== this.formData.passwordConfirmation) return this.$message.error('两次输入的密码不一致!');
|
||||
if (this.formData.newPassword === this.formData.oldPassword) return this.$message.error('新密码不能与原密码相同!');
|
||||
if (this.formData.newPassword.length < 6) return this.$message.error('密码长度在 6 到 16 个字符');
|
||||
const reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+$/
|
||||
if (!reg.test(this.formData.newPassword)) {
|
||||
return this.$message({
|
||||
message: '密码必须由数字和字母组成',
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
vk.callFunction({
|
||||
url: 'user/kh/updatePwd',
|
||||
data: this.formData
|
||||
}).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功'
|
||||
})
|
||||
this.$refs.resetForm.resetFields();
|
||||
})
|
||||
},
|
||||
checkPassword(rule, value, callback) {
|
||||
if (value !== this.formData.newPassword) {
|
||||
callback(new Error('两次输入的密码不一致!'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user