feat: ✨ 商家端新增redirect登录功能
							parent
							
								
									4389911436
								
							
						
					
					
						commit
						7bc5d67efc
					
				| 
						 | 
					@ -23,6 +23,15 @@ const service = axios.create({
 | 
				
			||||||
  timeout: 10000,
 | 
					  timeout: 10000,
 | 
				
			||||||
  baseURL: baseUrl
 | 
					  baseURL: baseUrl
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const recordCurrentPath = () => {
 | 
				
			||||||
 | 
					   return router.history.current.fullPath
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					// 跳转登录页
 | 
				
			||||||
 | 
					const redirectLogin = () => {
 | 
				
			||||||
 | 
					  router.push({path:'/login',query:{redirect: recordCurrentPath()}});
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
service.interceptors.request.use(
 | 
					service.interceptors.request.use(
 | 
				
			||||||
  config => {
 | 
					  config => {
 | 
				
			||||||
    if (config.method == "get") {
 | 
					    if (config.method == "get") {
 | 
				
			||||||
| 
						 | 
					@ -72,7 +81,7 @@ service.interceptors.response.use(
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            Message.error("未知错误,请重新登录");
 | 
					            Message.error("未知错误,请重新登录");
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          router.push("/login");
 | 
					          redirectLogin();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case 500:
 | 
					      case 500:
 | 
				
			||||||
| 
						 | 
					@ -110,7 +119,7 @@ service.interceptors.response.use(
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            Cookies.set("userInfoSeller", "");
 | 
					            Cookies.set("userInfoSeller", "");
 | 
				
			||||||
            router.push("/login");
 | 
					            redirectLogin();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          isRefreshToken = 0;
 | 
					          isRefreshToken = 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
<template>
 | 
					 <template>
 | 
				
			||||||
  <div class="login" @click="$refs.verify.show = false">
 | 
					  <div class="login" @click="$refs.verify.show = false">
 | 
				
			||||||
    <Row type="flex" @keydown.enter.native="submitLogin">
 | 
					    <Row type="flex" @keydown.enter.native="submitLogin">
 | 
				
			||||||
      <Col style="width: 368px">
 | 
					      <Col style="width: 368px">
 | 
				
			||||||
| 
						 | 
					@ -156,10 +156,14 @@ export default {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          util.initRouter(this);
 | 
					          util.initRouter(this);
 | 
				
			||||||
          this.$store.commit("setAvatarPath", res.result.storeLogo);
 | 
					          this.$store.commit("setAvatarPath", res.result.storeLogo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const redirectRouter = this.$route.query.redirect;
 | 
				
			||||||
          // 加载菜单
 | 
					          // 加载菜单
 | 
				
			||||||
          this.$router.push({
 | 
					          const push = {
 | 
				
			||||||
            name: "home_index",
 | 
					            path: redirectRouter || "/home",
 | 
				
			||||||
          });
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          this.$router.push(push);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          this.loading = false;
 | 
					          this.loading = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue