This commit is contained in:
lesion
2019-05-30 12:04:14 +02:00
parent 69792b518e
commit 6099d538c0
47 changed files with 1220 additions and 998 deletions

View File

@@ -1,15 +1,21 @@
<template lang='pug'>
b-modal(@shown="$refs.email.focus()" :title='$t("common.login")' hide-footer
@hidden='$router.replace("/")' :visible='true' ref='modal')
el-dialog(:title='$t("common.login")' :before-close='close' visible)
el-form(v-loading='loading')
p(v-html="$t('login.description')")
el-input.mb-2(v-model='email' type='email' :placeholder='$t("common.email")' autocomplete='email' ref='email')
v-icon(name='user' slot='prepend')
i.el-icon-user(slot='prepend')
el-input.mb-1(v-model='password' @keyup.enter.native="submit" type='password' :placeholder='$t("common.password")')
v-icon(name="lock" slot='prepend')
el-button.mr-1(plain type="success" @click='submit') {{$t('common.login')}}
router-link(to='/register')
i.el-icon-lock(slot='prepend')
el-button.mr-1(plain type="success" :disabled='!email || !password' @click='submit') {{$t('common.login')}}
nuxt-link(to='/register')
el-button.mt-1(plain type="primary") {{$t('login.not_registered')}}
a.float-right(href='#' @click='forgot') {{$t('login.forgot_password')}}
</template>
@@ -17,18 +23,22 @@
const Cookie = process.client ? require('js-cookie') : undefined
import { mapActions } from 'vuex'
import { Message } from 'element-ui'
// import api from '@/plugins/api'
import get from 'lodash/get'
export default {
name: 'Login',
data () {
return {
open: true,
password: '',
email: '',
loading: false
}
},
methods: {
close () {
this.$router.replace('/')
},
...mapActions(['login']),
async forgot () {
if (!this.email) {
@@ -37,7 +47,7 @@ export default {
return
}
this.loading = true
// await api.forgotPassword(this.email)
await this.$axios.$post('/user/recover', { email: this.email })
this.loading = false
Message({ message: this.$t('login.check_email'), type: 'success' })
},
@@ -49,12 +59,12 @@ export default {
this.loading = false
Message({ message: this.$t('login.ok'), type: 'success' })
} catch (e) {
Message({ message: this.$t('login.error') + e, type: 'error' })
e = get(e, 'response.data.message', e)
Message({ message: this.$t('login.error') + this.$t(e), type: 'error' })
this.loading = false
return
}
this.email = this.password = ''
this.$refs.modal.hide()
}
}
}