CommentRrise.js
9.06 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 Cassie on 2018/05/14
* 图文详情-评论点赞
*/
import React, {Component} from 'react';
import {FlatList,ActivityIndicator, Image, StatusBar, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {zoomH, zoomW} from '../../utils/getSize';
import {getHeaderPadding,xnToast} from '../../utils/utils';
import AppService from "../../service/AppService";
const defaultIcon = require('../../img/defaultIcon.png');
const vIcon = require('../../img/v.png');
const prise = require('../../img/prise.png');
const writeIcon = require('../../img/writeIcon.png');
const emj = require('../../img/emj.png');
const forwarding = require('../../img/forwarding.png');
const reward = require('../../img/reward.png');
const back = require('../../img/back.png');
const pageSize = 20;
export default class CommentPrise extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
header:null,
});
constructor(props){
super(props);
this.state = {
praiseList:[],//点赞人数集合
loadMore:false,
loading:false,
};
};
componentWillMount(){
this.getPriseList();
};
componentDidMount(){
};
//获取赞列表
getPriseList (){
if (!global.isConnected){
xnToast('暂无网络连接,请稍后重试!');
return;
}
let length = this.state.praiseList.length;
if (length % pageSize == 0 && !this.state.loadMore) {
let data = this.props.navigation.state.params.detailInfo;
let params = {
tenantId:global.tenantId,//承租人ID
forumId:data.forumId,//社区id
boardId:data.boardId,//板块id
threadId:data.threadId,//帖子id
targetType: 1,//点赞类型0:帖子点赞 1:评论点赞 2:回复点赞 3:转发点赞
targetId:data.id,//点赞对象ID
isActive:true,
pageNumber:length/pageSize+1,
pageSize : pageSize,
};
this.setState({
loadMore: true,
loading:true,
});
AppService.queryLike(params).then((data) => {
this.setState({
loadMore: false,
loading:false,
});
if (data.message) {
xnToast(data.message);
return;
}
if (data.errors.length > 0) {
xnToast(data.errors[0].message);
} else {
if (length + data.result.length > data.totalCount) {
return;
}
this.setState({
praiseList:this.state.praiseList.concat(data.result),
})
}
}).catch((error) => {
this.setState({
loadMore: false,
loading:false,
});
xnToast(error)
})
}
};
//去个人详情页面
toPersonalInfo(id){
if (id == global.userId){
//自己
this.props.navigation.navigate("MyPage",{id:id});
return;
}
this.props.navigation.navigate('PersonalHomePage',{'userId':id});
}
//渲染评论item
keyExtractor = (item,index) => index;
renderItem({item,index}){
return (
<TouchableOpacity style = {{paddingLeft:15/zoomW,paddingTop:10/zoomH,paddingBottom:10/zoomH}}
onPress = {()=>{this.toPersonalInfo(item.likeUserId)}}>
<View style={{flexDirection:'row',alignItems:'center'}}>
<View style={styles.commonAvatar} >
<Image style={styles.commonAvatar} source={!!item.userExtend && !!item.userExtend.avatar
?{uri:item.userExtend.avatar +'?x-oss-process=image/resize,w_100'} :defaultIcon} resizeMode="cover" />
{!!item.userExtend && !!item.userExtend.isAuthented &&<Image style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />}
</View>
<View style = {{width:'100%',flex:1,paddingLeft:10/zoomW,paddingRight:10/zoomW}}>
<View style = {{flexDirection:'row'}}>
<Text style = {{fontSize: 16,color:'#000000'}}>{item.likeUserName}</Text>
{/*暂时隐藏作者*/}
{ 1==2 && this.props.navigation.state.params.userId == item.likeUserId &&
<Text style = {{fontSize: 10,color:'#576B95',borderColor:'#576B95',borderWidth:StyleSheet.hairlineWidth,borderRadius:2,
paddingLeft:5,paddingRight:5,alignSelf:'center',marginLeft:5/zoomW}}>作者</Text>
}
</View>
{ !!item.userExtend && <Text style = {{fontSize: 12,color:'#c3c3c3'}}>{item.userExtend.agentName}</Text>}
</View>
</View>
<View style = {[styles.commonDividerLine,{marginTop:20/zoomH,marginLeft:46/zoomW}]}></View>
</TouchableOpacity>
);
}
render(){
return(
<View style={styles.background}>
<StatusBar
backgroundColor={'#B0B1B1'}
networkActivityIndicatorVisible
/>
<View style = {{height:getHeaderPadding(),backgroundColor:'#ffffff'}}>
</View>
<View style = {styles.backgroundRadius}>
{/*头部*/}
<View style = {{flexDirection:'row',alignItems:'center',height:48/zoomH}}>
<View style={{width:'100%',flexDirection:'row',justifyContent:'center'}}>
<Text style = {{flex:1,color:'rgba(0,0,0,0.85)', textAlign: "center",
alignSelf: "center",fontSize:16}}>{ this.props.navigation.state.params.length +'人点赞'}</Text>
</View>
<TouchableOpacity style = {{position:'absolute',padding:15/zoomW}} activeOpacity={0.8} onPress = {()=>{this.props.navigation.goBack()}}>
<Image style = {{width:15/zoomW,height:15/zoomW}} resizeMode='contain' source={back}></Image>
</TouchableOpacity>
</View>
<View style = {styles.commonDividerLine}></View>
<FlatList refreshing={false}
onEndReachedThreshold={0.01}
onEndReached={() => this.getPriseList()}
keyExtractor={this.keyExtractor}
data={this.state.praiseList}
renderItem={this.renderItem.bind(this)}/>
{/*局部loading*/}
{ this.state.loading && (
<View style={styles.loadingBg}>
<View style={styles.loadingBox}>
<ActivityIndicator size="large" color="#fff" />
<Text
style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
>
加载中...
</Text>
</View>
</View>
)}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
background:{
flex: 1,
backgroundColor: 'rgba(0,0,0,0.50)',
},
backgroundRadius:{
flex: 1,
backgroundColor: '#ffffff',
borderTopLeftRadius:5,
borderTopRightRadius:5,
borderColor:'rgba(0,0,0,0.50)',
borderWidth:1,
},
commonSpaceBetween:{
flexDirection:'row',
justifyContent:'space-between',
},
commonRow:{
flexDirection:'row',
paddingLeft:15/zoomW,
paddingRight:15/zoomW,
},
commonAvatar:{
width:36/zoomH,
height:36/zoomH,
borderRadius:18/zoomH,
},
commonAvatarV:{
width:10/zoomH,height:10/zoomH,position:'absolute',right:1/zoomW,bottom:1/zoomW
},
itemBackground:{
width:'100%',
flex:1,
padding: 10/zoomH,
flexDirection :'row',
marginBottom:10/zoomW
},
commonDividerLine:{
width:'100%',
height:StyleSheet.hairlineWidth,
backgroundColor:'#eeeeee'
},
loadingBg: {
position: "absolute",
top: 0,
width: "100%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center"
},
loadingBox: {
width: 100 / zoomW,
height: 120 / zoomH,
backgroundColor: "rgba(0,0,0,.5)",
borderRadius: 8,
display: "flex",
alignItems: "center",
justifyContent: "center"
},
});