优化
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user