Weixin.js
2.17 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
'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 (<View style={{height:1,width:width,backgroundColor:'white'}}/>);
}
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'}} />
</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'}} />
</View>
</TouchableOpacity>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
SmallImage: {
flexDirection: 'row',
flex: 1,
backgroundColor: '#e5e5e5'
},
thumb: {
}
});