Browse Source

修改登陆逻辑

wyling007 3 years ago
parent
commit
a02e4d0cbe
1 changed files with 20 additions and 22 deletions
  1. 20 22
      src/route/guard.ts

+ 20 - 22
src/route/guard.ts

@@ -26,29 +26,27 @@ const guard = (router: Router) => {
 		} catch (error) {
 		} catch (error) {
 			//监听到登陆事件
 			//监听到登陆事件
 			if (to.query.state === "LOGIN") {
 			if (to.query.state === "LOGIN") {
-				setTimeout(async () => {
-					const toast = Toast.loading({
-						duration: 0, // 持续展示 toast
-						forbidClick: true,
-						message: "登陆中",
-					});
-					try {
-						await useLogin(to.query);
-						toast.message = `登陆成功`;
-						setTimeout(() => {
-							Toast.clear();
-						}, 500);
-					} catch (error) {
-						toast.message = `登陆失败`;
-						setTimeout(() => {
-							Toast.clear();
-							location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
-						}, 1000);
-					}
-				}, 1000);
+				next();
+				const toast = Toast.loading({
+					duration: 0, // 持续展示 toast
+					forbidClick: true,
+					message: "登陆中",
+				});
+				try {
+					await useLogin(to.query);
+					toast.message = `登陆成功`;
+					setTimeout(() => {
+						Toast.clear();
+					}, 500);
+				} catch (error) {
+					toast.message = `登陆失败`;
+					setTimeout(() => {
+						Toast.clear();
+						location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h5.zzxcx.net/home/test&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+					}, 1000);
+				}
 			} else {
 			} else {
-				// location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=${location.href}&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
-				window.open(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=${location.href}&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
+				location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=${location.href}&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect`);
 			}
 			}
 		}
 		}