wupengfei
2025-02-21 83f821e00802979e64840901bf2a1d18b4b61601
packages/components/src/utils/lifeRecharge.ts
@@ -1,4 +1,33 @@
export class BlLifeRecharge {
import {
  BlLifeRechargeServices,
  PhoneMesssageCodeLoginInput,
  RequestConfig,
} from './lifeRechargeServices';
import { IRequest, BlLifeRechargeOptions } from './types';
export class BlLifeRecharge<T extends IRequest = IRequest> {
  services: BlLifeRechargeServices<T>;
  userId = '';
  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) {
    return (amount * rate).toFixed(2);
  }