| | |
| | | import { useUserStore } from '@/stores/modules/user'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { object2query } from '@life-payment/utils'; |
| | | import * as userServices from '@life-payment/services/api/User'; |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | import { MaybeRef } from 'vue'; |
| | | import { useRefeshDidShow } from './infiniteLoading'; |
| | |
| | | return userStore.getCurrentUserInfo(); |
| | | } |
| | | |
| | | const isChannelAccount = computed(() => !!virtualUserId.value && true); |
| | | |
| | | return { |
| | | user: userInfo, |
| | | userDetail: userDetail, |
| | |
| | | virtualPhoneNumber, |
| | | wxCode, |
| | | wxOpenId, |
| | | isChannelAccount, |
| | | }; |
| | | } |
| | | |
| | |
| | | // userStore.getCurrentUserInfo(); |
| | | } |
| | | if (needAuth && !isLogin.value) { |
| | | Taro.navigateTo({ |
| | | RouteHelper.navigateTo({ |
| | | url: `${RouterPath.loginByForm}?redirect=${router.path}&${object2query(router.params)}`, |
| | | }); |
| | | } |
| | |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const { getLifePayWxIndentity } = useLifePayWxIndentity(); |
| | | |
| | | Taro.useReady(async () => { |
| | | try { |
| | | //@ts-ignore |
| | |
| | | } |
| | | if (!!code && !wxCode.value) { |
| | | userStore.setWxCode(router.params.code ?? ''); |
| | | let res = await getLifePayWxIndentity(); |
| | | userStore.setWxOpenId(res.openId); |
| | | // getLifePayWxIndentity(code); |
| | | } |
| | | } catch (error) {} |
| | | }); |
| | | } |
| | | |
| | | async function getLifePayWxIndentity() { |
| | | export function useLifePayWxIndentity() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | const userStore = useUserStore(); |
| | | |
| | | async function getLifePayWxIndentity(code: string) { |
| | | try { |
| | | let params: APIgetLifePayWxIndentityParams = { |
| | | code: code, |
| | |
| | | let res = await blLifeRecharge.services.getLifePayWxIndentity(params, { |
| | | showLoading: false, |
| | | }); |
| | | if (res.openId) { |
| | | userStore.setWxOpenId(res.openId); |
| | | } |
| | | return res; |
| | | } catch (error) {} |
| | | } |
| | | |
| | | return { getLifePayWxIndentity }; |
| | | } |
| | | |
| | | export function useEnsureOpenId() { |
| | | const { wxCode, wxOpenId } = useUser(); |
| | | const { getLifePayWxIndentity } = useLifePayWxIndentity(); |
| | | |
| | | async function ensureOpenId() { |
| | | if (wxOpenId.value) { |
| | | return wxOpenId.value; |
| | | } else { |
| | | let rea = await getLifePayWxIndentity(wxCode.value); |
| | | return rea.openId ? rea.openId : wxOpenId.value; |
| | | } |
| | | } |
| | | |
| | | return { ensureOpenId }; |
| | | } |
| | | |
| | | export function useGoLogin() { |
| | | 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}`, |
| | | }); |
| | | } |