123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- import React, { Component } from 'react'
- import {
- StyleSheet,
- View,
- Platform,
- Text,
- Dimensions,
- StatusBar,
- TouchableOpacity,
- PixelRatio
- } from 'react-native'
- import {WebView} from 'react-native-webview';
- import { connect } from 'react-redux'
- import Icon from '../../../components/Iconfont/Iconfont'
- import { ImageBaseUrl } from '../../../utils/fetch/Fetchx.js'
- import TopTab from '../../../components/toptab/TopTab'
- import { NavigationActions, ScaleUtil, createAction } from '../../../utils'
- import { compose } from 'redux'
- import { ReturnDate } from '../../../utils/utils'
- const { width, height } = Dimensions.get('window')
- @connect(({ theme }) => ({ ...theme }))
- class AnnounceDetail extends Component {
- constructor(props) {
- super(props)
- this.state = {}
- // console.disableYellowBox = true;
- }
- render() {
- console.log(WebView);
- const { appTheme } = this.props
- const { item } = this.props.navigation.state.params
- let html = item.content
- html = html
- ? html.replace(
- /src=\"\/g1\//g,
- `style="max-width:${width - 40}px; max-height:${height -
- 100}px;" src="${ImageBaseUrl}/g1/`
- )
- : ''
- let html5 = `<!DOCTYPE html> <meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"><html><head><meta charset="utf-8"></head><body>${html}</body></html>`
- return (
- <View
- style={[
- styles.container,
- { backgroundColor: appTheme.backgroundColor },
- ]}
- >
- <StatusBar
- animated={true}
- barStyle={appTheme.barStyle}
- // barStyle={"dark-content"}
- backgroundColor={'transparent'}
- translucent={true}
- />
- {/* 头部 */}
- <View
- style={{
- height: HEADERSTYLE.height,
- paddingTop: HEADERSTYLE.paddingTop + 5,
- backgroundColor: '#fff',
- borderBottomColor: '#eee',
- borderBottomWidth: 1 / PixelRatio.get(),
- }}
- >
- <View
- style={{
- flex: 1,
- justifyContent: 'center',
- }}
- >
- <TouchableOpacity
- style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
- onPress={() => this.props.dispatch(NavigationActions.back())}
- >
- <Icon
- name="icon-icon-fanhui"
- size={20}
- color={'#666'}
- style={{ marginTop: 4 }}
- />
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- color: '#666',
- alignSelf: 'center',
- }}
- >
- 返回
- </Text>
- </TouchableOpacity>
- <Text
- style={{
- alignSelf: 'center',
- fontSize: 18,
- lineHeight: 25,
- letterSpacing: 0.19,
- color: '#333',
- }}
- >
- 公告详情
- </Text>
- </View>
- </View>
- <View
- style={{
- flex: 1,
- paddingVertical: 10,
- paddingHorizontal: 20,
- backgroundColor: '#FFF',
- }}
- >
- <View>
- <Text
- style={{
- fontSize: 16,
- letterSpacing: 0.19,
- lineHeight: 22,
- color: '#333',
- fontWeight: '500',
- alignSelf: 'center',
- }}
- >
- {item.title}
- </Text>
- <Text
- style={{
- fontSize: 12,
- letterSpacing: 0.14,
- lineHeight: 17,
- marginTop: 10,
- color: '#999',
- }}
- >
- 发布时间:{ReturnDate(item.pubdate, true)}
- </Text>
- </View>
- <WebView
- domStorageEnabled={true}
- javaScriptEnabled={true}
- automaticallyAdjustContentInsets={true}
- mediaPlaybackRequiresUserAction={true}
- bounces={false}
- style={{
- width: width - 40,
- marginTop: 10,
- }}
- source={{ html: html5, baseUrl: '' }}
- scalesPageToFit={Platform.OS === 'ios' ? true : false}
- saveFormDataDisabled={true}
- contentInset={{ top: 0, left: 0, right: 0, bottom: 0 }}
- onNavigationStateChange={info => {
- this.setState({
- WebViewHeight: info.url.replace('about:blank%23', '') / 1,
- })
- }}
- />
- </View>
- </View>
- )
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- },
- })
- export default AnnounceDetail
|