export default { data() { return { svg: '', form: { mobile: '15280215347', password: '123456', // captchaId: '', verifyCode: '' }, saving: false, loading: true }; }, created() { // this.getCaptcha(); }, mounted() { this.loading = false; }, methods: { // getCaptcha() { // this.form.verifyCode = ''; // this.$service.common // .captcha({ // height: 40, // width: 120 // }) // .then(res => { // this.svg = res.data; // this.form.captchaId = res.captchaId; // }) // .catch(this.$message.error); // }, async next() { const { mobile, password } = this.form; if (!mobile) { return this.$message.warning('用户名不能为空'); } if (!password) { return this.$message.warning('密码不能为空'); } this.saving = true; try { // 登录 await this.$store.dispatch('userLogin', this.form); if (this.$projectName == 'business') { // 用户信息 await this.$store.dispatch('userInfo'); // 商户信息 await this.$store.dispatch('shopInfo'); } else { // 后台信息 await this.$store.dispatch('adminInfo'); } // 权限菜单 const [first] = await this.$store.dispatch('permMenu'); this.saving = false; if (!first) { this.$message.error('该账号没有权限'); } else { this.$nextTick(() => { this.$router.push('/'); }); } } catch (err) { this.$message.error(err); // this.getCaptcha(); this.saving = false; } } } };