login.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: mapSite } = createNamespacedHelpers('site');
  10. const { mapActions: mapMarket } = createNamespacedHelpers('market');
  11. const { mapActions: login } = createNamespacedHelpers('login');
  12. export default {
  13. name: 'login',
  14. props: {},
  15. components: { loginDetail },
  16. data: () => {
  17. return {
  18. info: {},
  19. form: {},
  20. forms: {},
  21. };
  22. },
  23. created() {
  24. this.searchSite();
  25. },
  26. methods: {
  27. ...mapSite(['showInfo', 'toGetUser']),
  28. ...mapMarket({ userFetch: 'fetch', userCreate: 'create', userUpdate: 'update' }),
  29. ...login({ toLogin: 'login' }),
  30. // 查询站点信息
  31. async searchSite() {
  32. let res = await this.showInfo();
  33. let object = JSON.parse(JSON.stringify(res.data));
  34. if (object) {
  35. this.$set(this, `info`, res.data);
  36. } else {
  37. this.$message.error(res.errmsg ? res.errmsg : 'error');
  38. }
  39. },
  40. async submitLogin(form) {
  41. const res = await this.toLogin({ user: form });
  42. console.log(res);
  43. if (res.uid) {
  44. if (res.role == 1 || res.role == 4) window.location.href = 'http://free.liaoningdoupo.com/platadmin';
  45. else window.location.href = 'http://free.liaoningdoupo.com/platlive/home.html';
  46. }
  47. },
  48. async submitRegister(forms) {
  49. let data = this.forms;
  50. let res = await this.userCreate(data);
  51. let msg = `注册成功`;
  52. this.$checkRes(res, msg);
  53. },
  54. },
  55. computed: {
  56. ...mapState(['user']),
  57. pageTitle() {
  58. return `${this.$route.meta.title}`;
  59. },
  60. redirect_uri() {
  61. return `${this.$route.query.redirect_uri}`;
  62. },
  63. },
  64. metaInfo() {
  65. return { title: this.$route.meta.title };
  66. },
  67. };
  68. </script>
  69. <style lang="less" scoped></style>