From 3bee6d9b65900080f453608e0dd7139793a9ad51 Mon Sep 17 00:00:00 2001 From: TQCasey <494294315@qq.com> Date: Sun, 10 May 2026 01:25:47 +0800 Subject: [PATCH] fix bugs --- components/OTPBindUI.tsx | 276 ++++++++++++++-------------- components/WalletBindComponents.tsx | 39 ++-- hooks/useOTPBind.ts | 2 - servers/walletman | 2 +- 4 files changed, 154 insertions(+), 165 deletions(-) diff --git a/components/OTPBindUI.tsx b/components/OTPBindUI.tsx index ffc8049..7c27d43 100644 --- a/components/OTPBindUI.tsx +++ b/components/OTPBindUI.tsx @@ -1,5 +1,12 @@ import React from 'react'; -import { View, TextInput, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native'; +import { + View, + TextInput, + TouchableOpacity, + Text, + StyleSheet, + ActivityIndicator, +} from 'react-native'; import { WalletType } from 'rnwalletman'; import { useOTPBind } from '../hooks/useOTPBind'; @@ -30,177 +37,170 @@ export const OTPBindUI: React.FC = ({ }) => { const [state, actions] = useOTPBind( walletType, - { - onRequestOTP, - onVerifyOTP, - onSuccess, - onError, - isDebug, - }, - { - otpLength, - mobileLength, - additionalParams, - } + { onRequestOTP, onVerifyOTP, onSuccess, onError, isDebug }, + { otpLength, mobileLength, additionalParams } ); - if (state.step === 'processing') { - return ( - - - 处理中... - - ); - } + const isLoading = state.loading || state.step === 'processing'; + const showOtp = state.step === 'otp' || state.step === 'processing'; return ( - - - {title} - - {state.step === 'mobile' && ( - <> - {state.errorMessage ? ( - {state.errorMessage} - ) : null} - { - actions.setMobile(text); - if (state.errorMessage) actions.clearError(); - }} - editable={!state.loading} - /> - - {state.loading ? ( - - ) : ( - 获取验证码 - )} - - - )} + + {title} - {state.step === 'otp' && ( - <> - 验证码已发送至 {state.mobile} - {state.errorMessage ? ( - {state.errorMessage} - ) : null} - { - actions.setOtp(text); - if (state.errorMessage) actions.clearError(); - }} - editable={!state.loading} - /> - - {state.loading ? ( - - ) : ( - 验证并绑定 - )} - - - 重新输入手机号 - - - )} - + {state.step === 'mobile' && ( + <> + {!!state.errorMessage && ( + {state.errorMessage} + )} + 手机号 + { + actions.setMobile(t); + if (state.errorMessage) actions.clearError(); + }} + editable={!isLoading} + /> + + {isLoading ? ( + + ) : ( + 获取验证码 + )} + + + )} + + {showOtp && ( + <> + 验证码已发送至 {state.mobile} + {!!state.errorMessage && ( + {state.errorMessage} + )} + 验证码 + { + actions.setOtp(t); + if (state.errorMessage) actions.clearError(); + }} + editable={!isLoading} + /> + + {isLoading ? ( + + ) : ( + 验证并绑定 + )} + + + + 重新输入手机号 + + + + )} ); }; const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: 'rgba(0,0,0,0.8)', - justifyContent: 'center', - alignItems: 'center', - }, - form: { - width: '80%', + card: { + width: '92%', backgroundColor: '#fff', - borderRadius: 10, - padding: 20, + borderRadius: 20, + padding: 28, + alignSelf: 'center', }, title: { - fontSize: 20, - fontWeight: 'bold', + fontSize: 22, + fontWeight: '700', textAlign: 'center', - marginBottom: 20, + color: '#111', + marginBottom: 24, + }, + label: { + fontSize: 13, + color: '#666', + marginBottom: 6, + fontWeight: '500', + }, + hint: { + fontSize: 14, + color: '#555', + textAlign: 'center', + marginBottom: 18, }, input: { - borderWidth: 1, - borderColor: '#ddd', - borderRadius: 5, - padding: 12, - fontSize: 16, - marginBottom: 15, + borderWidth: 1.5, + borderColor: '#e0e0e0', + borderRadius: 10, + paddingHorizontal: 14, + paddingVertical: 14, + fontSize: 17, + color: '#111', + marginBottom: 18, + backgroundColor: '#fafafa', }, inputError: { borderColor: '#ff3b30', + backgroundColor: '#fff8f7', }, errorText: { color: '#ff3b30', - fontSize: 14, - marginBottom: 10, + fontSize: 13, + marginBottom: 12, textAlign: 'center', + lineHeight: 18, }, - button: { + btn: { backgroundColor: '#007AFF', - borderRadius: 5, - padding: 15, + borderRadius: 12, + paddingVertical: 16, alignItems: 'center', + marginTop: 4, }, - buttonDisabled: { - backgroundColor: '#ccc', + btnDisabled: { + backgroundColor: '#a0c4ff', }, - buttonText: { + btnText: { color: '#fff', - fontSize: 16, - fontWeight: 'bold', + fontSize: 17, + fontWeight: '600', + letterSpacing: 0.3, }, - linkButton: { - marginTop: 10, + linkBtn: { + marginTop: 16, alignItems: 'center', + paddingVertical: 4, }, linkText: { color: '#007AFF', fontSize: 14, }, - hint: { - fontSize: 14, - color: '#666', - marginBottom: 10, - textAlign: 'center', - }, - processingText: { - color: '#fff', - fontSize: 16, - marginTop: 10, - }, }); diff --git a/components/WalletBindComponents.tsx b/components/WalletBindComponents.tsx index a1a9935..d39515a 100644 --- a/components/WalletBindComponents.tsx +++ b/components/WalletBindComponents.tsx @@ -128,7 +128,7 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe onError: (error: string) => void; isDebug: boolean; }) { - const [step, setStep] = useState<'credentials' | 'otp' | 'processing'>('credentials'); + const [step, setStep] = useState<'credentials' | 'otp'>('credentials'); const [mobile, setMobile] = useState(''); const [otp, setOtp] = useState(''); const [sessionId, setSessionId] = useState(''); @@ -153,30 +153,22 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe const handleVerifyOTP = async () => { if (!otp || otp.length !== 6) { setErrorMsg('请输入6位验证码'); return; } - setLoading(true); setErrorMsg(''); setStep('processing'); + setLoading(true); setErrorMsg(''); try { const res = await onVerifyOTP(WalletType.PAYTM_BUSINESS, { mobile, otp, sessionId }); log('VerifyOTP:', res); if (res.success) { onSuccess({ type: WalletType.PAYTM_BUSINESS, success: true, cookie: res.data?.cookie || '', xCsrfToken: res.data?.xCsrfToken || '', qrData: res.data?.qrData || [] }); } else { - const msg = res.message || 'Failed to verify OTP'; - setErrorMsg(msg); setStep('otp'); onError(msg); + setErrorMsg(res.message || 'Failed to verify OTP'); + setStep('otp'); } } catch (e) { - const msg = e instanceof Error ? e.message : 'Failed to verify OTP'; - setErrorMsg(msg); setStep('otp'); onError(msg); + setErrorMsg(e instanceof Error ? e.message : 'Failed to verify OTP'); + setStep('otp'); } finally { setLoading(false); } }; - if (step === 'processing') { - return ( - - - 处理中... - - ); - } return ( @@ -210,17 +202,16 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe const ptStyles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'rgba(0,0,0,0.8)', justifyContent: 'center', alignItems: 'center' }, - form: { width: '80%', backgroundColor: '#fff', borderRadius: 10, padding: 20 }, - title: { fontSize: 20, fontWeight: 'bold', textAlign: 'center', marginBottom: 20 }, - input: { borderWidth: 1, borderColor: '#ddd', borderRadius: 5, padding: 12, fontSize: 16, marginBottom: 15 }, - errorText: { color: '#ff3b30', fontSize: 14, marginBottom: 10, textAlign: 'center' }, - button: { backgroundColor: '#007AFF', borderRadius: 5, padding: 15, alignItems: 'center' }, - buttonDisabled: { backgroundColor: '#ccc' }, - buttonText: { color: '#fff', fontSize: 16, fontWeight: 'bold' }, - linkButton: { marginTop: 10, alignItems: 'center' }, + form: { width: '92%', backgroundColor: '#fff', borderRadius: 20, padding: 28 }, + title: { fontSize: 22, fontWeight: '700', textAlign: 'center', color: '#111', marginBottom: 24 }, + input: { borderWidth: 1.5, borderColor: '#e0e0e0', borderRadius: 10, paddingHorizontal: 14, paddingVertical: 14, fontSize: 17, color: '#111', marginBottom: 18, backgroundColor: '#fafafa' }, + errorText: { color: '#ff3b30', fontSize: 13, marginBottom: 12, textAlign: 'center' }, + button: { backgroundColor: '#007AFF', borderRadius: 12, paddingVertical: 16, alignItems: 'center', marginTop: 4 }, + buttonDisabled: { backgroundColor: '#a0c4ff' }, + buttonText: { color: '#fff', fontSize: 17, fontWeight: '600' }, + linkButton: { marginTop: 16, alignItems: 'center' }, linkText: { color: '#007AFF', fontSize: 14 }, - hint: { fontSize: 14, color: '#666', marginBottom: 10, textAlign: 'center' }, - processingText: { color: '#fff', fontSize: 16, marginTop: 10 }, + hint: { fontSize: 14, color: '#555', marginBottom: 18, textAlign: 'center' }, }); export class PhonePePersonalOTPBind extends Component<{ diff --git a/hooks/useOTPBind.ts b/hooks/useOTPBind.ts index 797f8ae..945bde8 100644 --- a/hooks/useOTPBind.ts +++ b/hooks/useOTPBind.ts @@ -125,14 +125,12 @@ export function useOTPBind( const msg = response.message || 'Failed to verify OTP'; setStep('otp'); setErrorMessage(msg); - onError(msg); } } catch (e) { error('Verify OTP error:', e); const msg = e instanceof Error ? e.message : 'Failed to verify OTP'; setStep('otp'); setErrorMessage(msg); - onError(msg); } finally { setLoading(false); } diff --git a/servers/walletman b/servers/walletman index 9f53b50..ad661b4 160000 --- a/servers/walletman +++ b/servers/walletman @@ -1 +1 @@ -Subproject commit 9f53b50a8017c8544af1b4acea06f5a1c411cd97 +Subproject commit ad661b4f697fc5ff3d85ba2f660902beb89294f6