zhengyiming
2025-04-02 0886e91fdfe3b5528f80d2b6742083aa11d16ebb
packages/core/src/lifeRecharge.ts
@@ -2,31 +2,42 @@
  BlLifeRechargeServices,
  PhoneMesssageCodeLoginInput,
  RequestConfig,
  ChannelOutput,
} from './lifeRechargeServices';
import { BlLifeRechargeOptions } from './types';
import { LifeRechargeConstants } from './lifeRechargeConstants';
import { BlLifeRechargeAccountModel } from './lifeRechargeAccountModel';
import { LifeRechargeListener } from './listener';
export class BlLifeRecharge<TResponse = any, TRequestOptions = any> {
  services: BlLifeRechargeServices<TResponse, TRequestOptions>;
  accountModel: BlLifeRechargeAccountModel;
  listener: LifeRechargeListener;
  static constants = LifeRechargeConstants;
  constants = LifeRechargeConstants;
  constructor(options: BlLifeRechargeOptions<TResponse, TRequestOptions>) {
    this.listener = new LifeRechargeListener();
    this.services = new BlLifeRechargeServices(this, options);
    this.accountModel = new BlLifeRechargeAccountModel({
    this.accountModel = new BlLifeRechargeAccountModel(this, {
      userId: options.userId,
      phoneNumber: options.phoneNumber,
      channlesNum: options.channlesNum,
    });
  }
  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) {
@@ -37,6 +48,8 @@
  loginout() {
    this.accountModel.setUserId('');
    this.accountModel.setPhoneNumber('');
    this.accountModel.setUserChannles([]);
    this.accountModel.isBackClientUser = false;
  }
  isLogin() {