| | |
| | | const props = defineProps(commonNavigationBarProps); |
| | | |
| | | const router = Taro.useRouter(); |
| | | console.log('router: ', router); |
| | | |
| | | const isLastPage = computed(() => { |
| | | const pages = Taro.getCurrentPages(); |
| | |
| | | onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any; |
| | | getDefaultUserAccount?: ( |
| | | userAccountList: UserAccountListOutput[] |
| | | ) => UserAccountListOutput | undefined; |
| | | ) => Promise<UserAccountListOutput | undefined>; |
| | | }; |
| | | |
| | | export function useSetUserAccountBySelect({ |
| | | lifePayOrderType, |
| | | onSetUserAccount, |
| | | getDefaultUserAccount = (data) => data[0], |
| | | getDefaultUserAccount = (data) => Promise.resolve(data[0]), |
| | | }: UseSetUserAccountBySelectOptions) { |
| | | const { userAccountAllList } = useUserAccountAllList({ |
| | | lifePayOrderType: lifePayOrderType, |
| | | onSuccess(data) { |
| | | if (data.length > 0) { |
| | | const currentUserAccount = getDefaultUserAccount(data); |
| | | if (currentUserAccount) { |
| | | onSetUserAccount?.(currentUserAccount); |
| | | async onSuccess(data) { |
| | | try { |
| | | if (data.length > 0) { |
| | | const currentUserAccount = await getDefaultUserAccount(data); |
| | | if (currentUserAccount) { |
| | | onSetUserAccount?.(currentUserAccount); |
| | | } |
| | | } |
| | | } |
| | | } catch (error) {} |
| | | }, |
| | | }); |
| | | |
| | |
| | | QueryRateChannelInput, |
| | | CreateEditRateChannelOutput, |
| | | } from '@life-payment/core-vue'; |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | import { MaybeRef, unref, computed } from 'vue'; |
| | | import { useQuery, useQueryClient } from '@tanstack/vue-query'; |
| | | import { MaybeRef, unref, computed, Ref } from 'vue'; |
| | | |
| | | type UseLifePayRateChannelAllListOptions = { |
| | | params?: MaybeRef<QueryRateChannelInput>; |
| | |
| | | const { params = {} } = options; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const queryClient = useQueryClient(); |
| | | |
| | | const _params = computed(() => ({ |
| | | status: blLifeRecharge.constants.LifePayRateChannelStatus.Enabled, |
| | |
| | | placeholderData: () => [] as CreateEditRateChannelOutput[], |
| | | }); |
| | | |
| | | function ensureLifePayRateChannelAllList() { |
| | | return queryClient.ensureQueryData({ |
| | | queryKey: ['blLifeRecharge/getLifePayRateChannelAllList', _params], |
| | | }); |
| | | } |
| | | |
| | | function getRateChannelByCode(code: string) { |
| | | return allRateChannelList.value.find((item) => item.code === code); |
| | | } |
| | | |
| | | return { |
| | | allRateChannelList, |
| | | ensureLifePayRateChannelAllList, |
| | | getRateChannelByCode, |
| | | }; |
| | | } |
| | | |
| | | type UseCheckCanRechargeOptions = { |
| | | msg: Ref<string>; |
| | | show: Ref<boolean>; |
| | | }; |
| | | |
| | | export function useCheckCanRecharge(options: UseCheckCanRechargeOptions) { |
| | | const { msg, show } = options; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const { getRateChannelByCode, ensureLifePayRateChannelAllList } = useLifePayRateChannelAllList({ |
| | | params: { |
| | | status: null, |
| | | }, |
| | | }); |
| | | |
| | | /** |
| | | * |
| | | * @param rateChannelCode |
| | | * @description rateChannelCode值话费为IspCode、电费为electricType、燃气费为gasOrgType |
| | | * @returns |
| | | */ |
| | | function isCanRecharge(rateChannelCode: string) { |
| | | const rateChannel = getRateChannelByCode(rateChannelCode); |
| | | return rateChannel?.status === blLifeRecharge.constants.LifePayRateChannelStatus.Enabled; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param rateChannelCode |
| | | * @description rateChannelCode值话费为IspCode、电费为electricType、燃气费为gasOrgType |
| | | * @returns |
| | | */ |
| | | function checkCanRecharge(rateChannelCode: string) { |
| | | const rateChannel = getRateChannelByCode(rateChannelCode); |
| | | if (!isCanRecharge(rateChannelCode)) { |
| | | //通道正在升级,给您带来不便尽情谅解 |
| | | msg.value = rateChannel?.remark ?? ''; |
| | | show.value = true; |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | return { |
| | | isCanRecharge, |
| | | checkCanRecharge, |
| | | ensureLifePayRateChannelAllList, |
| | | }; |
| | | } |
| | |
| | | direction="horizontal" |
| | | class="par-account-list" |
| | | v-if="userAccountAllList.length > 0" |
| | | @change="handleUserAccountChange" |
| | | @change="_handleUserAccountChange" |
| | | > |
| | | <NutRadio |
| | | :label="item.id" |
| | |
| | | import { RechargeProps } from '../PhoneBillRecharge/types'; |
| | | import Chunk from '../../components/Layout/Chunk.vue'; |
| | | import IconSelect from '../../assets/recharge/icon-select.png'; |
| | | import { useCheckCanRecharge } from '../../hooks/rate'; |
| | | |
| | | defineOptions({ |
| | | name: 'GasBillRechargeStep3', |
| | |
| | | form.parValue = 0; |
| | | } |
| | | }, |
| | | async getDefaultUserAccount(userAccountList) { |
| | | await ensureLifePayRateChannelAllList(); |
| | | const defaultUserAccount = userAccountList.find((x) => { |
| | | const currentUserAccountExtraProperties = JSON.parse( |
| | | x.extraProperties |
| | | ) as GasUserAccountExtraProperties; |
| | | return isCanRecharge(currentUserAccountExtraProperties.gasOrgType); |
| | | }); |
| | | return defaultUserAccount; |
| | | }, |
| | | }); |
| | | |
| | | function _handleUserAccountChange(userAccountId: string) { |
| | | const currentUserAccount = userAccountAllList.value.find((x) => x.id === userAccountId); |
| | | const currentUserAccountExtraProperties = JSON.parse( |
| | | currentUserAccount.extraProperties |
| | | ) as GasUserAccountExtraProperties; |
| | | if (!checkCanRecharge(currentUserAccountExtraProperties.gasOrgType)) { |
| | | // return; |
| | | } |
| | | handleUserAccountChange(userAccountId); |
| | | } |
| | | |
| | | function handleAddUserAccount() { |
| | | goTo('step1'); |
| | |
| | | |
| | | const currentOrderNo = ref(''); |
| | | |
| | | const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({ |
| | | msg: toRef(state, 'msg'), |
| | | show: toRef(state, 'show'), |
| | | }); |
| | | |
| | | async function goPay() { |
| | | try { |
| | | if (!checkCanRecharge(form.gasOrgType)) { |
| | | return; |
| | | } |
| | | let params: LifeGasDataCreateLifePayOrderInput = { |
| | | userId: blLifeRecharge.accountModel.userId, |
| | | channelId: blLifeRecharge.accountModel.channlesNum, |
| | |
| | | > |
| | | <NutFormItem label="选择运营商:" class="bole-form-item" prop="ispCode" required> |
| | | <NutRadioGroup v-model="form.ispCode" direction="horizontal" @change="handleIspCodeChange"> |
| | | <BlRadio |
| | | :label="key" |
| | | v-for="(val, key) in BlLifeRecharge.constants.IspCodeTextForSelect" |
| | | :key="key" |
| | | >{{ val }}</BlRadio |
| | | > |
| | | <BlRadio :label="item.code" v-for="item in allRateChannelList" :key="item.id">{{ |
| | | item.rateChannelName |
| | | }}</BlRadio> |
| | | </NutRadioGroup> |
| | | </NutFormItem> |
| | | <NutFormItem label="充值手机号" class="bole-form-item" prop="phone" required> |
| | |
| | | import BlRadio from '../../components/Radio/Radio.vue'; |
| | | import { FormValidator } from '../../utils'; |
| | | import { BlLifeRecharge, LifeRechargeConstants } from '@life-payment/core-vue'; |
| | | import { useLifePayRateChannelAllList } from '../../hooks/rate'; |
| | | |
| | | defineOptions({ |
| | | name: 'PhoneBillRechargeBaseForm', |
| | |
| | | |
| | | const dialogVisible = ref(false); |
| | | |
| | | const { allRateChannelList } = useLifePayRateChannelAllList({ |
| | | params: { |
| | | lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum.话费订单, |
| | | }, |
| | | }); |
| | | |
| | | function handleIspCodeChange(ispCode: LifeRechargeConstants.IspCode) { |
| | | console.log('ispCode: ', ispCode); |
| | | if (ispCode === LifeRechargeConstants.IspCode.dianxin) { |
| | |
| | | import { RechargeProps } from './types'; |
| | | import Chunk from '../../components/Layout/Chunk.vue'; |
| | | import IconSelect from '../../assets/recharge/icon-select.png'; |
| | | import { useCheckCanRecharge } from '../../hooks/rate'; |
| | | |
| | | defineOptions({ |
| | | name: 'PhoneBillRechargeStep2', |
| | |
| | | form.remark = currentUserAccount.remark; |
| | | changeIspCode(form.ispCode as any); |
| | | }, |
| | | getDefaultUserAccount(userAccountList) { |
| | | async getDefaultUserAccount(userAccountList) { |
| | | await ensureLifePayRateChannelAllList(); |
| | | const defaultUserAccount = userAccountList.find((x) => { |
| | | const currentUserAccountExtraProperties = JSON.parse( |
| | | x.extraProperties |
| | |
| | | |
| | | const currentOrderNo = ref(''); |
| | | |
| | | function isCanRecharge(ispCode: string) { |
| | | return ispCode !== blLifeRecharge.constants.IspCode.yidong; |
| | | } |
| | | |
| | | function checkCanRecharge(ispCode: string) { |
| | | if (!isCanRecharge(ispCode)) { |
| | | //通道正在升级,给您带来不便尽情谅解 |
| | | state.msg = |
| | | '尊敬的用户,为提供更安全、稳定的充值服务,移动充值通道正在进行升级维护,维护期间暂无法发起充值'; |
| | | state.show = true; |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({ |
| | | msg: toRef(state, 'msg'), |
| | | show: toRef(state, 'show'), |
| | | }); |
| | | |
| | | async function goPay() { |
| | | try { |
| | |
| | | direction="horizontal" |
| | | class="par-account-list" |
| | | v-if="userAccountAllList.length > 0" |
| | | @change="handleUserAccountChange" |
| | | @change="_handleUserAccountChange" |
| | | > |
| | | <NutRadio |
| | | :label="item.id" |
| | |
| | | import { RechargeProps } from '../PhoneBillRecharge/types'; |
| | | import Chunk from '../../components/Layout/Chunk.vue'; |
| | | import IconSelect from '../../assets/recharge/icon-select.png'; |
| | | import { useCheckCanRecharge } from '../../hooks/rate'; |
| | | |
| | | defineOptions({ |
| | | name: 'ElectricBillRechargeStep2', |
| | |
| | | form.parValue = 0; |
| | | } |
| | | }, |
| | | async getDefaultUserAccount(userAccountList) { |
| | | await ensureLifePayRateChannelAllList(); |
| | | const defaultUserAccount = userAccountList.find((x) => { |
| | | const currentUserAccountExtraProperties = JSON.parse( |
| | | x.extraProperties |
| | | ) as ElectricUserAccountExtraProperties; |
| | | return isCanRecharge(currentUserAccountExtraProperties.electricType); |
| | | }); |
| | | return defaultUserAccount; |
| | | }, |
| | | }); |
| | | |
| | | function _handleUserAccountChange(userAccountId: string) { |
| | | const currentUserAccount = userAccountAllList.value.find((x) => x.id === userAccountId); |
| | | const currentUserAccountExtraProperties = JSON.parse( |
| | | currentUserAccount.extraProperties |
| | | ) as ElectricUserAccountExtraProperties; |
| | | if (!checkCanRecharge(currentUserAccountExtraProperties.electricType)) { |
| | | // return; |
| | | } |
| | | handleUserAccountChange(userAccountId); |
| | | } |
| | | |
| | | function handleAddUserAccount() { |
| | | goTo('step1'); |
| | |
| | | |
| | | const currentOrderNo = ref(''); |
| | | |
| | | const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({ |
| | | msg: toRef(state, 'msg'), |
| | | show: toRef(state, 'show'), |
| | | }); |
| | | |
| | | async function goPay() { |
| | | try { |
| | | if (!checkCanRecharge(form.electricType)) { |
| | | return; |
| | | } |
| | | let params: LifeElectricDataCreateLifePayOrderInput = { |
| | | userId: blLifeRecharge.accountModel.userId, |
| | | channelId: blLifeRecharge.accountModel.channlesNum, |