ContentMessageCell.js
8.66 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
* Created by zzz on 2019/3/12.
*/
'use strict';
import React, {Component} from 'react';
import {Dimensions, Image, StyleSheet, Text, TouchableOpacity, View, NativeModules} from 'react-native';
import ListView from 'deprecated-react-native-listview'
import {Immutable} from "immutable";
import YH_Image from '../../../common/components/YH_Image';
export default class ContentMessageCell extends Component {
constructor(props) {
super(props);
}
render() {
let {rowData} = this.props;
let status = rowData.businessType === 1003 ? true : false;
let resource = rowData.coverImg ? typeof rowData.coverImg === 'string' ? JSON.parse(rowData.coverImg) : rowData.coverImg : '';
let picItem = resource ? typeof resource.data === 'string' ? JSON.parse(resource.data) : resource.data : '';
let imageUrl = YH_Image.getSlicedUrl(picItem.src, 50 * DEVICE_HEIGHT_RATIO, 50 * DEVICE_HEIGHT_RATIO, 2);
let userName = rowData.userName;
let subName = rowData.businessType === 1002 ? '评论了你' : '回复了你';
let showIcon = (rowData.authGroupId === 3 || rowData.authGroupId === 5 || rowData.authGroupId === 7 || rowData.authGroupId === 11) ? true : false;
let source;
switch (rowData.authGroupId) {
case 3:
source = require('../../images/GF_big_ic.png');
break;
case 5:
source = require('../../images/PP_big_ic.png');
break;
case 7:
source = require('../../images/KING_big_ic.png');
break;
case 11:
source = require('../../images/DR_big_ic.png');
break;
default:
}
return (
<View>
<View style={styles.headerBackground}>
<TouchableOpacity style={{marginLeft: 15, marginRight: 10, flexDirection: 'row'}} activeOpacity={1}
onPress={() => this.props.jumpToPersonalGrassPage && this.props.jumpToPersonalGrassPage(rowData)}>
<YH_Image style={styles.headIcon} url={rowData.headIco} circle={true}/>
{showIcon ? <Image style={styles.iconImage} resizeMode="contain" source={source}/> : null}
</TouchableOpacity>
<View style={styles.textView}>
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.jumpToPersonalGrassPage && this.props.jumpToPersonalGrassPage(rowData)}>
<Text style={styles.nicknameText} numberOfLines={1}>{userName}</Text>
</TouchableOpacity>
<Text style={styles.subnameText}>{subName}</Text>
</View>
<TouchableOpacity activeOpacity={1} style={styles.replyContainer}
onPress={() => this.props.jumpToShowKeyboard && this.props.jumpToShowKeyboard(rowData)}>
<Image style={styles.replyImage} resizeMode="contain"
source={require('../../images/content_reply.png')}/>
</TouchableOpacity>
</View>
<View style={styles.replyTextView}>
<Text style={styles.replyText} numberOfLines={2}>{rowData.commentContent}</Text>
</View>
{status ?
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.jumpToGrassDetailPage && this.props.jumpToGrassDetailPage(rowData)}>
<View style={styles.ownerReplyView}>
<Text style={{paddingLeft: 10, paddingTop: 14, paddingRight: 1, paddingBottom: 12}}
numberOfLines={3}>
<Text style={styles.replyText}>我的评论:</Text>
<Text style={styles.defaultReplyText}>{rowData.parentCommentContent}</Text>
</Text>
</View>
</TouchableOpacity>
:
<TouchableOpacity activeOpacity={1}
onPress={() => this.props.jumpToGrassDetailPage && this.props.jumpToGrassDetailPage(rowData)}>
{rowData.isDelete === 'N' ?
<View style={styles.originContainerView}>
<Text style={styles.copyText}>原文</Text>
{imageUrl ? <YH_Image url={imageUrl} style={styles.imageStyle}/> : null}
{rowData.content ?
<Text style={styles.originText} numberOfLines={1}>
<Text>{rowData.content}</Text>
<Text>{'...'}</Text>
</Text>
:
<View style={{height: 5}}/>
}
</View>
:
<View style={styles.originContainerView}>
<Text style={styles.deleteText} numberOfLines={1}>{'原文已被作者删除'}</Text>
</View>
}
</TouchableOpacity>}
<View style={styles.timeView}>
<Text style={styles.startTimeText}>{rowData.createTime}</Text>
</View>
{this.props.showLine ? <View style={styles.lineView}/> : null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 375;
const DEVICE_HEIGHT_RATIO = height / 667;
let styles = StyleSheet.create({
headerBackground: {
width: width,
height: 70,
backgroundColor: 'white',
flexDirection: 'row',
},
headIcon: {
width: 40,
height: 40,
marginTop: 15,
overflow: 'hidden',
borderRadius: 20,
},
iconImage: {
width: 16,
height: 16,
marginLeft: -12,
marginTop: 42,
},
textView: {
flexDirection: 'column',
justifyContent: 'space-between',
alignItems: 'flex-start',
marginTop: 18,
marginBottom: 15,
},
nicknameText: {
fontSize: 14,
fontFamily: 'PingFang-SC-Medium',
color: '#222222',
width: width / 2,
},
subnameText: {
fontSize: 12,
fontFamily: 'PingFang-SC-Regular',
color: '#B0B0B0',
},
replyContainer: {
position: 'absolute',
top: 23,
right: 15,
width: 60,
height: 25,
},
replyImage: {
width: 60,
height: 25,
},
replyTextView: {
width: width - 30,
marginBottom: 15,
marginLeft: 15,
},
replyText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#444444',
},
ownerReplyView: {
flexDirection: 'row',
alignItems: 'center',
width: width - 30,
marginLeft: 15,
backgroundColor: '#F0F0F0',
marginBottom: 10,
},
defaultReplyText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#a8a8a8',
},
originContainerView: {
flex: 1,
marginLeft: 15,
marginRight: 15,
marginBottom: 10,
backgroundColor: '#f0f0f0'
},
copyText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#444444',
marginTop: 10,
marginLeft: 9,
},
imageStyle: {
marginTop: 10,
marginBottom: 4,
marginLeft: 9,
width: 50 * DEVICE_HEIGHT_RATIO,
height: 50 * DEVICE_HEIGHT_RATIO,
},
originText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#b0b0b0',
marginLeft: 9,
marginRight: 16,
marginBottom: 9,
},
deleteText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#b0b0b0',
marginLeft: 9,
marginRight: 16,
marginTop: 10,
marginBottom: 10
},
timeView: {
alignItems: 'flex-start',
marginBottom: 10,
marginLeft: 15,
},
startTimeText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#B0B0B0',
height: 17
},
lineView: {
marginLeft: 15,
marginRight: 0,
width: width - 15,
height: 0.5,
backgroundColor: '#e0e0e0'
},
});