From e350d54243ad5497a418e50eab8d350be166a8f3 Mon Sep 17 00:00:00 2001 From: TQCasey <494294315@qq.com> Date: Tue, 26 May 2026 15:20:10 +0800 Subject: [PATCH] fix bugs --- screens/HomeScreen.tsx | 99 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/screens/HomeScreen.tsx b/screens/HomeScreen.tsx index fa48070..33b1520 100644 --- a/screens/HomeScreen.tsx +++ b/screens/HomeScreen.tsx @@ -36,6 +36,8 @@ import { FreechargePersonalBind, SmsMessage, proxyBackgroundService, + PhonePePersonalBindResult, + PaytmPersonalBindResult, } from 'rnwalletman'; import { @@ -416,6 +418,7 @@ export default class HomeScreen extends Component { this.setState({ [key]: false, bindPrefillMobile: '' } as any); if (showPaytmPersonalBind && paytmPersonalBindType === 'tokenMode') { + const remoteVersion = '1'; // 目前版本是 1 return ( { { Alert.alert('Bind Failed', e); close('showPaytmPersonalBind')(); }} + onSuccess={(result: PaytmPersonalBindResult) => { + if (result.chType != 'ipay') { + // 有 AIDL 通信,能拿回数据,但是不是我们的魔改 type + // 视作未安装 + Alert.alert('Bind Failed', '未安装Paytm 魔改包,需要重新安装'); + return; + } + if (result.chVersion != remoteVersion) { + // 版本有更新 + Alert.alert('Bind Failed', '版本有更新,需要重新安装'); + return; + } + + // 实际请求注册钱包 + this.handleBindSuccess('showPaytmPersonalBind', WalletType.PAYTM_PERSONAL, 'Paytm Personal bound successfully')(result); + }} + onError={(code: string, message: string) => { + switch (code) { + case 'NATIVE_MODULE_UNAVAILABLE': // 没有模块 + Alert.alert('Bind Failed', 'Native module not available'); + break; + case 'NOT_LOGGED_IN': // 未登录,提示用户登录 + Alert.alert('Bind Failed', 'Please login in paytm app first'); + break; + case 'ERROR': // catch 错误,提示错误即可 + Alert.alert('Bind Failed', message); + break; + case 'NO_DATA': // 拿到了错误的信息,提示错误就可以 (aidl 给了错误的 resp,几率低),提示错误就可以 + Alert.alert('Bind Failed', 'No data received from Paytm'); + break; + case 'SERVICE_DISCONNECTED': // 服务不可用 (可能aidl 通信失败,几率低)提示错误就可以 + Alert.alert('Bind Failed', 'Paytm service disconnected'); + break; + case 'NOT_INSTALLED': // 未安装,提示用户安装 + Alert.alert('Bind Failed', '未安装Paytm 魔改包,需要重新安装'); + break; + case 'BIND_ERROR': // 绑定错误,aidl 通信失败,可能存在 paytm 未打开的情况,出现这个,手动拉起一下 + Alert.alert('Bind Failed', 'Paytm bind error'); + break; + default: + Alert.alert('Bind Failed', `[${code}] ${message}`); + break; + } + close('showPaytmPersonalBind')(); + }} /> ); @@ -454,6 +500,7 @@ export default class HomeScreen extends Component { ); } if (showPhonePePersonalBind && phonePePersonalBindType === 'tokenMode') { + const remoteVersion = '1'; // 目前版本是 1 return ( { processString="Processing..." userToken={Api.instance.getUserToken()} isDebug - onSuccess={this.handleBindSuccess('showPhonePePersonalBind', WalletType.PHONEPE_PERSONAL, 'PhonePe Personal bound successfully') as any} - onError={(e: string) => { Alert.alert('Bind Failed', e); close('showPhonePePersonalBind')(); }} + onSuccess={(result: PhonePePersonalBindResult) => { + if (result.chType != 'ipay') { + // 有 AIDL 通信,能拿回数据,但是不是我们的魔改 type + // 视作未安装 + Alert.alert('Bind Failed', '未安装Phonepe 魔改包,需要重新安装'); + return; + } + if (result.chVersion != remoteVersion) { + // 版本有更新 + Alert.alert('Bind Failed', '版本有更新,需要重新安装'); + return; + } + + // 实际请求注册钱包 + this.handleBindSuccess('showPhonePePersonalBind', WalletType.PHONEPE_PERSONAL, 'PhonePe Personal bound successfully')(result); + }} + onError={(code: string, message: string) => { + + switch (code) { + case 'NOT_INSTALLED': + // 未安装 + Alert.alert('Bind Failed', '未安装Phonepe 魔改包,需要重新安装'); + break; + case 'SERVICE_DISCONNECTED': + // 服务不可用 (可能aidl 通信失败,几率低)提示错误就可以 + Alert.alert('Bind Failed', '服务不可用'); + break; + case 'NO_DATA': + // 拿到了错误的信息,提示错误就可以 (aidl 给了错误的 resp,几率低),提示错误就可以 + Alert.alert('Bind Failed', '未知错误信息'); + break; + case 'BIND_ERROR': + // 绑定错误,aidl 通信失败,可能存在 paytm / phonepe 未打开的情况,出现这个,手动拉起一下 + Alert.alert('Bind Failed', '绑定失败,请手动打开PhonePe后重试'); + break; + case 'ERROR': + // catch 错误,通用错误,提示错误即可 + Alert.alert('Bind Failed', message); + break; + default: + Alert.alert('Bind Failed', '未知错误'); + break; + } + + close('showPhonePePersonalBind')(); + }} /> );