index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // import Captcha from '@/components/common/captcha';
  2. export default {
  3. // components: {
  4. // Captcha
  5. // },
  6. data() {
  7. return {
  8. form: {
  9. mobile: null,
  10. password: null,
  11. // captchaId: '',
  12. verifyCode: ''
  13. },
  14. saving: false,
  15. loading: true
  16. };
  17. },
  18. mounted() {
  19. this.loading = false;
  20. if (process.env.NODE_ENV === 'development') {
  21. this.form.mobile = '15280215347';
  22. this.form.password = '123456';
  23. }
  24. },
  25. methods: {
  26. captchaChange() {
  27. this.form.verifyCode = '';
  28. },
  29. async next() {
  30. const { mobile, password } = this.form;
  31. if (!mobile) {
  32. return this.$message.warning('用户名不能为空');
  33. }
  34. if (!password) {
  35. return this.$message.warning('密码不能为空');
  36. }
  37. this.saving = true;
  38. try {
  39. // 登录
  40. await this.$store.dispatch('userLogin', this.form);
  41. if (this.$projectName == 'business') {
  42. // 用户信息
  43. await this.$store.dispatch('userInfo');
  44. // 商户信息
  45. await this.$store.dispatch('shopInfo');
  46. } else {
  47. // 后台信息
  48. await this.$store.dispatch('adminInfo');
  49. }
  50. // 权限菜单
  51. const [first] = await this.$store.dispatch('permMenu');
  52. this.saving = false;
  53. if (!first) {
  54. this.$message.error('该账号没有权限');
  55. } else {
  56. this.$nextTick(() => {
  57. if (this.$projectName == 'business') {
  58. this.$router.push('/');
  59. } else {
  60. this.$router.push('/');
  61. }
  62. });
  63. }
  64. } catch (err) {
  65. // this.$refs.captcha.refresh();
  66. this.saving = false;
  67. }
  68. }
  69. }
  70. };