zhengyiming
2025-03-13 9c680ea2c5938d26065232d3a658a9a615e1f827
apps/taro/src/hooks/user.ts
@@ -58,7 +58,6 @@
  const isAuth = computed(() => !needAuth || isLogin.value);
  const router = Taro.useRouter();
  console.log('222', 222);
  useInitWeixinJSBridge();
  Taro.useReady(async () => {
@@ -66,7 +65,7 @@
      // userStore.getCurrentUserInfo();
    }
    if (needAuth && !isLogin.value) {
      Taro.navigateTo({
      RouteHelper.navigateTo({
        url: `${RouterPath.loginByForm}?redirect=${router.path}&${object2query(router.params)}`,
      });
    }
@@ -88,8 +87,10 @@
  Taro.useReady(async () => {
    try {
      //@ts-ignore
      if (!code && isInWeChat && !wxCode.value) {
        location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf940ff1d35a98493&redirect_uri=${location.href}&response_type=code&scope=snsapi_base#wechat_redirect`;
      if (!code && isInWeChat && !wxCode.value && location?.replace) {
        location.replace(
          `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf940ff1d35a98493&redirect_uri=${location.href}&response_type=code&scope=snsapi_base#wechat_redirect`
        );
      }
      if (!!code && !wxCode.value) {
        userStore.setWxCode(router.params.code ?? '');
@@ -116,11 +117,11 @@
  const router = Taro.useRouter();
  const { redirectParams } = useLoginedJump();
  function goLoginFn() {
    // Taro.navigateTo({
    // RouteHelper.navigateTo({
    //   url: `${RouterPath.authorization}?redirect=${router.path}&${object2query(router.params)}`,
    // });
    Taro.navigateTo({
    RouteHelper.navigateTo({
      url: `${RouterPath.loginByForm}?redirect=${redirectParams.value}&tab=${LoginFormTabs.VerificationCodeLogin}`,
    });
  }