From 5cd618c9523ad30dccf858a00ff6d99a28de4187 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 11 九月 2025 10:24:35 +0800
Subject: [PATCH] feat: 公告

---
 apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue              |    1 
 packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue       |   22 +---
 packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue    |   16 ++-
 packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue           |   32 +++++++
 packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue |   32 +++++++
 packages/components/src/hooks/rate.ts                                            |   69 ++++++++++++++++
 packages/components/src/hooks/index.ts                                           |   18 ++--
 7 files changed, 156 insertions(+), 34 deletions(-)

diff --git a/apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue b/apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue
index ed91b01..b1b86d0 100644
--- a/apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue
+++ b/apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue
@@ -36,7 +36,6 @@
 const props = defineProps(commonNavigationBarProps);
 
 const router = Taro.useRouter();
-console.log('router: ', router);
 
 const isLastPage = computed(() => {
   const pages = Taro.getCurrentPages();
diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts
index 624ec3d..8288b45 100644
--- a/packages/components/src/hooks/index.ts
+++ b/packages/components/src/hooks/index.ts
@@ -283,23 +283,25 @@
   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) {}
     },
   });
 
diff --git a/packages/components/src/hooks/rate.ts b/packages/components/src/hooks/rate.ts
index 5db3d7c..48b30b4 100644
--- a/packages/components/src/hooks/rate.ts
+++ b/packages/components/src/hooks/rate.ts
@@ -3,8 +3,8 @@
   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>;
@@ -14,6 +14,8 @@
   const { params = {} } = options;
 
   const { blLifeRecharge } = useLifeRechargeContext();
+
+  const queryClient = useQueryClient();
 
   const _params = computed(() => ({
     status: blLifeRecharge.constants.LifePayRateChannelStatus.Enabled,
@@ -30,7 +32,70 @@
     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銆佺噧姘旇垂涓篻asOrgType
+   * @returns
+   */
+  function isCanRecharge(rateChannelCode: string) {
+    const rateChannel = getRateChannelByCode(rateChannelCode);
+    return rateChannel?.status === blLifeRecharge.constants.LifePayRateChannelStatus.Enabled;
+  }
+
+  /**
+   *
+   * @param rateChannelCode
+   * @description rateChannelCode鍊艰瘽璐逛负IspCode銆佺數璐逛负electricType銆佺噧姘旇垂涓篻asOrgType
+   * @returns
+   */
+  function checkCanRecharge(rateChannelCode: string) {
+    const rateChannel = getRateChannelByCode(rateChannelCode);
+    if (!isCanRecharge(rateChannelCode)) {
+      //閫氶亾姝e湪鍗囩骇锛岀粰鎮ㄥ甫鏉ヤ笉渚垮敖鎯呰皡瑙�
+      msg.value = rateChannel?.remark ?? '';
+      show.value = true;
+      return false;
+    }
+    return true;
+  }
+
+  return {
+    isCanRecharge,
+    checkCanRecharge,
+    ensureLifePayRateChannelAllList,
   };
 }
diff --git a/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue b/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
index be78bf7..ef36068 100644
--- a/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
+++ b/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
@@ -13,7 +13,7 @@
           direction="horizontal"
           class="par-account-list"
           v-if="userAccountAllList.length > 0"
-          @change="handleUserAccountChange"
+          @change="_handleUserAccountChange"
         >
           <NutRadio
             :label="item.id"
@@ -145,6 +145,7 @@
 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',
@@ -199,7 +200,28 @@
       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');
@@ -257,8 +279,16 @@
 
 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,
diff --git a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue
index 2b4f92a..bd2b1fb 100644
--- a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue
+++ b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue
@@ -8,12 +8,9 @@
   >
     <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>
@@ -56,6 +53,7 @@
 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',
@@ -78,6 +76,12 @@
 
 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) {
diff --git a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
index 43e7e4c..a5508c1 100644
--- a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
+++ b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
@@ -132,6 +132,7 @@
 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',
@@ -166,7 +167,8 @@
     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
@@ -262,20 +264,10 @@
 
 const currentOrderNo = ref('');
 
-function isCanRecharge(ispCode: string) {
-  return ispCode !== blLifeRecharge.constants.IspCode.yidong;
-}
-
-function checkCanRecharge(ispCode: string) {
-  if (!isCanRecharge(ispCode)) {
-    //閫氶亾姝e湪鍗囩骇锛岀粰鎮ㄥ甫鏉ヤ笉渚垮敖鎯呰皡瑙�
-    state.msg =
-      '灏婃暚鐨勭敤鎴凤紝涓烘彁渚涙洿瀹夊叏銆佺ǔ瀹氱殑鍏呭�兼湇鍔★紝绉诲姩鍏呭�奸�氶亾姝e湪杩涜鍗囩骇缁存姢锛岀淮鎶ゆ湡闂存殏鏃犳硶鍙戣捣鍏呭��';
-    state.show = true;
-    return false;
-  }
-  return true;
-}
+const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({
+  msg: toRef(state, 'msg'),
+  show: toRef(state, 'show'),
+});
 
 async function goPay() {
   try {
diff --git a/packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue b/packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
index 40844f6..719bc65 100644
--- a/packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
+++ b/packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
@@ -13,7 +13,7 @@
           direction="horizontal"
           class="par-account-list"
           v-if="userAccountAllList.length > 0"
-          @change="handleUserAccountChange"
+          @change="_handleUserAccountChange"
         >
           <NutRadio
             :label="item.id"
@@ -143,6 +143,7 @@
 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',
@@ -201,7 +202,28 @@
       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');
@@ -261,8 +283,16 @@
 
 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,

--
Gitblit v1.9.1