Ver Fonte

仓储平台界面点击登录能够调回仓储平台

lichao há 3 anos atrás
pai
commit
7c288ffe2b
3 ficheiros alterados com 21 adições e 3 exclusões
  1. 5 0
      package-lock.json
  2. 1 0
      package.json
  3. 15 3
      src/views/login/index.vue

+ 5 - 0
package-lock.json

@@ -15544,6 +15544,11 @@
       "integrity": "sha1-HuO8mhbsv1EYvjNLsV+cRvgvWCU=",
       "dev": true
     },
+    "vue-ui": {
+      "version": "0.1.3",
+      "resolved": "https://registry.nlark.com/vue-ui/download/vue-ui-0.1.3.tgz",
+      "integrity": "sha1-HSUcBc3NAkjiifr9ipC/BGEvUG4="
+    },
     "vuedraggable": {
       "version": "2.24.3",
       "resolved": "https://registry.nlark.com/vuedraggable/download/vuedraggable-2.24.3.tgz?cache=0&sync_timestamp=1623379001749&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fvuedraggable%2Fdownload%2Fvuedraggable-2.24.3.tgz",

+ 1 - 0
package.json

@@ -21,6 +21,7 @@
     "jsencrypt": "^3.2.0",
     "vue": "^2.5.2",
     "vue-router": "^3.0.1",
+    "vue-ui": "^0.1.3",
     "vuedraggable": "^2.24.3"
   },
   "devDependencies": {

+ 15 - 3
src/views/login/index.vue

@@ -84,7 +84,9 @@ export default {
         code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
       },
       loading: false,
-      redirect: undefined
+      redirect: undefined,
+      // 上个路由地址
+      fromPath: '',
     };
   },
   watch: {
@@ -100,6 +102,13 @@ export default {
     this.getCookie();
     Cookies.remove();
   },
+  beforeRouteEnter(to, from, next) {
+    next(vm => {
+      if (from.name === null || from.name === 'stock') {
+        vm.fromPath = "/stock";
+      }
+    })
+  },
   methods: {
     getCode() {
       request({
@@ -151,8 +160,11 @@ export default {
             }else {
               Cookies.set("username",this.loginForm.username);
               Cookies.set('TokenKey', res.data.token)
-              console.log(Cookies.get());
-              this.$router.push({ path: this.redirect || '/' });
+              if (this.fromPath === '/stock') {
+                this.$router.push({ path: this.redirect || '/stock' });
+              } else {
+                this.$router.push({ path: this.redirect || '/' });
+              }
               this.loading = false;
             }
           }).catch(err => {