Răsfoiți Sursa

信息补全

panhui 5 ani în urmă
părinte
comite
c79fdcdf8e
3 a modificat fișierele cu 46 adăugiri și 5 ștergeri
  1. 17 1
      src/main/vue/src/router.js
  2. 24 0
      src/main/vue/src/store.js
  3. 5 4
      src/main/vue/src/views/Login.vue

+ 17 - 1
src/main/vue/src/router.js

@@ -417,7 +417,14 @@ router.beforeEach((to, from, next) => {
         store
             .dispatch('getUserInfo')
             .then(() => {
-                next();
+                store
+                    .dispatch('checkOrganization')
+                    .then(() => {
+                        next();
+                    })
+                    .catch(() => {
+                        next('/organizationInfo');
+                    });
             })
             .catch(() => {
                 localStorage.removeItem('token');
@@ -425,6 +432,15 @@ router.beforeEach((to, from, next) => {
             });
     } else if (!to.matched.length) {
         next('/404');
+    } else if (to.path !== '/organizationInfo' && to.path !== '/login') {
+        store
+            .dispatch('checkOrganization')
+            .then(() => {
+                next();
+            })
+            .catch(() => {
+                next('/organizationInfo');
+            });
     } else {
         next();
     }

+ 24 - 0
src/main/vue/src/store.js

@@ -43,12 +43,36 @@ export default new Vuex.Store({
                 .then(res => {
                     if (res) {
                         context.commit('updateOrganization', res.data);
+                    } else {
+                        context.commit('updateOrganization', null);
                     }
                     return Promise.resolve();
                 })
                 .catch(() => {
                     return Promise.reject();
                 });
+        },
+        checkOrganization(context) {
+            console.log(context.state.organization);
+            if (context.state.organization) {
+                if (
+                    context.state.organization.owner &&
+                    context.state.organization.ownerEmail &&
+                    context.state.organization.ownerPhone &&
+                    context.state.organization.privacyPolicy &&
+                    context.state.organization.IDNo &&
+                    context.state.organization.uscc &&
+                    context.state.organization.district &&
+                    context.state.organization.address &&
+                    context.state.organization.businessLicense
+                ) {
+                    return Promise.resolve();
+                } else {
+                    return Promise.reject();
+                }
+            } else {
+                return Promise.resolve();
+            }
         }
     }
 });

+ 5 - 4
src/main/vue/src/views/Login.vue

@@ -231,13 +231,14 @@ export default {
                         })
                         .then(res => {
                             localStorage.setItem('token', res);
-
                             return this.$store.dispatch('getUserInfo');
                         })
                         .then(res => {
-                            this.loading = false;
-                            this.$router.replace({
-                                name: this.$route.params.name || 'dashboard'
+                            this.$nextTick(() => {
+                                this.loading = false;
+                                this.$router.replace({
+                                    name: this.$route.params.name || 'dashboard'
+                                });
                             });
                         })
                         .catch(e => {