Comments.js
4.91 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import {getSlicedUrl} from '../../../classify/utils/Utils';
import YH_Image from '../../../common/components/YH_Image';
const {
AppRegistry,
StyleSheet,
Text,
View,
Image,
ListView,
Dimensions,
TouchableOpacity,
} = ReactNative;
export default class Comments extends React.Component {
constructor(props) {
super(props);
}
render() {
let {resource} = this.props;
console.log('ddddd');
console.log(resource.toJS());
let avator = resource?resource.get('avator'):'';
let username = resource?resource.get('username'):'';
let content = resource?resource.get('content'):'';
let isPraise = resource?resource.get('isPraise'):'N';
let praiseNum = resource&&resource.get('praiseNum') ? resource.get('praiseNum'):0;
praiseNum = praiseNum > 999 ? '999+' : praiseNum;
let id = resource?resource.get('id'):0;
let create_time = resource?resource.get('create_time'):'';
let relayTo = resource?resource.get('relayTo'):null;
let relayToUsername = relayTo?relayTo.get('username'):'';
let thumbsUpIcon = isPraise=='Y' ? require('../../image/g_z_ic_h.png') : require('../../image/g_z_ic.png');
let uid = resource? resource.get('uid'):'';
return (
<View style={styles.container}>
<View style={styles.rightContainer}>
<YH_Image url={avator} style={styles.icon}
radius={{'topLeft':'60','topRight':'60','bottomRight':'60','bottomLeft':'60'}}
masksToBounds={true} />
</View>
<View style={styles.leftContainer}>
<View style={styles.headerContainer}>
<Text style={styles.name} numberOfLines={1}>{username}</Text>
<TouchableOpacity onPress={()=>{
this.props.onThumbsUp&&this.props.onThumbsUp(id,isPraise=='Y'?'N':'Y', uid)
}}>
<View style={styles.thumbsUp}>
<Image style={styles.thumbsUpIcon} source={thumbsUpIcon}/>
<Text style={styles.thumbsUpNum} numberOfLines={1} >{praiseNum}</Text>
</View>
</TouchableOpacity>
<Text style={styles.time}>{create_time}</Text>
</View>
<View style={styles.commentView}>
<TouchableOpacity onPress={()=>{this.props.onPressComment&&this.props.onPressComment(id,username)}}>
{relayTo ? <Text style={styles.commentText}>
回复:<Text style={styles.replayName}>{relayToUsername}</Text>
:<Text style={styles.commentText}>{content}</Text>
</Text> : <Text style={styles.commentText}>{content}</Text>}
</TouchableOpacity>
</View>
<View style={styles.line}/>
</View>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
flexDirection: 'row'
},
rightContainer: {
width: 60,
backgroundColor: 'white',
},
leftContainer: {
flex: 1,
width: width - 60,
backgroundColor: 'white',
},
icon: {
height: 36,
width: 36,
borderRadius: 18,
position: 'absolute',
left: 14,
top: 8,
},
headerContainer: {
height: 50,
width: width - 60,
backgroundColor: 'white',
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-between',
},
name: {
textAlign: 'left',
backgroundColor: 'white',
fontSize: 15,
fontWeight: 'bold',
width: width - 60 - 100,
},
thumbsUp: {
height: 50,
width: 100,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'flex-end',
flexDirection: 'row',
marginRight: 10,
},
thumbsUpIcon: {
height: 24,
width: 24,
},
thumbsUpNum: {
marginLeft: 5,
textAlign: 'left',
backgroundColor: 'white',
fontSize: 12,
color: 'gray',
width: 35,
},
time: {
position: 'absolute',
textAlign: 'left',
backgroundColor: 'white',
fontSize: 11,
color: 'gray',
bottom: 0,
},
commentView: {
width: width - 60 - 10,
backgroundColor: 'white',
marginTop: 10,
},
commentText: {
textAlign: 'left',
backgroundColor: 'white',
fontSize: 15,
},
replayName: {
textAlign: 'left',
backgroundColor: 'white',
fontSize: 15,
fontWeight: 'bold',
},
line: {
marginTop: 15,
width: width-80,
height: 1,
backgroundColor: '#e0e0e0',
},
});