login.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div id="login">
  3. <login-detail :info="info" :form="form" @submitDate="submitLogin" :forms="forms" @submitDates="submitRegister"></login-detail>
  4. </div>
  5. </template>
  6. <script>
  7. import loginDetail from '@/layout/login.vue';
  8. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  9. const { mapActions: mapMarket } = createNamespacedHelpers('market');
  10. const { mapActions: login } = createNamespacedHelpers('login');
  11. export default {
  12. name: 'login',
  13. props: {},
  14. components: { loginDetail },
  15. data: () => {
  16. return {
  17. info: {},
  18. form: {},
  19. forms: {},
  20. };
  21. },
  22. created() {},
  23. methods: {
  24. // ...mapSite(['showInfo', 'toGetUser']),
  25. ...mapMarket({ userFetch: 'fetch', userCreate: 'create', userUpdate: 'update' }),
  26. ...login({ toLogin: 'login' }),
  27. async submitLogin(form) {
  28. let res = await this.toLogin({ user: form });
  29. if (res.uid) {
  30. if (res.role == '2' || res.role == '3') this.$router.push('/enterprise/enterprisejb');
  31. else if (res.role == '5') this.$router.push('/hallList/index');
  32. else this.$router.push('/market/index');
  33. }
  34. },
  35. async submitRegister(forms) {
  36. let data = this.forms;
  37. let res = await this.userCreate(data);
  38. let msg = `注册成功`;
  39. this.$checkRes(res, msg);
  40. },
  41. },
  42. computed: {
  43. ...mapState(['user']),
  44. pageTitle() {
  45. return `${this.$route.meta.title}`;
  46. },
  47. redirect_uri() {
  48. return `${this.$route.query.redirect_uri}`;
  49. },
  50. },
  51. metaInfo() {
  52. return { title: this.$route.meta.title };
  53. },
  54. };
  55. </script>
  56. <style lang="less" scoped></style>