From 797fa07355a312a06541ca105a00928e95dbded6 Mon Sep 17 00:00:00 2001 From: zym2525 <540361168@qq.com> Date: 星期日, 23 二月 2025 14:39:44 +0800 Subject: [PATCH] fix: some --- packages/components/src/utils/lifeRecharge.ts | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/components/src/utils/lifeRecharge.ts b/packages/components/src/utils/lifeRecharge.ts index 68a5e06..1cdaf07 100644 --- a/packages/components/src/utils/lifeRecharge.ts +++ b/packages/components/src/utils/lifeRecharge.ts @@ -1,20 +1,43 @@ -import { BlLifeRechargeServices, PhoneMesssageCodeLoginInput } from './lifeRechargeServices'; +import { + BlLifeRechargeServices, + PhoneMesssageCodeLoginInput, + RequestConfig, +} from './lifeRechargeServices'; import { IRequest, BlLifeRechargeOptions } from './types'; +import { LifeRechargeConstants } from './lifeRechargeConstants'; +import { BlLifeRechargeAccountModel } from './lifeRechargeAccountModel'; export class BlLifeRecharge<T extends IRequest = IRequest> { services: BlLifeRechargeServices<T>; - isLogin = false; + accountModel: BlLifeRechargeAccountModel; + + static constants = LifeRechargeConstants; + constants = LifeRechargeConstants; constructor(options: BlLifeRechargeOptions<T>) { this.services = new BlLifeRechargeServices(options); + this.accountModel = new BlLifeRechargeAccountModel({ + userId: options.userId, + phoneNumber: options.phoneNumber, + }); } - login(body: PhoneMesssageCodeLoginInput) { - let res = this.services.lifePayPhoneMesssageCodeLogin(body); - this.isLogin = true; + async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) { + let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options); + this.accountModel.setUserId(res); + this.accountModel.setPhoneNumber(body.phoneNumber); return res; } + loginout() { + this.accountModel.setUserId(''); + this.accountModel.setPhoneNumber(''); + } + + isLogin() { + return !!this.accountModel.userId; + } + getRechargeParValue(amount: number, rate: number) { return (amount * rate).toFixed(2); } -- Gitblit v1.9.1