2019-04-03 00:25:12 +02:00
|
|
|
<template lang='pug'>
|
|
|
|
|
b-modal(hide-footer @hidden='$router.replace("/")' ref='modal'
|
2019-04-26 23:14:43 +02:00
|
|
|
:title="$t('common.register')" :visible='true' @shown='$refs.email.focus()')
|
2019-04-03 00:25:12 +02:00
|
|
|
el-form
|
2019-04-26 23:14:43 +02:00
|
|
|
p(v-html="$t('register.description')")
|
2019-04-03 00:25:12 +02:00
|
|
|
el-input.mb-2(ref='email' v-model='user.email' type='email'
|
2019-04-26 23:14:43 +02:00
|
|
|
:placeholder='$t("common.email")' autocomplete='email')
|
2019-04-03 00:25:12 +02:00
|
|
|
span(slot='prepend') @
|
2019-04-23 13:45:52 +00:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
el-input.mb-2(v-model='user.password' type="password" placeholder="Password")
|
|
|
|
|
v-icon(name='lock' slot='prepend')
|
|
|
|
|
|
2019-04-26 23:14:43 +02:00
|
|
|
el-input.mb-2(v-model='user.description' type="textarea" rows='3' :placeholder="$t('common.description')")
|
2019-04-03 00:25:12 +02:00
|
|
|
v-icon(name='envelope-open-text')
|
|
|
|
|
|
2019-04-26 23:14:43 +02:00
|
|
|
el-button.float-right(plain type="success" icon='el-icon-arrow-right' @click='register') {{$t('common.send')}}
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-04-05 00:10:19 +02:00
|
|
|
import api from '@/plugins/api'
|
|
|
|
|
import { mapActions } from 'vuex'
|
2019-04-03 00:25:12 +02:00
|
|
|
import { Message } from 'element-ui'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Register',
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
error: {},
|
|
|
|
|
user: { }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions(['login']),
|
|
|
|
|
async register () {
|
|
|
|
|
try {
|
2019-04-26 23:14:43 +02:00
|
|
|
const user = await this.$axios.$post('/user', this.user)
|
|
|
|
|
this.$refs.modal.hide()
|
|
|
|
|
Message({
|
|
|
|
|
message: this.$t(`register.${user.is_admin && 'admin_'}complete`),
|
|
|
|
|
type: 'success'
|
|
|
|
|
})
|
2019-04-03 00:25:12 +02:00
|
|
|
} catch (e) {
|
|
|
|
|
Message({
|
2019-04-26 23:14:43 +02:00
|
|
|
message: this.$t('register.error') + e,
|
2019-04-03 00:25:12 +02:00
|
|
|
type: 'error'
|
|
|
|
|
})
|
|
|
|
|
console.error(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|