From 8bb9173a95a87e3ceab4f48b5b34041af38b7c70 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期五, 28 三月 2025 15:23:14 +0800 Subject: [PATCH] fix: 四期需求 --- packages/core/src/lifeRechargeAccountModel.ts | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lifeRechargeAccountModel.ts b/packages/core/src/lifeRechargeAccountModel.ts index e5e7b9e..42a4afc 100644 --- a/packages/core/src/lifeRechargeAccountModel.ts +++ b/packages/core/src/lifeRechargeAccountModel.ts @@ -1,13 +1,20 @@ import { BlLifeRechargeAccountModelOptions } from './types'; -import { LifePayPhoneMesssageCodeLoginOutput } from './lifeRechargeServices'; +import { ChannelOutput } from './lifeRechargeServices'; +import { BlLifeRecharge } from './lifeRecharge'; -export class BlLifeRechargeAccountModel { +export class BlLifeRechargeAccountModel<TResponse = any, TRequestOptions = any> { + ctx: BlLifeRecharge<TResponse, TRequestOptions>; + userId = ''; phoneNumber = ''; channlesNum = ''; - constructor(options: BlLifeRechargeAccountModelOptions = {}) { + constructor( + ctx: BlLifeRecharge<TResponse, TRequestOptions>, + options: BlLifeRechargeAccountModelOptions = {} + ) { const { userId = '', phoneNumber = '', channlesNum } = options; + this.ctx = ctx; this.setUserId(userId); this.setPhoneNumber(phoneNumber); this.setChannlesNum(channlesNum); @@ -15,12 +22,42 @@ setUserId(userId: string) { this.userId = userId; + this.ctx.listener.fireEvent('update', this.ctx); + if (userId) { + this.getUserInfo(userId); + } + } + + async getUserInfo(userId: string) { + try { + let res = await this.ctx.services.lifePayUserMesssageByIduser( + { + id: userId, + }, + { + showLoading: false, + } + ); + this.ctx.isBackClientUser = res.isBackClientUser; + if (res && res.isBackClientUser) { + this.setUserChannles(res.channlesNum ?? []); + } + return res; + } catch (error) { + console.log('error: ', error); + } } setPhoneNumber(phoneNumber: string) { this.phoneNumber = phoneNumber; + this.ctx.listener.fireEvent('update', this.ctx); } setChannlesNum(channlesNum: string) { this.channlesNum = channlesNum; + this.ctx.listener.fireEvent('update', this.ctx); + } + setUserChannles(userChannles: ChannelOutput[]) { + this.ctx.userChannles = userChannles; + this.ctx.listener.fireEvent('update', this.ctx); } } -- Gitblit v1.9.1