CommonWebView.js
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from 'react'
import {StatusBar, StyleSheet, View, WebView} from 'react-native'
import {getFooterBottom} from "../utils/utils";
import {width} from "../utils/getSize";
import LoadingView from "../components/LoadingView";
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff'
},
tabIcon: {
height: 20,
width: 20,
},
text: {
fontSize: 20
}
})
export default class CommonWebView extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: true
};
this.url = this.props.navigation.state.params.url
}
componentWillMount() {
//设置头部
this.props.navigation.setParams({
isBack: true,
title: ''
});
}
render() {
return (
<View style={styles.container}>
<StatusBar barStyle={'default'} networkActivityIndicatorVisible/>
<WebView
originWhitelist={['*']}
bounces={false}
style={{flex: 1, backgroundColor: '#fff'}}
ref="webView"
source={{uri: this.url}}
mixedContentMode={'always'}
//onMessage={toNext}
injectedJavaScript={''}
javaScriptEnabled={true}
domStorageEnabled={true}
useWebKit={true}
onLoadEnd={v => {
this.setState({
loading: false
})
}}
/>
<View style={{width: width, height: getFooterBottom(), backgroundColor: '#fff'}}/>
{this.state.loading && <LoadingView/>}
</View>
)
}
}