This commit is contained in:
2026-08-05 18:24:41 +08:00
parent 4086b64fc0
commit 79562ecb5c
6 changed files with 83 additions and 57 deletions
+22 -10
View File
@@ -10,12 +10,12 @@ export interface WalletItem {
otpMode?: boolean;
}
const DEFAULT_DOMAIN = 'aa.pfgame.org';
const DEFAULT_DOMAIN = '192.168.1.117:16000';
const STORAGE_KEY = 'server_domain';
const HTTPS_KEY = 'server_https';
let _domain = DEFAULT_DOMAIN;
let _useHttps = true;
let _useHttps = false;
export async function loadServerDomain(): Promise<string> {
const saved = await AsyncStorage.getItem(STORAGE_KEY);
@@ -101,14 +101,26 @@ class Api {
}
public async register(walletType: WalletType, params: any, cardId?: string) {
const res = await fetch(`${Api.BASE_URL}/register`, {
method: 'POST',
headers: this.headers(),
body: JSON.stringify({ walletType, params, cardId }),
});
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data;
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 90000);
try {
const res = await fetch(`${Api.BASE_URL}/register`, {
method: 'POST',
headers: this.headers(),
body: JSON.stringify({ walletType, params, cardId }),
signal: controller.signal,
});
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data;
} catch (error: any) {
if (error?.name === 'AbortError') {
throw new Error('Bind request timed out. Please try again.');
}
throw error;
} finally {
clearTimeout(timeout);
}
}
public async requestOTP(walletType: WalletType, mobile: string, params: any = {}, cardId?: string) {