| | |
| | | const props = defineProps(commonNavigationBarProps); |
| | | |
| | | const router = Taro.useRouter(); |
| | | console.log('router: ', router); |
| | | |
| | | const isLastPage = computed(() => { |
| | | const pages = Taro.getCurrentPages(); |
| | |
| | | } from '@life-payment/core-vue'; |
| | | import { MaybeRef } from 'vue'; |
| | | import { Message } from '@/utils'; |
| | | import Taro from '@tarojs/taro'; |
| | | |
| | | export function useOnlineService() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | |
| | | type UseShowingLifePayAnnouncementOptions = { |
| | | params?: MaybeRef<API.GetShowingLifePayAnnouncementInput>; |
| | | onSuccess?: (data: API.CreateEditLifePayAnnouncementOutput) => any; |
| | | staleTime?: MaybeRef<number>; |
| | | }; |
| | | |
| | | export function useShowingLifePayAnnouncement(options: UseShowingLifePayAnnouncementOptions = {}) { |
| | | const { onSuccess, params = {} } = options; |
| | | const { onSuccess, params = {}, staleTime } = options; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | |
| | | onSuccess: (data) => { |
| | | onSuccess?.(data); |
| | | }, |
| | | staleTime: staleTime, |
| | | }); |
| | | |
| | | return { |
| | |
| | | }; |
| | | } |
| | | |
| | | const dialogShowingLifePayAnnouncementCache = {}; |
| | | |
| | | export function useDialogShowingLifePayAnnouncement() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | const router = Taro.useRouter(); |
| | | |
| | | useShowingLifePayAnnouncement({ |
| | | params: { |
| | | announcementType: blLifeRecharge.constants.AnnouncementTypeEnum.Dialog, |
| | | }, |
| | | onSuccess(data) { |
| | | Message.confirm({ |
| | | title: '公告', |
| | | message: data.announcementContent ?? '', |
| | | showCancelBtn: false, |
| | | }); |
| | | if (!dialogShowingLifePayAnnouncementCache[router.path]) { |
| | | dialogShowingLifePayAnnouncementCache[router.path] = true; |
| | | Message.confirm({ |
| | | title: '公告', |
| | | message: data.announcementContent ?? '', |
| | | showCancelBtn: false, |
| | | }); |
| | | } |
| | | }, |
| | | staleTime: Infinity, |
| | | }); |
| | | } |
| | |
| | | import { useInfiniteLoading } from './infiniteLoading'; |
| | | import { OrderInputType } from '../constants'; |
| | | import { convertOrderFrontStatus } from '../utils'; |
| | | import { useLifePayRateChannelAllList } from './rate'; |
| | | |
| | | export function useGetRate() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const { data: lifePayRateList, isLoading } = useQuery({ |
| | | queryKey: ['blLifeRecharge/getRate'], |
| | | queryFn: async () => { |
| | | return await blLifeRecharge.services.getRate({ showLoading: false }); |
| | | }, |
| | | placeholderData: () => [] as LifePayRateListOutput[], |
| | | }); |
| | | // const { data: lifePayRateList, isLoading } = useQuery({ |
| | | // queryKey: ['blLifeRecharge/getRate'], |
| | | // queryFn: async () => { |
| | | // return await blLifeRecharge.services.getRate({ showLoading: false }); |
| | | // }, |
| | | // placeholderData: () => [] as LifePayRateListOutput[], |
| | | // }); |
| | | const { allRateChannelList } = useLifePayRateChannelAllList(); |
| | | |
| | | const hasChannel = computed(() => !!blLifeRecharge.accountModel.channlesNum); |
| | | |
| | |
| | | if (hasChannel.value && channelRate.value.channlesRate) { |
| | | return channelRate.value.channlesRate; |
| | | } |
| | | // return ( |
| | | // lifePayRateList.value.find( |
| | | // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认话费折扣 |
| | | // )?.rate ?? 0 |
| | | // ); |
| | | return ( |
| | | lifePayRateList.value.find( |
| | | (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认话费折扣 |
| | | )?.rate ?? 0 |
| | | allRateChannelList.value |
| | | .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.话费订单) |
| | | .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 |
| | | ); |
| | | }); |
| | | |
| | |
| | | if (hasChannel.value && channelRate.value.channlesRate) { |
| | | return channelRate.value.channlesRate; |
| | | } |
| | | // return ( |
| | | // lifePayRateList.value.find( |
| | | // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认电费折扣 |
| | | // )?.rate ?? 0 |
| | | // ); |
| | | return ( |
| | | lifePayRateList.value.find( |
| | | (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认电费折扣 |
| | | )?.rate ?? 0 |
| | | allRateChannelList.value |
| | | .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.电费订单) |
| | | .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 |
| | | ); |
| | | }); |
| | | |
| | |
| | | if (hasChannel.value && channelRate.value.channlesRate) { |
| | | return channelRate.value.channlesRate; |
| | | } |
| | | // return ( |
| | | // lifePayRateList.value.find( |
| | | // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认燃气折扣 |
| | | // )?.rate ?? 0 |
| | | // ); |
| | | return ( |
| | | lifePayRateList.value.find( |
| | | (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认燃气折扣 |
| | | )?.rate ?? 0 |
| | | allRateChannelList.value |
| | | .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.燃气订单) |
| | | .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 |
| | | ); |
| | | }); |
| | | |
| | | return { |
| | | lifePayRateList, |
| | | // lifePayRateList, |
| | | lifePayPhoneRate, |
| | | lifePayElectricRate, |
| | | lifePayGasRate, |
| | | allRateChannelList, |
| | | }; |
| | | } |
| | | |
| | |
| | | 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) {} |
| | | }, |
| | | }); |
| | | |
New file |
| | |
| | | import { |
| | | useLifeRechargeContext, |
| | | QueryRateChannelInput, |
| | | CreateEditRateChannelOutput, |
| | | } from '@life-payment/core-vue'; |
| | | import { useQuery, useQueryClient } from '@tanstack/vue-query'; |
| | | import { MaybeRef, unref, computed, Ref } from 'vue'; |
| | | |
| | | type UseLifePayRateChannelAllListOptions = { |
| | | params?: MaybeRef<QueryRateChannelInput>; |
| | | }; |
| | | |
| | | export function useLifePayRateChannelAllList(options: UseLifePayRateChannelAllListOptions = {}) { |
| | | const { params = {} } = options; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const queryClient = useQueryClient(); |
| | | |
| | | const _params = computed(() => ({ |
| | | status: blLifeRecharge.constants.LifePayRateChannelStatus.Enabled, |
| | | ...unref(params), |
| | | })); |
| | | |
| | | const { data: allRateChannelList } = useQuery({ |
| | | queryKey: ['blLifeRecharge/getLifePayRateChannelAllList', _params], |
| | | queryFn: async () => { |
| | | return await blLifeRecharge.services.getLifePayRateChannelAllList(_params.value, { |
| | | showLoading: false, |
| | | }); |
| | | }, |
| | | 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, |
| | |
| | | /**已停止 */ |
| | | Stop = 30, |
| | | } |
| | | |
| | | export enum LifePayRateChannelStatus { |
| | | /**启用 */ |
| | | Disabled = -10, |
| | | /**禁用 */ |
| | | Enabled = 10, |
| | | } |
| | | } |
| | |
| | | } |
| | | ); |
| | | } |
| | | |
| | | /** 获取折扣通道配置列表 POST /api/LifePayRate/GetLifePayRateChannelAllList */ |
| | | async getLifePayRateChannelAllList(body: QueryRateChannelInput, options?: RequestConfig) { |
| | | return this.request<CreateEditRateChannelOutput[]>( |
| | | '/api/LifePayRate/GetLifePayRateChannelAllList', |
| | | { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | } |
| | | ); |
| | | } |
| | | } |
| | | |
| | | export interface PhoneMesssageCodeLoginInput { |
| | |
| | | creationTime?: string; |
| | | status?: LifeRechargeConstants.AnnouncementStatusEnum; |
| | | } |
| | | |
| | | export interface QueryRateChannelInput { |
| | | status?: LifeRechargeConstants.LifePayRateChannelStatus; |
| | | lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum; |
| | | } |
| | | |
| | | export interface CreateEditRateChannelOutput { |
| | | id?: string; |
| | | lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum; |
| | | /** 通道 */ |
| | | rateChannelName: string; |
| | | /** ID */ |
| | | code: string; |
| | | /** 供应商折扣 */ |
| | | supplierRate: number; |
| | | /** 平台折扣 */ |
| | | platformRate: number; |
| | | status: LifeRechargeConstants.LifePayRateChannelStatus; |
| | | /** 通知内容 */ |
| | | remark: string; |
| | | creationTime?: string; |
| | | } |
| | |
| | | |
| | | interface QueryRateChannelInput { |
| | | status?: LifePayRateChannelStatus; |
| | | lifePayOrderType?: LifePayOrderTypeEnum; |
| | | } |
| | | |
| | | interface QueryUserAccountAllListInput { |