wupengfei
2025-02-25 7160c12ee6c5eb9ffbce1caea864110f3585c0e1
apps/taro/src/hooks/user.ts
@@ -8,6 +8,7 @@
import { LoginFormTabs } from '@/subpackages/login/constants';
import { useLoginedJump } from './login';
import { useLifeRechargeContext, APIgetLifePayWxIndentityParams } from '@life-payment/core-vue';
import { isInWeChat } from '@/utils/env';
export function useUser() {
  const userStore = useUserStore();
@@ -57,6 +58,8 @@
  const isAuth = computed(() => !needAuth || isLogin.value);
  const router = Taro.useRouter();
  console.log('222', 222);
  useInitWeixinJSBridge();
  Taro.useReady(async () => {
    if (isLogin.value && userStore.firstGetUserDetail) {
@@ -83,16 +86,18 @@
  const { blLifeRecharge } = useLifeRechargeContext();
  Taro.useReady(async () => {
    if (!code && !!WeixinJSBridge && !wxCode) {
    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 && !wxCode) {
      try {
      if (!!code && !wxCode.value) {
        userStore.setWxCode(router.params.code ?? '');
        let res = await getLifePayWxIndentity();
        userStore.setWxOpenId(res.openId);
      } catch (error) {}
    }
    } catch (error) {}
  });
    async function getLifePayWxIndentity() {
      try {
@@ -105,7 +110,6 @@
        return res;
      } catch (error) {}
    }
  });
}
export function useGoLogin() {