1
0
Fork 0
phizclip-react-native-demo/App.js

91 lines
2.5 KiB
JavaScript

/**
* Sample React Native App
*
* adapted from App.js generated by the following command:
*
* react-native init example
*
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Button } from 'react-native';
import MopSDK from 'react-native-mopsdk';
const onPressOpenCanvasApplet = () => {
MopSDK.openApplet('5e933835b795a5000199d547', '', '', (data) => { });
};
const onPressOpenDemoApplet = () => {
MopSDK.openApplet('5e4d123647edd60001055df1', '', '', (data) => { });
};
const onPressOpenProfileApplet = () => {
MopSDK.openApplet('5e637a18cbfae4000170fa7a', '', '', (data) => { });
};
export default class App extends Component<{}> {
state = {
status: 'starting',
message: '--'
};
componentDidMount() {
MopSDK.initialize({
appkey: '22LyZEib0gLTQdU3MUauASlb4KFRNRajt4RmY6UDSucA',
secret: '4a915e447bcbd439',
apiServer: 'https://mp.finogeeks.com',
apiPrefix: '/api/v1/mop'
}, (data) => {
console.log('message;', data);
const s = JSON.stringify(data);
this.setState({
status: 'native callback received',
message: s
});
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>FINMopsdk example</Text>
<Text style={styles.instructions}>STATUS: {this.state.status}</Text>
<Text style={styles.welcome}>NATIVE CALLBACK MESSAGE</Text>
<Text style={styles.instructions}>{this.state.message}</Text>
<Button
onPress={onPressOpenCanvasApplet}
title="打开画图小程序"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
<Button
onPress={onPressOpenDemoApplet}
title="打开官方小程序"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
<Button
onPress={onPressOpenProfileApplet}
title="打开智能对账单小程序"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});