|
|
@ -1,16 +1,17 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<el-form ref="form" :model="form" label-width="80px"> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
|
|
<el-form-item :label="$t('account.form.user')"> |
|
|
|
<el-form-item :label="$t('account.form.user')" prop="user"> |
|
|
|
<el-input v-model="form.user" :placeholder="$t('input_please',{keyword:$t('account.form.user')})"></el-input> |
|
|
|
<el-input v-model="form.user" :placeholder="$t('input_please',{keyword:$t('account.form.user')})"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('account.form.password')"> |
|
|
|
<el-form-item :label="$t('account.form.password')" prop="password"> |
|
|
|
<el-input v-model="form.password" type="password" :placeholder="$t('input_please',{keyword:$t('account.form.password')})"></el-input> |
|
|
|
<el-input v-model="form.password" type="password" :placeholder="$t('input_please',{keyword:$t('account.form.password')})"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('account.form.confirmPwd')"> |
|
|
|
<el-form-item class="is-required" :label="$t('account.form.confirmPwd')" prop="confirmPwd"> |
|
|
|
<el-input v-model="form.confirmPwd" type="password" :placeholder="$t('input_confirm',{keyword:$t('account.form.password')})"></el-input> |
|
|
|
<el-input v-model="form.confirmPwd" type="password" :placeholder="$t('input_confirm',{keyword:$t('account.form.password')})"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" @click="onRegister(form.user,form.password)">{{$t('account.register')}}</el-button> |
|
|
|
<el-button type="primary" @click="submit">{{$t('account.register')}}</el-button> |
|
|
|
|
|
|
|
<el-button @click="$refs.form.resetFields()">{{$t('reset')}}</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -22,16 +23,67 @@ |
|
|
|
export default Vue.extend({ |
|
|
|
export default Vue.extend({ |
|
|
|
name: 'register', |
|
|
|
name: 'register', |
|
|
|
data(){ |
|
|
|
data(){ |
|
|
|
|
|
|
|
let that=this |
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
//注册表单 |
|
|
|
form:{ |
|
|
|
form:{ |
|
|
|
user:'', |
|
|
|
user:'', |
|
|
|
password:'', |
|
|
|
password:'', |
|
|
|
confirmPwd:'' |
|
|
|
confirmPwd:'' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 表单校验规则 |
|
|
|
|
|
|
|
rules:{ |
|
|
|
|
|
|
|
user:[{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
message: this.$t('input_please', { keyword: this.$t('account.form.user') }), |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
password:[{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
message: this.$t('input_please', { keyword: this.$t('account.form.password') }) |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
confirmPwd:[{ |
|
|
|
|
|
|
|
validator:(rule, value, callback) => { |
|
|
|
|
|
|
|
if (value === '') { |
|
|
|
|
|
|
|
callback(new Error(rule.msg.a)); |
|
|
|
|
|
|
|
} else if (value !== that.form.password) { |
|
|
|
|
|
|
|
callback(new Error(rule.msg.b)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
callback(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
msg:{ |
|
|
|
|
|
|
|
a:this.$t('input_confirm', { keyword: this.$t('account.form.password') }), |
|
|
|
|
|
|
|
b:this.$t('account.form.tip.tow_diff') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
props:{ |
|
|
|
methods:{ |
|
|
|
onRegister:Function |
|
|
|
submit(){ |
|
|
|
|
|
|
|
this.$refs.form.validate((valid: boolean)=>{ |
|
|
|
|
|
|
|
if(valid){ |
|
|
|
|
|
|
|
let that=this |
|
|
|
|
|
|
|
this.GLOBAL.postJSON('/v1/api/users/sign_up',{ userName: this.form.user, password: this.form.password },function(res) { |
|
|
|
|
|
|
|
if(res.code==='200'){ |
|
|
|
|
|
|
|
that.$message.info(that.$t('account.form.tip.register_ok').toString()) |
|
|
|
|
|
|
|
that.$router.push(that.localePath('/')) |
|
|
|
|
|
|
|
}else if(res.code==='1101'){ |
|
|
|
|
|
|
|
that.$message.error(that.$t('account.form.tip.user_exit',{name:that.form.user}).toString()) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
that.$message.error(that.$t('error_500').toString()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
this.$message.error({ |
|
|
|
|
|
|
|
message:this.$t('form_err').toString(), |
|
|
|
|
|
|
|
duration:2000 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|