From f01e5949f44c74ce85f74e37658ad848036b6b12 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期一, 09 六月 2025 15:09:00 +0800 Subject: [PATCH] fix: v1.4 --- packages/core/src/lifeRecharge.ts | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lifeRecharge.ts b/packages/core/src/lifeRecharge.ts index c529319..84d0f87 100644 --- a/packages/core/src/lifeRecharge.ts +++ b/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); + this.accountModel.setUserId(res.userId); + this.accountModel.getUserInfo(); this.accountModel.setPhoneNumber(body.phoneNumber); return res; } catch (error) { @@ -37,6 +48,9 @@ loginout() { this.accountModel.setUserId(''); this.accountModel.setPhoneNumber(''); + this.accountModel.setUserChannles([]); + this.accountModel.isBackClientUser = false; + this.accountModel.promoterIdNumber = ''; } isLogin() { @@ -44,7 +58,10 @@ } getRechargeParValue(amount: number | string, rate: number) { - return ((Number(amount) * rate) / 100).toFixed(2); + if (rate > 0) { + return ((Number(amount) * rate) / 100).toFixed(2); + } + return Number(amount).toFixed(2); } MaxParValue = 300; -- Gitblit v1.9.1