|
|
@@ -1,81 +1,84 @@
|
|
|
// import Captcha from '@/components/common/captcha';
|
|
|
|
|
|
export default {
|
|
|
- // components: {
|
|
|
- // Captcha
|
|
|
- // },
|
|
|
+ // components: {
|
|
|
+ // Captcha
|
|
|
+ // },
|
|
|
|
|
|
- data() {
|
|
|
- return {
|
|
|
- form: {
|
|
|
- mobile: '15280215347',
|
|
|
- password: '123456',
|
|
|
- // captchaId: '',
|
|
|
- verifyCode: ''
|
|
|
- },
|
|
|
- saving: false,
|
|
|
- loading: true
|
|
|
- };
|
|
|
- },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ mobile: null,
|
|
|
+ password: null,
|
|
|
+ // captchaId: '',
|
|
|
+ verifyCode: ''
|
|
|
+ },
|
|
|
+ saving: false,
|
|
|
+ loading: true
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.loading = false;
|
|
|
+ if (process.env.NODE_ENV === "development") {
|
|
|
+ this.form.mobile = '15280215347'
|
|
|
+ this.form.password = '123456'
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- mounted() {
|
|
|
- this.loading = false;
|
|
|
- },
|
|
|
+ methods: {
|
|
|
+ captchaChange() {
|
|
|
+ this.form.verifyCode = '';
|
|
|
+ },
|
|
|
|
|
|
- methods: {
|
|
|
- captchaChange() {
|
|
|
- this.form.verifyCode = '';
|
|
|
- },
|
|
|
+ async next() {
|
|
|
+ const {mobile, password} = this.form;
|
|
|
|
|
|
- async next() {
|
|
|
- const { mobile, password } = this.form;
|
|
|
+ if (!mobile) {
|
|
|
+ return this.$message.warning('用户名不能为空');
|
|
|
+ }
|
|
|
|
|
|
- if (!mobile) {
|
|
|
- return this.$message.warning('用户名不能为空');
|
|
|
- }
|
|
|
+ if (!password) {
|
|
|
+ return this.$message.warning('密码不能为空');
|
|
|
+ }
|
|
|
|
|
|
- if (!password) {
|
|
|
- return this.$message.warning('密码不能为空');
|
|
|
- }
|
|
|
+ this.saving = true;
|
|
|
|
|
|
- this.saving = true;
|
|
|
+ try {
|
|
|
+ // 登录
|
|
|
+ await this.$store.dispatch('userLogin', this.form);
|
|
|
|
|
|
- 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');
|
|
|
+ }
|
|
|
|
|
|
- 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');
|
|
|
|
|
|
- // 权限菜单
|
|
|
- const [first] = await this.$store.dispatch('permMenu');
|
|
|
+ this.saving = false;
|
|
|
|
|
|
- this.saving = false;
|
|
|
+ if (!first) {
|
|
|
+ this.$message.error('该账号没有权限');
|
|
|
+ } else {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$projectName == 'business') {
|
|
|
+ this.$router.push('/');
|
|
|
+ } else {
|
|
|
+ this.$router.push('/');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ // this.$refs.captcha.refresh();
|
|
|
+ this.saving = false;
|
|
|
|
|
|
- if (!first) {
|
|
|
- this.$message.error('该账号没有权限');
|
|
|
- } else {
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$projectName == 'business') {
|
|
|
- this.$router.push('/');
|
|
|
- } else {
|
|
|
- this.$router.push('/');
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- // this.$refs.captcha.refresh();
|
|
|
- this.saving = false;
|
|
|
-
|
|
|
- this.$message.error(err);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ this.$message.error(err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|