| | |
| | | import { useRefeshDidShow } from './infiniteLoading'; |
| | | import { LoginFormTabs } from '@/subpackages/login/constants'; |
| | | import { useLoginedJump } from './login'; |
| | | import { useLifeRechargeContext, APIgetLifePayWxIndentityParams } from '@life-payment/core-vue'; |
| | | import { |
| | | useLifeRechargeContext, |
| | | APIgetLifePayWxIndentityParams, |
| | | WxMiniAppIndentityInfo, |
| | | } from '@life-payment/core-vue'; |
| | | import { isInWeChat } from '@/utils/env'; |
| | | |
| | | export function useUser() { |
| | |
| | | }); |
| | | } |
| | | |
| | | let wxIndentityPromise: Promise<WxMiniAppIndentityInfo>; |
| | | |
| | | export function useLifePayWxIndentity() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | const userStore = useUserStore(); |
| | |
| | | let params: APIgetLifePayWxIndentityParams = { |
| | | code: code, |
| | | }; |
| | | let res = await blLifeRecharge.services.getLifePayWxIndentity(params, { |
| | | showLoading: false, |
| | | }); |
| | | userStore.setWxOpenId(res.openId); |
| | | if (!wxIndentityPromise) { |
| | | wxIndentityPromise = blLifeRecharge.services |
| | | .getLifePayWxIndentity(params, { |
| | | showLoading: false, |
| | | }) |
| | | .finally(() => { |
| | | wxIndentityPromise = undefined; |
| | | }); |
| | | } |
| | | |
| | | let res = await wxIndentityPromise; |
| | | if (res.openId) { |
| | | userStore.setWxOpenId(res.openId); |
| | | } |
| | | return res; |
| | | } catch (error) {} |
| | | } |
| | |
| | | const { getLifePayWxIndentity } = useLifePayWxIndentity(); |
| | | |
| | | async function ensureOpenId() { |
| | | if (wxOpenId) { |
| | | if (wxOpenId.value) { |
| | | return wxOpenId.value; |
| | | } else { |
| | | let rea = await getLifePayWxIndentity(wxCode.value); |
| | | return rea.openId; |
| | | return rea.openId ? rea.openId : wxOpenId.value; |
| | | } |
| | | } |
| | | |