| | |
| | | |
| | | // return { isFirstEnter }; |
| | | // } |
| | | |
| | | export function useFocus() { |
| | | const isFocus = ref(false); |
| | | |
| | | Taro.useDidShow(() => { |
| | | isFocus.value = true; |
| | | }); |
| | | |
| | | Taro.useDidHide(() => { |
| | | isFocus.value = false; |
| | | }); |
| | | |
| | | return { |
| | | isFocus, |
| | | }; |
| | | } |
| | |
| | | :showWeixinPay="!isInAlipay" |
| | | :openId="wxOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isH5="isH5" |
| | | :isH5="isWeb" |
| | | :appId="WXPayAppId" |
| | | :isFocus="isFocus" |
| | | /> |
| | | </ContentScrollView> |
| | | </template> |
| | |
| | | import { SelectPayTypeView } from '@life-payment/components'; |
| | | import { LifeRechargeConstants } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat, isH5 } from '@/utils/env'; |
| | | import { useUser } from '@/hooks'; |
| | | import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env'; |
| | | import { useUser, useFocus } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | |
| | | const { isFocus } = useFocus(); |
| | | |
| | | function handePaySuccess( |
| | | orderNo: string, |
| | | lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum |
| | |
| | | } from '@life-payment/core-vue'; |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | import { Toast as NutToast } from '@nutui/nutui-taro'; |
| | | import { reactive } from 'vue'; |
| | | import { onMounted, reactive, ref, computed } from 'vue'; |
| | | |
| | | defineOptions({ |
| | | name: 'SelectPayTypeView', |
| | |
| | | isInWeChat?: boolean; |
| | | isH5?: boolean; |
| | | appId?: string; |
| | | isFocus?: boolean; |
| | | }; |
| | | |
| | | const props = withDefaults(defineProps<Props>(), { |
| | |
| | | if (res.err_msg == 'get_brand_wcpay_request:ok') { |
| | | // 使用以上方式判断前端返回,微信团队郑重提示: |
| | | //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠,商户需进一步调用后端查单确认支付结果。 |
| | | } else if (res.err_msg == 'system:access_denied') { |
| | | state.msg = '请在手机微信中打开'; |
| | | state.show = true; |
| | | } else { |
| | | state.msg = res.err_msg; |
| | | state.show = true; |
| | | } |
| | | }, |
| | | function (res) { |
| | | console.log('res: ', res); |
| | | } |
| | | ); |
| | | } |
| | |
| | | } |
| | | }, |
| | | refetchInterval: 1000 * 3, |
| | | enabled: computed(() => props.isFocus), |
| | | }); |
| | | </script> |