targetAbout.js
5.84 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
/**
* Created by Cassie on 2018/05/14
*/
import React, {Component} from "react";
import {StyleSheet, View, Text, TouchableOpacity, Image, ScrollView} from "react-native";
import moment from "moment";
import {zoomW, zoomH} from "../../utils/getSize";
import {NoDoublePress} from "../../utils/utils";
const back = require('../../img/returnB.png');
const avatar = require('../../img/avatar.png');
export default class TargetAbout extends Component {
static navigationOptions = ({navigation, screenProps}) => ({
title: navigation.state.params.from,
headerLeft: (<View style={{flex: 1, display: 'flex', flexDirection: 'row'}}>
<TouchableOpacity style={styles.topIcon}
onPress={navigation.state.params ? navigation.state.params.back : null}>
<Image source={back} style={{width: (16 / zoomH), height: (16 / zoomH)}} resizeMode="contain"/>
</TouchableOpacity>
</View>),
headerRight: (<View style={{flex: 1, display: 'flex', flexDirection: 'row'}}/>)
});
constructor(props) {
super(props);
this.state = {
sheetList: [],
};
};
componentWillMount() {
this.setState({
sheetList: this.props.navigation.state.params.list
})
};
componentDidMount() {
this.props.navigation.setParams({
back: () => {
NoDoublePress.onPress(() => {
this.props.navigation.goBack();
})
}
});
};
/*渲染列表*/
renderItem(item, index) {
return (
this.props.navigation.state.params.from == '关联任务' ?
<TouchableOpacity activeOpacity={0.8} key={index} style={styles.targetItem} onPress={() => {
NoDoublePress.onPress(() => this.props.navigation.navigate('TargetDetail', {
targetId: item.objectId,
isAbort: item.isAbort,
isDone: item.isDone,
from: 'targetAbout'
}))
}}>
<View style={{
borderRadius: (30 / zoomH),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderStyle: 'solid',
borderColor: '#ddd',
borderWidth: StyleSheet.hairlineWidth
}}>
<Image
source={item.avarUrl ? {uri: item.avarUrl + '?x-oss-process=image/resize,w_500'} : avatar}
style={{width: (52 / zoomH), height: (52 / zoomH), borderRadius: (26 / zoomH)}}
resizeMode="cover"/>
</View>
<View style={{flex: 1, paddingLeft: (10 / zoomW)}}>
<Text style={{fontSize: 17, color: '#000'}} numberOfLines={1}>{item.objectName}</Text>
<Text style={{fontSize: 14, color: '#666'}}
numberOfLines={1}>{'结束时间:' + moment(Number(item.endTime)).format('YYYY-MM-DD HH:mm')}</Text>
{item.objectDescription && <Text style={{fontSize: 14, color: '#666'}}
numberOfLines={1}>{'任务详情:' + item.objectDescription}</Text>}
</View>
</TouchableOpacity>
:
<View key={index} style={styles.targetItem}>
<View style={{
width: (50 / zoomH),
height: (50 / zoomH),
borderRadius: (25 / zoomH),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderStyle: 'solid',
borderColor: '#ddd',
borderWidth: StyleSheet.hairlineWidth
}}>
<Image source={item.avatar ? {uri: item.avatar + '?x-oss-process=image/resize,w_500'} : avatar}
style={{width: (50 / zoomH), height: (50 / zoomH), borderRadius: (25 / zoomH)}}
resizeMode="cover"/>
</View>
<View style={{flex: 1, paddingLeft: (10 / zoomW), display: 'flex', justifyContent: 'center'}}>
<Text style={{fontSize: 17, color: '#000'}} numberOfLines={1}>{item.userName}</Text>
</View>
</View>
)
};
componentWillUnmount() {
this.setState = (state, callback) => {
return;
};
};
render() {
return (
<View style={styles.background}>
<ScrollView style={{width: '100%'}}>
<View style={{width: '100%', height: (18 / zoomH)}}/>
{this.state.sheetList && this.state.sheetList.map((item, index) => this.renderItem(item, index))}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
topIcon: {
paddingLeft: (10 / zoomW),
paddingRight: (10 / zoomW),
height: '100%',
display: 'flex',
justifyContent: 'center'
},
background: {
flex: 1,
backgroundColor: '#ececf1',
display: 'flex',
alignItems: 'center'
},
targetItem: {
flex: 1,
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
borderStyle: 'solid',
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#eee',
paddingLeft: (15 / zoomW),
paddingRight: (15 / zoomW),
paddingTop: (10 / zoomH),
paddingBottom: (10 / zoomH),
backgroundColor: '#fff'
}
});