From 381c97332e567a1b95a9a5220275461d0ae3f74e Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 28 三月 2025 17:30:37 +0800
Subject: [PATCH] fix: 四期需求

---
 apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue |    6 ++++--
 apps/taro/src/app.ts                                   |    3 ++-
 packages/core/src/lifeRechargeAccountModel.ts          |   18 +++++++++++-------
 apps/taro/src/hooks/user.ts                            |    6 +++---
 packages/core-vue/src/plugin.ts                        |    1 +
 packages/core/src/lifeRecharge.ts                      |   11 +++++++----
 apps/taro/src/utils/blLifeRecharge.ts                  |    7 +++++++
 7 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/apps/taro/src/app.ts b/apps/taro/src/app.ts
index 1af221b..f940945 100644
--- a/apps/taro/src/app.ts
+++ b/apps/taro/src/app.ts
@@ -11,7 +11,7 @@
 import { VueQueryPlugin, VueQueryPluginOptions } from '@tanstack/vue-query';
 import { myClient } from '@/constants/query';
 import { VueLifeRechargePlugin } from '@life-payment/core-vue';
-import { blLifeRecharge } from '@/utils/blLifeRecharge';
+import { blLifeRecharge, LifeRechargeOptions } from '@/utils/blLifeRecharge';
 import { isWeChat } from '@/utils/env';
 
 window.uni = Taro;
@@ -93,6 +93,7 @@
 
 App.use(VueLifeRechargePlugin, {
   blLifeRecharge,
+  // options: LifeRechargeOptions,
 });
 
 export default App;
diff --git a/apps/taro/src/hooks/user.ts b/apps/taro/src/hooks/user.ts
index 36ec443..981d80e 100644
--- a/apps/taro/src/hooks/user.ts
+++ b/apps/taro/src/hooks/user.ts
@@ -55,9 +55,9 @@
   }
 
   const { blLifeRecharge } = useLifeRechargeContext();
-  const { virtualUserInfo } = useVirtualUserInfo();
+  // const { virtualUserInfo } = useVirtualUserInfo();
 
-  const isChannelAccount = computed(() => virtualUserInfo.value.isBackClientUser);
+  const isChannelAccount = computed(() => blLifeRecharge.accountModel.isBackClientUser);
 
   return {
     user: userInfo,
@@ -69,7 +69,7 @@
     wxCode,
     wxOpenId,
     isChannelAccount,
-    virtualUserInfo,
+    // virtualUserInfo,
   };
 }
 
diff --git a/apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue b/apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue
index 9df5cfa..e1c1c9d 100644
--- a/apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue
+++ b/apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue
@@ -13,15 +13,17 @@
 
 <script setup lang="ts">
 import { ShareQrcodeView } from '@life-payment/components';
+import { useLifeRechargeContext } from '@life-payment/core-vue';
 import { useUser } from '@/hooks';
 
 defineOptions({
   name: 'InnerPage',
 });
 
-const { virtualUserInfo } = useUser();
+// const { virtualUserInfo } = useUser();
+const { blLifeRecharge } = useLifeRechargeContext();
 
-const userChannles = computed(() => virtualUserInfo.value.channlesNum ?? []);
+const userChannles = computed(() => blLifeRecharge.accountModel.userChannles ?? []);
 
 const channlesType = ref(userChannles.value[0]?.channlesNum ?? '');
 
diff --git a/apps/taro/src/utils/blLifeRecharge.ts b/apps/taro/src/utils/blLifeRecharge.ts
index fd757e3..7a1e19e 100644
--- a/apps/taro/src/utils/blLifeRecharge.ts
+++ b/apps/taro/src/utils/blLifeRecharge.ts
@@ -9,3 +9,10 @@
   phoneNumber: getStorageVirtualUserId()?.virtualPhoneNumber ?? '',
   channlesNum: '818',
 });
+
+export const LifeRechargeOptions = {
+  axiosConfig: config,
+  userId: getStorageVirtualUserId()?.virtualUserId ?? '',
+  phoneNumber: getStorageVirtualUserId()?.virtualPhoneNumber ?? '',
+  channlesNum: '818',
+};
diff --git a/packages/core-vue/src/plugin.ts b/packages/core-vue/src/plugin.ts
index 9bd40c1..ca1fdec 100644
--- a/packages/core-vue/src/plugin.ts
+++ b/packages/core-vue/src/plugin.ts
@@ -21,6 +21,7 @@
 export const VueLifeRechargePlugin = {
   install: (app: any, { blLifeRecharge }: VueLifeRechargePluginOptions) => {
     const _blLifeRecharge = reactive(blLifeRecharge);
+    _blLifeRecharge.init();
 
     // blLifeRecharge.listener.addListener({
     //   update: (state) => {
diff --git a/packages/core/src/lifeRecharge.ts b/packages/core/src/lifeRecharge.ts
index 409801a..38e3088 100644
--- a/packages/core/src/lifeRecharge.ts
+++ b/packages/core/src/lifeRecharge.ts
@@ -17,10 +17,6 @@
   static constants = LifeRechargeConstants;
   constants = LifeRechargeConstants;
 
-  /**鐢ㄦ埛鎵�鏈夌殑娓犻亾 */
-  userChannles = [] as ChannelOutput[];
-  isBackClientUser: boolean;
-
   constructor(options: BlLifeRechargeOptions<TResponse, TRequestOptions>) {
     this.listener = new LifeRechargeListener();
     this.services = new BlLifeRechargeServices(this, options);
@@ -31,10 +27,17 @@
     });
   }
 
+  init() {
+    if (this.accountModel.userId) {
+      this.accountModel.getUserInfo();
+    }
+  }
+
   async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) {
     try {
       let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options);
       this.accountModel.setUserId(res.userId);
+      this.accountModel.getUserInfo();
       this.accountModel.setPhoneNumber(body.phoneNumber);
       return res;
     } catch (error) {
diff --git a/packages/core/src/lifeRechargeAccountModel.ts b/packages/core/src/lifeRechargeAccountModel.ts
index 42a4afc..45a7dfd 100644
--- a/packages/core/src/lifeRechargeAccountModel.ts
+++ b/packages/core/src/lifeRechargeAccountModel.ts
@@ -9,6 +9,10 @@
   phoneNumber = '';
   channlesNum = '';
 
+  /**鐢ㄦ埛鎵�鏈夌殑娓犻亾 */
+  userChannles = [] as ChannelOutput[];
+  isBackClientUser: boolean;
+
   constructor(
     ctx: BlLifeRecharge<TResponse, TRequestOptions>,
     options: BlLifeRechargeAccountModelOptions = {}
@@ -23,22 +27,22 @@
   setUserId(userId: string) {
     this.userId = userId;
     this.ctx.listener.fireEvent('update', this.ctx);
-    if (userId) {
-      this.getUserInfo(userId);
-    }
+    // if (userId) {
+    //   this.getUserInfo(userId);
+    // }
   }
 
-  async getUserInfo(userId: string) {
+  async getUserInfo(userId?: string) {
     try {
       let res = await this.ctx.services.lifePayUserMesssageByIduser(
         {
-          id: userId,
+          id: userId || this.userId,
         },
         {
           showLoading: false,
         }
       );
-      this.ctx.isBackClientUser = res.isBackClientUser;
+      this.isBackClientUser = res.isBackClientUser;
       if (res && res.isBackClientUser) {
         this.setUserChannles(res.channlesNum ?? []);
       }
@@ -57,7 +61,7 @@
     this.ctx.listener.fireEvent('update', this.ctx);
   }
   setUserChannles(userChannles: ChannelOutput[]) {
-    this.ctx.userChannles = userChannles;
+    this.userChannles = userChannles;
     this.ctx.listener.fireEvent('update', this.ctx);
   }
 }

--
Gitblit v1.9.1