index.js 1.5 KB

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