zhengyiming
2025-03-28 381c97332e567a1b95a9a5220275461d0ae3f74e
fix: 四期需求
7个文件已修改
52 ■■■■■ 已修改文件
apps/taro/src/app.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/hooks/user.ts 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/my/shareQrcode/InnerPage.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/utils/blLifeRecharge.ts 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/core-vue/src/plugin.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/core/src/lifeRecharge.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/core/src/lifeRechargeAccountModel.ts 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
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,
  };
}
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 ?? '');
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',
};
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) => {
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) {
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);
  }
}