zhengyiming
2025-02-21 bc9db06646fc925635dd5995d521bcf9fd05aa93
packages/components/src/utils/lifeRecharge.ts
@@ -1,11 +1,35 @@
import { BlLifeRechargeServices } from './lifeRechargeServices';
import {
  BlLifeRechargeServices,
  PhoneMesssageCodeLoginInput,
  RequestConfig,
} from './lifeRechargeServices';
import { IRequest, BlLifeRechargeOptions } from './types';
import { LifeRechargeConstants } from './lifeRechargeConstants';
export class BlLifeRecharge<T extends IRequest> {
export class BlLifeRecharge<T extends IRequest = IRequest> {
  services: BlLifeRechargeServices<T>;
  userId = '';
  static constants = LifeRechargeConstants;
  constants = LifeRechargeConstants;
  constructor(options: BlLifeRechargeOptions<T>) {
    this.services = new BlLifeRechargeServices(options);
    this.userId = options.userId || '';
  }
  async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) {
    let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options);
    this.userId = res;
    return res;
  }
  loginout() {
    this.userId = '';
  }
  isLogin() {
    return !!this.userId;
  }
  getRechargeParValue(amount: number, rate: number) {