| | |
| | | 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, |
| | | }); |
| | | if (!wxIndentityPromise) { |
| | | wxIndentityPromise = blLifeRecharge.services |
| | | .getLifePayWxIndentity(params, { |
| | | showLoading: false, |
| | | }) |
| | | .finally(() => { |
| | | wxIndentityPromise = undefined; |
| | | }); |
| | | } |
| | | |
| | | let res = await wxIndentityPromise; |
| | | if (res.openId) { |
| | | userStore.setWxOpenId(res.openId); |
| | | } |
| | |
| | | isInWeChat?: MaybeRef<boolean>; |
| | | isH5?: MaybeRef<boolean>; |
| | | appId?: MaybeRef<string>; |
| | | getOpenId?: () => Promise<string>; |
| | | getOpenId?: MaybeRef<() => Promise<string>>; |
| | | }; |
| | | |
| | | export function useSelectPayType(options: UseSelectPayTypeOptions = {}) { |
| | |
| | | |
| | | async function getPayOrderForJsAPI(orderNo: string) { |
| | | try { |
| | | const openId = await getOpenId(); |
| | | const _getOpenId = unref(getOpenId); |
| | | const openId = await _getOpenId(); |
| | | let params: GetPayOrderForJsAPIInput = { |
| | | orderNo: orderNo, |
| | | lifePayType: blLifeRecharge.constants.LifePayTypeEnum.WxPay, |
| | |
| | | } |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | getOpenId: props.getOpenId, |
| | | getOpenId: toRef(props, 'getOpenId'), |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | } |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | getOpenId: props.getOpenId, |
| | | getOpenId: toRef(props, 'getOpenId'), |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | }>(); |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | getOpenId: props.getOpenId, |
| | | getOpenId: toRef(props, 'getOpenId'), |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | | getOpenId: props.getOpenId, |
| | | getOpenId: toRef(props, 'getOpenId'), |
| | | }); |
| | | |
| | | const currentOrderNo = ref(''); |