Weixin.js 2.13 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 Weixin extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
		let {resource} = this.props;

		let data = resource.get('data') ? resource.get('data').toJS() : null;
        if (!data) {
            return null;
        }

		let url1 = data.length>0?data[0].src:null;
		let url2 = data.length>1?data[1].src:null;
        let text1 = data.length>0?data[0].wechat_id:null;
		let text2 = data.length>1?data[1].wechat_id:null;

		if (!url1 || !url2) {
			return null;
		}
		let url3 = getSlicedUrl(url1, 640, 640, 2);
		let url4 = getSlicedUrl(url2, 640, 640, 2);

		return (
			<View style={styles.SmallImage}>
                <TouchableOpacity activeOpacity={0.5} onPress={() => {
    				this.props.onPressWeixin && this.props.onPressWeixin(text1);
    			}}>
                    <View style={{width: width/2-30,height: 100,marginLeft: 20,backgroundColor:'transparent',marginTop: 20,marginBottom: 20}}>
    				    <Image source={{uri: url3}} style={{width: width/2-30,height: 100,backgroundColor:'transparent'}} ></Image>
                    </View>
                </TouchableOpacity>
                <TouchableOpacity activeOpacity={0.5} onPress={() => {
                    this.props.onPressWeixin && this.props.onPressWeixin(text2);
                }}>
                    <View style={{width: width/2-30,height: 100,marginLeft: 10,backgroundColor:'transparent',marginTop: 20,marginBottom: 20}}>
    				    <Image source={{uri: url4}} style={{width: width/2-30,height: 100,marginLeft: 10,backgroundColor:'transparent'}} ></Image>
                    </View>
                </TouchableOpacity>
			</View>
		);
    }
};

let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
	SmallImage: {
		flexDirection: 'row',
		flex: 1,
		backgroundColor: '#e5e5e5'
	},
	thumb: {

	}
});