|
|
|
@ -31,6 +31,7 @@ |
|
|
|
|
export default Vue.extend({ |
|
|
|
|
name: 'security', |
|
|
|
|
data() { |
|
|
|
|
let that = this |
|
|
|
|
return { |
|
|
|
|
form: { |
|
|
|
|
oldpwd: '', |
|
|
|
@ -44,7 +45,7 @@ |
|
|
|
|
message: this.$t('input_please', { keyword: this.$t('center.security.oldpwd') }), |
|
|
|
|
trigger: 'blur' |
|
|
|
|
}, |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password',{min:3,max:5}), trigger: 'blur' } |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password', { min: 3, max: 5 }), trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
newpwd: [ |
|
|
|
|
{ |
|
|
|
@ -52,27 +53,69 @@ |
|
|
|
|
message: this.$t('input_please', { keyword: this.$t('center.security.newpwd') }), |
|
|
|
|
trigger: 'blur' |
|
|
|
|
}, |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password',{min:3,max:5}), trigger: 'blur' } |
|
|
|
|
{ |
|
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
if (value === that.form.oldpwd) { |
|
|
|
|
callback(new Error(rule.msg.b)) |
|
|
|
|
} else { |
|
|
|
|
callback() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
msg: { |
|
|
|
|
b: this.$t('center.security.tip.same_err') |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password', { min: 3, max: 5 }), trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
confirmpwd: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: this.$t('input_confirm', { keyword: this.$t('center.security.newpwd') }), |
|
|
|
|
trigger: 'blur' |
|
|
|
|
}, |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password',{min:3,max:5}), trigger: 'blur' } |
|
|
|
|
{ |
|
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
if (value !== that.form.newpwd) { |
|
|
|
|
callback(new Error(rule.msg.a)) |
|
|
|
|
} else { |
|
|
|
|
callback() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
msg: { |
|
|
|
|
a: this.$t('account.form.tip.tow_diff') |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ min: 3, max: 5, message: this.$t('center.security.rules.password', { min: 3, max: 5 }), trigger: 'blur' } |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
onSubmit() { |
|
|
|
|
this.$refs.form.validate((valid: boolean)=>{ |
|
|
|
|
let that=this |
|
|
|
|
this.$refs.form.validate((valid: boolean) => { |
|
|
|
|
if (valid) { |
|
|
|
|
this.$alert(this.$t('center.security.tip.ok').toString()) |
|
|
|
|
this.GLOBAL.fetchJSON('/v1/api/users/update','PUT',{ |
|
|
|
|
oldpwd:this.form.oldpwd, |
|
|
|
|
newpwd:this.form.newpwd |
|
|
|
|
},function(res) { |
|
|
|
|
if(res.code==='200'){ |
|
|
|
|
that.$message.info(that.$t('center.security.tip.ok').toString()) |
|
|
|
|
that.$cookies.remove(that.GLOBAL.user_key) |
|
|
|
|
that.$router.push(that.localePath('/account')) |
|
|
|
|
}else if(res.msg!==null){ |
|
|
|
|
that.$message.error(res.msg) |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
that.$message.error(that.$t('center.security.tip.fail').toString()) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
console.log('error submit!!'); |
|
|
|
|
return false; |
|
|
|
|
this.$message.error({ |
|
|
|
|
message:this.$t('form_err').toString(), |
|
|
|
|
duration:2000 |
|
|
|
|
}) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|