| | |
| | | |
| | | 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, |
| | | }); |
| | | 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) { |
| | | return wxOpenId.value; |
| | | } else { |
| | | let rea = await getLifePayWxIndentity(wxCode.value); |
| | | return rea.openId; |
| | | } |
| | | } |
| | | |
| | | return { ensureOpenId }; |
| | | } |
| | | |
| | | export function useGoLogin() { |
| | |
| | | @goPay="goPay" |
| | | :isDev="isDev" |
| | | @paySuccess="handePaySuccess" |
| | | :openId="wxOpenId" |
| | | :getOpenId="ensureOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isInAlipay="isInAlipay" |
| | | :isH5="isWeb" |
| | |
| | | import { BlLifeRecharge } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env'; |
| | | import { useUser, useFocus } from '@/hooks'; |
| | | import { useUser, useFocus, useEnsureOpenId } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | |
| | | const isDev = process.env.NODE_ENV === 'development'; |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | const { ensureOpenId } = useEnsureOpenId(); |
| | | const { isFocus } = useFocus(); |
| | | |
| | | function goPay(orderNo: string) { |
| | |
| | | @goPay="goPay" |
| | | :isDev="isDev" |
| | | @paySuccess="handePaySuccess" |
| | | :openId="wxOpenId" |
| | | :getOpenId="ensureOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isInAlipay="isInAlipay" |
| | | :isH5="isWeb" |
| | |
| | | import { BlLifeRecharge } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env'; |
| | | import { useUser, useFocus } from '@/hooks'; |
| | | import { useUser, useFocus, useEnsureOpenId } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | |
| | | const isDev = process.env.NODE_ENV === 'development'; |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | const { ensureOpenId } = useEnsureOpenId(); |
| | | const { isFocus } = useFocus(); |
| | | |
| | | function goPay(orderNo: string) { |
| | |
| | | @goPay="goPay" |
| | | :isDev="isDev" |
| | | @paySuccess="handePaySuccess" |
| | | :openId="wxOpenId" |
| | | :getOpenId="ensureOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isInAlipay="isInAlipay" |
| | | :isH5="isWeb" |
| | |
| | | import { BlLifeRecharge } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env'; |
| | | import { useUser, useFocus } from '@/hooks'; |
| | | import { useUser, useFocus, useEnsureOpenId } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | |
| | | const isDev = process.env.NODE_ENV === 'development'; |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | const { ensureOpenId } = useEnsureOpenId(); |
| | | const { isFocus } = useFocus(); |
| | | |
| | | function goPay(orderNo: string) { |
| | |
| | | @paySuccess="handePaySuccess" |
| | | :showAliPay="!isInWeChat" |
| | | :showWeixinPay="!isInAlipay" |
| | | :openId="wxOpenId" |
| | | :getOpenId="ensureOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isH5="isWeb" |
| | | :appId="WXPayAppId" |
| | |
| | | import { LifeRechargeConstants } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env'; |
| | | import { useUser, useFocus } from '@/hooks'; |
| | | import { useUser, useFocus, useEnsureOpenId } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | |
| | | const lifePayOrderType = Number(router.params?.lifePayOrderType ?? ''); |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | const { ensureOpenId } = useEnsureOpenId(); |
| | | |
| | | const { isFocus } = useFocus(); |
| | | |
| | |
| | | onClose(); |
| | | resolve(1); |
| | | }} |
| | | //@ts-ignore |
| | | onClickOverlay={() => { |
| | | onClose(); |
| | | }} |
| | | confirmText={confirmText} |
| | | ></Model> |
| | | ), |
| | |
| | | ); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import Taro from '@tarojs/taro'; |
| | | |
| | | type UseSelectPayTypeOptions = { |
| | | openId?: MaybeRef<string>; |
| | | isInWeChat?: MaybeRef<boolean>; |
| | | isH5?: MaybeRef<boolean>; |
| | | appId?: MaybeRef<string>; |
| | | getOpenId?: () => Promise<string>; |
| | | }; |
| | | |
| | | export function useSelectPayType(options: UseSelectPayTypeOptions = {}) { |
| | | const { openId, isInWeChat, isH5, appId } = options; |
| | | const { isInWeChat, isH5, appId, getOpenId } = options; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | |
| | | |
| | | async function getPayOrderForJsAPI(orderNo: string) { |
| | | try { |
| | | const openId = await getOpenId(); |
| | | let params: GetPayOrderForJsAPIInput = { |
| | | orderNo: orderNo, |
| | | lifePayType: blLifeRecharge.constants.LifePayTypeEnum.WxPay, |
| | | openId: unref(openId), |
| | | openId: openId, |
| | | attach: Date.now().toString(), |
| | | payAppId: unref(appId), |
| | | }; |
| | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | useQuery({ |
| | | queryKey: ['platformServicePayServices/getPayStatusByOrderNo', orderNo], |
| | | queryKey: ['blLifeRecharge/getPayStatusByOrderNo', orderNo], |
| | | queryFn: async () => { |
| | | return await blLifeRecharge.services.getPayStatusByOrderNo( |
| | | { |
| | |
| | | margin-top: 40px; |
| | | |
| | | .recharge-grid-item { |
| | | position: relative; |
| | | .nut-grid-item__text { |
| | | font-size: 36rpx; |
| | | color: boleGetCssVar('text-color', 'primary'); |
| | |
| | | width: 64px; |
| | | height: 64px; |
| | | } |
| | | |
| | | .discountTag { |
| | | position: absolute; |
| | | padding: 8px 16px; |
| | | border-radius: 0px 0 20px 0; |
| | | background: linear-gradient( |
| | | 186deg, |
| | | rgba(255, 129, 45, 0.08) 14.82%, |
| | | rgba(238, 67, 67, 0.08) 91.5% |
| | | ); |
| | | color: #fb5100; |
| | | font-size: 24px; |
| | | font-weight: 700; |
| | | line-height: 28px; |
| | | position: absolute; |
| | | top: -2px; |
| | | left: -2px; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | openId: toRef(props, 'openId'), |
| | | getOpenId: props.getOpenId, |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | } |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | openId: toRef(props, 'openId'), |
| | | getOpenId: props.getOpenId, |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | export type RechargeProps = { |
| | | isDev?: boolean; |
| | | openId?: string; |
| | | isInWeChat?: boolean; |
| | | isH5?: boolean; |
| | | appId?: string; |
| | |
| | | isInAlipay?: boolean; |
| | | showAliPay?: boolean; |
| | | showWeixinPay?: boolean; |
| | | getOpenId?: () => Promise<string>; |
| | | }; |
| | |
| | | <Grid square :gutter="20" :column-num="2" class="recharge-grid-wrapper"> |
| | | <GridItem class="recharge-grid-item" text="话费" @click="emit('phoneBillRecharge')"> |
| | | <img :src="IconFreePhone" class="recharge-grid-item-icon" /> |
| | | <div class="discountTag">{{ lifePayPhoneRate }}折</div> |
| | | </GridItem> |
| | | <GridItem class="recharge-grid-item" text="电费" @click="emit('electricityBillRecharge')"> |
| | | <img :src="IconFreeDian" class="recharge-grid-item-icon" /> |
| | | <div class="discountTag">{{ lifePayElectricRate }}折</div> |
| | | </GridItem> |
| | | <!-- <GridItem class="recharge-grid-item" text="燃气" @click="emit('gasBillRecharge')"> |
| | | <img :src="IconFreeGas" class="recharge-grid-item-icon" /> |
| | | <div class="discountTag">{{ lifePayGasRate }}折</div> |
| | | </GridItem> --> |
| | | </Grid> |
| | | </MainCell> |
| | |
| | | import IconFreePhone from '../../assets/icon-free-phone.png'; |
| | | import IconFreeDian from '../../assets/icon-free-dian.png'; |
| | | import IconFreeGas from '../../assets/icon-free-gas.png'; |
| | | import { useGetRate } from '../../hooks'; |
| | | |
| | | defineOptions({ |
| | | name: 'RechargeGrid', |
| | |
| | | (e: 'electricityBillRecharge'): void; |
| | | (e: 'gasBillRecharge'): void; |
| | | }>(); |
| | | |
| | | const { lifePayPhoneRate, lifePayElectricRate, lifePayGasRate } = useGetRate(); |
| | | </script> |
| | |
| | | lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum; |
| | | showAliPay?: boolean; |
| | | showWeixinPay?: boolean; |
| | | openId?: string; |
| | | isInWeChat?: boolean; |
| | | isH5?: boolean; |
| | | appId?: string; |
| | | isFocus?: boolean; |
| | | getOpenId?: () => Promise<string>; |
| | | }; |
| | | |
| | | const props = withDefaults(defineProps<Props>(), { |
| | |
| | | }>(); |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | openId: toRef(props, 'openId'), |
| | | getOpenId: props.getOpenId, |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | |
| | | } |
| | | |
| | | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ |
| | | openId: toRef(props, 'openId'), |
| | | isInWeChat: toRef(props, 'isInWeChat'), |
| | | isH5: toRef(props, 'isH5'), |
| | | appId: toRef(props, 'appId'), |
| | | getOpenId: props.getOpenId, |
| | | }); |
| | | |
| | | const currentOrderNo = ref(''); |