From e372854c71bc97d162452cc4b3f5cfa586da50a8 Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期四, 22 五月 2025 17:06:31 +0800 Subject: [PATCH] feat: UI --- packages/core/src/lifeRechargeAccountModel.ts | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lifeRechargeAccountModel.ts b/packages/core/src/lifeRechargeAccountModel.ts index e5e7b9e..45a7dfd 100644 --- a/packages/core/src/lifeRechargeAccountModel.ts +++ b/packages/core/src/lifeRechargeAccountModel.ts @@ -1,13 +1,24 @@ 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 = {}) { + /**鐢ㄦ埛鎵�鏈夌殑娓犻亾 */ + userChannles = [] as ChannelOutput[]; + isBackClientUser: boolean; + + 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 +26,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 || this.userId, + }, + { + showLoading: false, + } + ); + this.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.userChannles = userChannles; + this.ctx.listener.fireEvent('update', this.ctx); } } -- Gitblit v1.9.1