1.remove demo web
This commit is contained in:
108
App.tsx
108
App.tsx
@@ -629,114 +629,8 @@ export default class App extends Component<AppProps, WalletmanAppState> {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
renderWebDemo() {
|
||||
const handleMessage = (event: any) => {
|
||||
try {
|
||||
const data = JSON.parse(event.nativeEvent.data);
|
||||
if (data.type === 'iframe_message') {
|
||||
console.log('[Demo] iframe message:', data.data);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[Demo] Parse error:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const syncToIframe = (fieldId: string, value: string) => {
|
||||
const js = `
|
||||
window.postMessage({
|
||||
type: 'set_field',
|
||||
fieldId: '${fieldId}',
|
||||
value: '${value.replace(/'/g, "\\'")}'
|
||||
}, '*');
|
||||
`;
|
||||
this.webViewRef?.injectJavaScript(js);
|
||||
};
|
||||
|
||||
const clickLogin = () => {
|
||||
const js = `window.postMessage({type: 'click_login'}, '*');`;
|
||||
this.webViewRef?.injectJavaScript(js);
|
||||
};
|
||||
|
||||
const injectedJS = `
|
||||
window.addEventListener('message', function(event) {
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({
|
||||
type: 'iframe_message',
|
||||
data: event.data
|
||||
}));
|
||||
});
|
||||
true;
|
||||
`;
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<WebView
|
||||
ref={(ref) => { this.webViewRef = ref; }}
|
||||
source={{ uri: 'https://dashboard.paytm.com' }}
|
||||
javaScriptEnabled={true}
|
||||
domStorageEnabled={true}
|
||||
thirdPartyCookiesEnabled={true}
|
||||
sharedCookiesEnabled={true}
|
||||
onMessage={handleMessage}
|
||||
injectedJavaScript={injectedJS}
|
||||
interceptUrlPattern="accounts.paytm.com/oauth-js-sdk/"
|
||||
interceptInjectedScript={`
|
||||
if (!window.__paytmMessageHandler) {
|
||||
window.__paytmMessageHandler = function(event) {
|
||||
if (event.data.type === 'set_field') {
|
||||
const el = document.getElementById(event.data.fieldId);
|
||||
if (el) {
|
||||
el.click();
|
||||
el.focus();
|
||||
el.value = event.data.value;
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
el.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
el.dispatchEvent(new Event('blur', { bubbles: true }));
|
||||
}
|
||||
}
|
||||
if (event.data.type === 'click_login') {
|
||||
const btn = document.getElementById('login_button');
|
||||
if (btn) btn.click();
|
||||
}
|
||||
};
|
||||
window.addEventListener('message', window.__paytmMessageHandler);
|
||||
window.parent.postMessage({type: 'iframe_ready'}, '*');
|
||||
}
|
||||
`}
|
||||
/>
|
||||
|
||||
<View style={{padding: 20, backgroundColor: '#f5f5f5', borderTopWidth: 1, borderTopColor: '#ddd'}}>
|
||||
<Text style={{fontSize: 16, fontWeight: 'bold', marginBottom: 10}}>Test Controls</Text>
|
||||
|
||||
<Text style={{marginTop: 5}}>Mobile:</Text>
|
||||
<TextInput
|
||||
style={{borderWidth: 1, borderColor: '#ccc', padding: 10, borderRadius: 5, backgroundColor: '#fff', marginTop: 5}}
|
||||
onChangeText={(text) => syncToIframe('email_mobile_login', text)}
|
||||
placeholder="Enter mobile number"
|
||||
keyboardType="phone-pad"
|
||||
/>
|
||||
|
||||
<Text style={{marginTop: 10}}>Password:</Text>
|
||||
<TextInput
|
||||
style={{borderWidth: 1, borderColor: '#ccc', padding: 10, borderRadius: 5, backgroundColor: '#fff', marginTop: 5}}
|
||||
onChangeText={(text) => syncToIframe('password_login', text)}
|
||||
placeholder="Enter password"
|
||||
secureTextEntry
|
||||
/>
|
||||
|
||||
<TouchableOpacity
|
||||
style={{marginTop: 15, backgroundColor: '#00BAF2', padding: 15, borderRadius: 5, alignItems: 'center'}}
|
||||
onPress={clickLogin}
|
||||
>
|
||||
<Text style={{color: '#fff', fontSize: 16, fontWeight: 'bold'}}>Login</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
// return this.renderWebDemo();
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{(() => {
|
||||
|
||||
Reference in New Issue
Block a user