| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import React, { Component } from 'react';
- import { View, Text, StyleSheet } from 'react-native';
- import * as Progress from 'react-native-progress';
- import WebView from 'react-native-webview';
- import Dialog from '../../components/Dialog';
- import { PageList } from '../Router';
- export default class CreditCard extends Component {
- constructor(props) {
- super(props);
- this.state = {
- url: 'http://161.117.183.142/juiceplus/cardCancelPage.html',
- url2: 'http://baidu.com',
- progress: 0
- };
- }
- componentDidMount() {
- if (this.props.route.params.url) {
- this.setState({
- url: this.props.route.params.url
- });
- }
- }
- onPostMessage(data) {
- startPage(PageList.topup);
- /*if (data) {
- try {
- const msg = JSON.parse(data);
- if (msg.msg) {
- Dialog.showResultDialog(msg.msg, 'OK', back => {
- startPage(PageList.topup);
- });
- }
- } catch (error) {
-
- }
- console.log('WebviewMessage', data)
- }*/
- }
- render() {
- return (
- <View style={styles.container}>
- <Progress.Bar
- style={styles.progress}
- width={$vw(100)}
- height={2}
- color={colorPrimaryDark}
- borderWidth={0}
- borderRadius={0}
- progress={this.state.progress}/>
- <WebView
- style={ui.flex1}
- source={{ uri: this.state.url}}
- mixedContentMode={'always'}
- applicationNameForUserAgent={'juiceplus/1.0'}
- onLoadProgress={({nativeEvent}) => this.setState({ progress: nativeEvent.progress }) }
- onLoadEnd={(e) => {
- //console.log('webview-end', e)
- this.setState({ progress: 0 })
- }}
- onMessage={e => this.onPostMessage(e.nativeEvent.data)}/>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1
- },
- progress: {
- top: 0,
- left: 0,
- position: 'absolute',
- }
- })
|