zhengyiming
2025-02-21 456de36d8e21416cdd2439437bdfd9460dcd15be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {
  BlLifeRechargeServices,
  PhoneMesssageCodeLoginInput,
  RequestConfig,
} from './lifeRechargeServices';
import { IRequest, BlLifeRechargeOptions } from './types';
import { LifeRechargeConstants } from './lifeRechargeConstants';
 
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) {
    return (amount * rate).toFixed(2);
  }
}