|
@@ -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 => {
|