WeChatPublic.js 2.71 KB
'use strict';

import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import {getSlicedUrl} from '../../../classify/utils/Utils';

const {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  ListView,
  Dimensions,
  TouchableOpacity,
} = ReactNative;


export default class WeChatPublic extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
		let {resource} = this.props;
        let data = resource?resource.toJS():null;
        let wechatAtten = data?data.wechatAtten:'';
        let wechatAttenSub = data?data.wechatAttenSub:'';
        let wechatCopy = data?data.wechatCopy:'';
        let error = data?data.error:'';

        if (!data || error) {
            return (<View style={{height:1,width:width,backgroundColor:'white'}}/>);
        }

		return (
			<View style={styles.container}>
				<View style={{width: width,height: 15,backgroundColor: '#e5e5e5',}}/>
				<View style={styles.subContainer}>
					<Image style={styles.icon} source={require('../../image/wechart.png')}/>
					<View style={styles.rightView}>
						<Text style={styles.rightTitle} numberOfLines={1}>
							{wechatAtten}
						</Text>
						<Text style={styles.rightDetail} numberOfLines={1}>
	                        {wechatAttenSub}
	                    </Text>
					</View>
				</View>
				<TouchableOpacity style={styles.button} activeOpacity={0.5} onPress={() => {
					this.props.onPressWeixin && this.props.onPressWeixin(wechatCopy);
				}}>
					<Text style={styles.buttonText} numberOfLines={1}>
						复制
					</Text>
				</TouchableOpacity>
                <View style={{width: width,height: 15,backgroundColor: '#e5e5e5',}}/>
			</View>
		);
    }
};

let {width, height} = Dimensions.get('window');
let backgroundHeight = 105;

let styles = StyleSheet.create({
	container: {
		width: width,
		height: backgroundHeight,
		backgroundColor: 'white',
	},
	subContainer: {
		width: width,
		height: backgroundHeight - 15 - 15,
		backgroundColor: 'white',
		flexDirection: 'row',
	},
	icon: {
		width: 60,
		height: 60,
		backgroundColor: 'white',
		marginTop: 10,
	},
	rightView: {
		width: width - 60,
		height: backgroundHeight - 15 - 15,
		backgroundColor: 'white',
	},
	rightTitle: {
        width: width - 60 - 40,
		fontSize: 14,
		fontWeight: 'bold',
		color: 'black',
		backgroundColor: 'white',
		marginTop: 17,
	},
	rightDetail: {
		fontSize: 13,
		color: 'gray',
		backgroundColor: 'white',
		marginTop: 10,
	},
	button: {
		position: 'absolute',
        right:  10,
        top: 32,
        width: 35,
        height: 18,
		backgroundColor: 'rgb(68, 68, 68)',
		justifyContent: 'center',
	},
	buttonText: {
		fontSize: 13,
		color: 'white',
		textAlign: 'center',
	}
});