ItemHeaderInfo.js
9.21 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
import React, {Component} from 'react';
import {DeviceEventEmitter, Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {zoomH, zoomW} from '../../utils/getSize';
import {dateToMsgTime, NoDoublePress,xnToast} from '../../utils/utils';
import AppService from "../../service/AppService";
import StashHead from '../../widget/StashHead';
import {scaleHeight, scaleSize, setSpText} from "../../utils/ScreenUtil";
import ActionSheet from "react-native-actionsheet-api";
//图片资源
const defaultIcon = require('../../img/defaultIcon.png');
const vIcon = require('../../img/v.png');
/**
* 图集列表item 中个人信息部分
* 调用者需要传入的参数 personInfoData : 个人信息数据源
*/
export default class itemHeaderInfo extends Component {
// 构造
constructor(props) {
super(props);
// 初始状态
this.state = {
loading:false
};
}
//点击事件,跳到个人详情
_onPress(){
NoDoublePress.onPress(()=>{
let id = this.props.itemList.threadUserId;
if (id == global.userId) {
//自己
this.props.nav.navigate("MyPage", { id: id,});
return;
}
this.props.nav.navigate('PersonalHomePage',{userId:id})
})
};
// TODO:这是为了应付苹果审核做的假的举报拉黑功能
reportClick = ()=>{
let _this = this;
ActionSheet.showActionSheetWithOptions({
options: [ '举报内容违规','举报内容作者骚扰', '屏蔽该内容作者', '取消'],
cancelButtonIndex:3,
tintColor: global.homeColor,
},
(buttonIndex) => {
if (buttonIndex == 0) {
xnToast('举报成功,平台将会在24小时之内给出内容评审结果');
}
if (buttonIndex == 1) {
xnToast('举报成功,平台将会在24小时之内给出内容作者行为审核结果');
}
if (buttonIndex == 2) {
xnToast('屏蔽成功,平台将不再向您推送该用户发布的内容');
if (_this.props.reportCallback != undefined){
_this.props.reportCallback(buttonIndex);
}
}
}
);
}
//点击事件
_followClick = ()=>{//关注
NoDoublePress.onPress(()=>{
var data = this.props.itemList;
if (!global.isConnected){
xnToast('暂无网络连接,请稍后重试!');
return;
}
let params = {
forumId:data.forumId,//社区id
targetType:1,//关注对象类型,目前固定1:社区用户
targetUserId:data.threadUserId,//被关注者用户ID
targetUserName:data.threadUserName,//被关注者用户名称
attentionUserId: global.userId,//自己的id
attentionUserName:global.userName,//自己的名字
};
console.log(params);
AppService.attention(params).then((data) => {
this.setState({
loading: false
});
if (data.message) {
xnToast(res.message);
return;
}
if (!!data.errors === true && !!data.errors.length > 0) {
xnToast(data.errors[0].message);
} else {
xnToast('已关注');
//通知列表刷新
DeviceEventEmitter.emit('refreshHomeList');
DeviceEventEmitter.emit('refreshAllList');
DeviceEventEmitter.emit('reGetThreadDetailInfo');
DeviceEventEmitter.emit('refreshHomeHistory');
DeviceEventEmitter.emit('refreshCollectList');
DeviceEventEmitter.emit('refreshAttention');
}
}).catch((error) => {
this.setState({
loading: false
});
xnToast(error)
})
})
};
//时间和认证省份信息显示
getTimeAndIndentity(itemList){
let time = dateToMsgTime(itemList.creationTime);
let identity = !!itemList.user && !!itemList.user.agentName?itemList.user.agentName:'';
if (identity != ''){
return time + ' · ' + identity;
}
return time;
}
//获取帖子类型
getThreadTypeStr(){
let threadType = this.props.itemList.threadType;
let str = "文章";
switch (threadType){
case 0:
str = "图文";
break;
case 1:
str = "图集";
break;
case 2:
str = "视频";
break;
case 3:
str = "问答";
break;
case 4:
str = "文章";
break;
case 5:
str = "课程";
break;
default:
break
}
return str;
}
//个人信息
render() {
return (
<View style = {{width:'100%',flexDirection:'row',alignItems:'center',paddingLeft:scaleSize(14), marginTop:scaleHeight(14), paddingRight:scaleSize(14),backgroundColor:'#ffffff'}} >
<TouchableOpacity style={styles.avatar} onPress = {()=>{this._onPress()}}>
<Image style={styles.avatar}
source={!!this.props.itemList.threadUserHeadFileUrl?{uri: this.props.itemList.threadUserHeadFileUrl +'?x-oss-process=image/resize,w_100'}
:defaultIcon} resizeMode="cover" />
{!!this.props.itemList.user && !!this.props.itemList.user.isAuthented &&
<Image style={styles.avatarV} source={vIcon} resizeMode="cover" />}
</TouchableOpacity>
<View style = {{width : '100%',flex:1,display:'flex',marginLeft:8/zoomW}}>
<View style = {{width : '100%',flex:1,flexDirection:'row',justifyContent:'space-between',alignItems:'center'}}>
<View style = {{flexDirection:'column'}}>
<View style = {{flexDirection:'row',alignItems:'center'}}>
<Text style = {[styles.userNameBlack]} numberOfLines = {1}>{this.props.itemList.threadUserName}</Text>
{this.props.itemList.isHot&& <Image style={{width:14,height:14,marginLeft:5}} resizeMode={'contain'} source={require('../../img/hot.png')}></Image>}
{this.props.showReport && <TouchableOpacity activeOpacity={0.8} onPress = {()=>{this.reportClick()}}>
<Text style = {[styles.reportStyle]} numberOfLines = {1}>{' 举报 '}</Text>
</TouchableOpacity>}
</View>
<View style={{flexDirection:'row', marginTop:5}}>
{ ! this.props.hideTop && this.props.itemList.isBoardTop ? <StashHead /> : null}
{ this.props.showType && <Text style={styles.type}>{this.getThreadTypeStr()}</Text> }
{ ! this.props.hideTime && <Text style = {{fontSize:12,color:"rgba(0,0,0,0.45)"}}>{this.getTimeAndIndentity(this.props.itemList)}</Text>}
{/*this.props.showType &&*/}
</View>
</View>
{!!this.props.itemList.user && this.props.itemList.user.id != global.userId && (!this.props.itemList.user.hasBeenAttended)
&& <TouchableOpacity activeOpacity={0.8} onPress = {this._followClick}>
<Text style = {{fontSize:setSpText(14),color:global.homeColor}}>关注</Text>
</TouchableOpacity>
}
</View>
</View>
</View>
)
}
}
// this.props.itemList.creationTime
const styles = StyleSheet.create({
avatar:{
width:scaleHeight(36),
height:scaleHeight(36),
borderRadius:scaleHeight(18),
},
avatarV:{
width:scaleHeight(12),
height:scaleHeight(12),
position:'absolute',
right:-scaleSize(4),
bottom:scaleHeight(2),
},
userNameBlack:{
fontSize:setSpText(14),
color:'rgba(0,0,0,0.85)',
fontWeight: 'bold',
},
reportStyle:{
marginLeft:5,
fontSize:setSpText(8),
color:'gray',
fontWeight: 'bold',
borderColor: 'rgba(0,0,0,0.45)',
borderWidth: 0.5,
borderRadius: 2,
},
time:{
fontSize:setSpText(12),
color:'rgba(0,0,0,0.45)'
},
type:{
fontSize: 10,
color: 'rgba(0,0,0,0.65)',
borderColor: 'rgba(0,0,0,0.45)',
borderWidth: 1,
borderRadius: 2,
marginRight: 5,
justifyContent: "center",
alignItems: "center",
textAlign: "center",
paddingLeft: 4,
paddingTop: 2,
paddingRight: 4,
paddingBottom: 1
}
});