WeChatPublic.js 2.54 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 null;
        }

		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>

		);
    }
};

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

let styles = StyleSheet.create({
	container: {
		width: width,
		height: backgroundHeight,
		backgroundColor: 'white',
	},
	subContainer: {
		width: width,
		height: backgroundHeight - 15,
		backgroundColor: 'white',
		flexDirection: 'row',
	},
	icon: {
		width: 60,
		height: 60,
		backgroundColor: 'white',
		marginTop: 10,
	},
	rightView: {
		width: width - 60,
		height: backgroundHeight,
		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: 'black',
		justifyContent: 'center',
	},
	buttonText: {
		fontSize: 13,
		color: 'white',
		textAlign: 'center',
	}
});