4040 </el-form-item >
4141 </el-form >
4242 <el-footer class =" login__footer" >
43- <p class = " author__info " >Copyright & copy ; {{currentYear}}</ p >
43+ <page-footer / >
4444 </el-footer >
4545 </section >
4646</template >
4747
4848<script >
49+ import PageFooter from ' COMPONENTS/PageFooter'
4950import rules from ' ./rules'
5051
5152export default {
@@ -60,24 +61,28 @@ export default {
6061 }
6162 },
6263
63- computed: {
64- currentYear () {
65- return new Date ().getFullYear ()
66- }
67- },
68-
6964 methods: {
7065 onSubmit () {
71- this .toggleLoading (true )
72- this .$refs .login .validate (isValid => {
73- if (! isValid) return
66+ this .switchLoading (true )
67+ this .$refs .login .validate ()
68+ .then (valid => ({
69+ ... this .userInfo ,
70+ vm: this
71+ }))
7472 // This action has included routes replacement
75- this .$store .dispatch (' login/userLogin' , { ... this .userInfo , vm: this })
76- })
73+ // dispatch() will return a Promise instance
74+ .then (payload => this .$store .dispatch (' login/userLogin' , payload))
75+ .then (() => this .$router .replace (' /' ))
76+ .catch (e => console .error (' [Login form]: validate failed !' ))
77+ .finally (() => this .switchLoading (false ))
7778 },
78- toggleLoading (state ) {
79+ switchLoading (state ) {
7980 this .isLoading = state
8081 }
82+ },
83+
84+ components: {
85+ PageFooter
8186 }
8287}
8388 </script >
@@ -88,9 +93,9 @@ export default {
8893}
8994
9095.login {
91- background-image : url (' ~ASSETS /animation.gif' );
96+ background-image : url (' ~./img /animation.gif' );
9297 background-repeat : no-repeat ;
93- background-position : center bottom ;
98+ background-position : center center ;
9499
95100 & __form {
96101 display : flex ;
0 commit comments