atlasAdController.js
5.18 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// atlasAdController.js
//
// Created by Cheney Mars on 2018/9/26.
// Copyright © 2018年 saygoodlolita. All rights reserved.
//
import React, {Component} from 'react';
// 系统组件
import {Image, ScrollView, TouchableOpacity, View} from 'react-native';
import MyWebView from "react-native-webview-autoheight";
import {zoomW} from "../../utils/getSize";
const defaultIcon = require("../../img/defaultIcon.png");
// 可供外界调用的类
export default class atlasAdController extends Component {
constructor(props) {
super(props);
}
static navigationOptions = ({ navigation, screenProps }) => ({
headerTitle: "广告",
headerLeft: (
<View style={{ flexDirection: "row", flex: 1 }}>
<TouchableOpacity
style={{
flexDirection: "column",
justifyContent: "center",
paddingRight: 15,
paddingLeft: 10
}}
onPress={
navigation.state.params ? navigation.state.params.back : null
}
>
<Image
source={require("../../img/loadBack.png")}
resizeMode="contain"
/>
</TouchableOpacity>
</View>
),
headerRight: (
<View style={{ flexDirection: "row", flex: 1, justifyContent: "center" }}>
<TouchableOpacity
style={{
flexDirection: "column",
justifyContent: "center",
paddingRight: 15,
paddingLeft: 10
}}
>
<Image
style={{ width: 20 / zoomW, height: 20 / zoomW }}
resizeMode="contain"
/>
</TouchableOpacity>
</View>
)
});
componentDidMount() {
//设置头部
this.props.navigation.setParams({
back: () => {
this.props.navigation.goBack();
}
});
}
render() {
let url = this.props.navigation.state.params.adLink;
if(url.indexOf('http://') == -1 && url.indexOf('https://') == -1){
url = "http://" + url;
}
return (
<View style={{flex:1}}>
<ScrollView style= {{width:'100%',flex:1,backgroundColor:'#fff'}}>
<MyWebView
style= {{width:'100%',flex:1}}
source={{uri: url}}
startInLoadingState={true}
/>
</ScrollView>
</View>
);
}
}