|  |  | 
 |  |  |         </NutRadio> | 
 |  |  |       </NutRadioGroup> | 
 |  |  |     </NutFormItem> | 
 |  |  |     <SelectPayTypeFormItem v-model="form.lifePayType"></SelectPayTypeFormItem> | 
 |  |  |     <div class="common-content"> | 
 |  |  |       <nut-button class="recharge-button" type="primary" @click="handleSubmit"> | 
 |  |  |         <div class="recharge-button-inner"> | 
 |  |  | 
 |  |  |   Button as NutButton, | 
 |  |  | } from '@nutui/nutui-taro'; | 
 |  |  | import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types'; | 
 |  |  | import { reactive, ref, computed } from 'vue'; | 
 |  |  | import { reactive, ref, computed, toRef } from 'vue'; | 
 |  |  | import { | 
 |  |  |   useLifeRechargeContext, | 
 |  |  |   LifeElectricDataCreateLifePayOrderInput, | 
 |  |  | 
 |  |  | } from '@life-payment/core-vue'; | 
 |  |  | import { useGetRate, useGetGasParValue, useSetUserAccountBySelect } from '../../hooks'; | 
 |  |  | import { useGasBillRechargeContext, GasUserAccountExtraProperties } from './context'; | 
 |  |  | import { FormValidator } from '../../utils'; | 
 |  |  | import { FormValidator, initLifePayType } from '../../utils'; | 
 |  |  | import { CustomerServiceTips } from '../../constants'; | 
 |  |  | import AccountAddCard from '../../components/Card/AccountAddCard.vue'; | 
 |  |  | import AccountCard from '../../components/Card/AccountCard.vue'; | 
 |  |  | import RechargeTipsView from '../../components/RechargeTipsView/RechargeTipsView.vue'; | 
 |  |  | import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue'; | 
 |  |  | import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue'; | 
 |  |  | import SelectPayTypeFormItem from '../../components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue'; | 
 |  |  | import { useSelectPayType, useGetPayStatusByOrderNo } from '../../hooks/selectPayType'; | 
 |  |  | import { RechargeProps } from '../PhoneBillRecharge/types'; | 
 |  |  |  | 
 |  |  | defineOptions({ | 
 |  |  |   name: 'GasBillRechargeStep3', | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | type Props = { | 
 |  |  |   isDev?: boolean; | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | const props = withDefaults(defineProps<Props>(), { | 
 |  |  | const props = withDefaults(defineProps<RechargeProps>(), { | 
 |  |  |   isDev: false, | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | const emit = defineEmits<{ | 
 |  |  |   (e: 'goPay', orderNo: string): void; | 
 |  |  |   (e: 'paySuccess', orderNo: string): void; | 
 |  |  | }>(); | 
 |  |  |  | 
 |  |  | const { goTo } = useGasBillRechargeContext(); | 
 |  |  | 
 |  |  |   currentUserAccountId: '', | 
 |  |  |   remark: '', | 
 |  |  |   areaList: [] as string[], | 
 |  |  |   lifePayType: initLifePayType(props.isInWeChat, props.isInAlipay), | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | const { userAccountAllList, handleUserAccountChange } = useSetUserAccountBySelect({ | 
 |  |  | 
 |  |  |     { required: true, message: '请选择充值金额', validator: FormValidator.validatorNumberNotNull }, | 
 |  |  |   ], | 
 |  |  |   currentUserAccountId: [{ required: true, message: '请选择充值户号' }], | 
 |  |  |   lifePayType: [{ required: true, message: '请选择支付方式' }], | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | const formRef = ref<any>(null); | 
 |  |  | 
 |  |  |   confirmDialogVisible.value = true; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ | 
 |  |  |   openId: toRef(props, 'openId'), | 
 |  |  |   isInWeChat: toRef(props, 'isInWeChat'), | 
 |  |  |   isH5: toRef(props, 'isH5'), | 
 |  |  |   appId: toRef(props, 'appId'), | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | const currentOrderNo = ref(''); | 
 |  |  |  | 
 |  |  | async function goPay() { | 
 |  |  |   try { | 
 |  |  |     let params: LifeGasDataCreateLifePayOrderInput = { | 
 |  |  |       userId: blLifeRecharge.accountModel.userId, | 
 |  |  |       channelId: blLifeRecharge.accountModel.channlesNum, | 
 |  |  |       productData: { | 
 |  |  |         parValue: props.isDev ? 0.1 : form.parValue, | 
 |  |  |         gasOrgType: form.gasOrgType, | 
 |  |  | 
 |  |  |       }, | 
 |  |  |     }; | 
 |  |  |     let res = await blLifeRecharge.services.createLifePayGasOrder(params); | 
 |  |  |     emit('goPay', res.orderNo); | 
 |  |  |     // emit('goPay', res.orderNo); | 
 |  |  |     if (form.lifePayType === LifeRechargeConstants.LifePayTypeEnum.WxPay) { | 
 |  |  |       await invokeWeixinPay(res.orderNo); | 
 |  |  |     } else { | 
 |  |  |       await invokeAliPay(res.orderNo); | 
 |  |  |     } | 
 |  |  |     currentOrderNo.value = res.orderNo; | 
 |  |  |   } catch (error) {} | 
 |  |  | } | 
 |  |  |  | 
 |  |  | useGetPayStatusByOrderNo({ | 
 |  |  |   orderNo: currentOrderNo, | 
 |  |  |   enabled: computed(() => props.isFocus && !!currentOrderNo.value), | 
 |  |  |   onPaySuccess: (orderNo) => { | 
 |  |  |     emit('paySuccess', orderNo); | 
 |  |  |     currentOrderNo.value = ''; | 
 |  |  |   }, | 
 |  |  | }); | 
 |  |  | </script> |