This commit is contained in:
2026-05-23 12:23:47 +08:00
parent 7879cef91e
commit 73fa41007b
6 changed files with 164 additions and 30 deletions

View File

@@ -7,6 +7,7 @@ export interface WalletItem {
upi?: string;
phone?: string;
status?: string;
otpMode?: boolean;
}
const DEFAULT_DOMAIN = 'aa.pfgame.org';
@@ -54,6 +55,7 @@ class Api {
private static _instance: Api | null = null;
private userId: number = 0;
private userToken: string = '';
private constructor() {}
@@ -65,6 +67,10 @@ class Api {
return this.userId;
}
public getUserToken(): string {
return this.userToken;
}
public static get instance() {
if (Api._instance === null) {
Api._instance = new Api();
@@ -90,6 +96,7 @@ class Api {
const data = await res.json();
if (!data.success) throw new Error(data.message);
this.userId = data.data.userId;
this.userToken = data.data.userToken ?? String(data.data.userId);
return this.userId;
}
@@ -153,6 +160,17 @@ class Api {
return data.data?.vpa ?? '';
}
public async setWalletStatus(walletId: string, active: boolean): Promise<string> {
const res = await fetch(`${Api.BASE_URL}/wallet/set-status`, {
method: 'POST',
headers: this.headers(),
body: JSON.stringify({ walletId, active }),
});
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data.data?.status ?? '';
}
public async generateLink(walletId: string, amount: string): Promise<{ link: string; orderId: string }> {
const res = await fetch(`${Api.BASE_URL}/generate-link`, {
method: 'POST',