myEvents.js
10.6 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
/**
* Created by Cassie on 2018/03/21
*/
import React, { Component } from 'react';
import {
StyleSheet,
ScrollView,
View,
Text,
TouchableOpacity,
Image,
TextInput,
ActivityIndicator,
Keyboard,
StatusBar,
Modal
} from 'react-native';
import {width,height,zoomW,zoomH} from '../../utils/getSize';
import {getHeaderPadding, getHeaderHeight, NoDoublePress,xnToast,MD5} from "../../utils/utils";
import xnService from "../../service/AppService";
import Carousel from 'react-native-looped-carousel';
import md5 from 'md5';
import { NavigationActions } from 'react-navigation';
const bgImg = require('../../img/bgImg.png');
const logo = require('../../img/logo.png');
const phone = require('../../img/phone.png');
const pwd = require('../../img/pwd.png');
const bitmap = require('../../img/bitmap.png');
const phoneRule = /^1[3456789]\d{9}$/;
export default class myEvents extends Component {
static navigationOptions = ({navigation,screenProps}) => ({
headerTitle:'我的事件',
headerLeft:(
<TouchableOpacity style={styles.backWrap} onPress={() => navigation.goBack()}>
<Image source={require('../../img/back_gray.png')} resizeMode="contain" />
</TouchableOpacity>
),
headerRight:(
<View></View>
)
});
constructor(props){
super(props);
this.state = {
itemList:[],
imageList: [],
currentIndex: 0,
modalShow: false
};
};
componentWillMount(){
};
componentDidMount(){
xnService.getMyEvents({userId:global.user.id}).then((data) => {
if(data.message){
xnToast(data.message);
return;
}
if(data.errors.length > 0){
xnToast(data.errors[0].message);
}else{
this.setState({
itemList:data.result
})
}
});
}
renderItem = (item,index) => {
return (
<View style={{marginTop:index==0?35:10,paddingLeft:15/zoomW,paddingRight:15/zoomW,paddingBottom:13/zoomH,borderBottomWidth:1,borderBottomColor:'#e5e5e5'}}>
<Text style={{color:'#0c50ba',fontSize:17}}>{item.title}</Text>
<Text style={{color:'#343434',fontSize:17,marginTop:5/zoomH,marginBottom:10/zoomH}}>{item.description}</Text>
{item.appAttachementAddress && <View style={styles.itemContent}>
<View style={{flexDirection:'row'}}>
{item.appAttachementAddress.map((item,index,arr) => this.renderImg(item,index,arr))}
</View>
</View>}
<Text numberOfLines={1} style={{color:'#4e7fcc',fontSize:16,marginBottom:3/zoomH}}>{!!!item.detailed?item.lineName+item.station:item.detailed}</Text>
<Text style={{color:'#a0a0a0',fontSize:16}}>{item.commitTime}</Text>
<View>
<Image style={{marginLeft:8/zoomW}} source={require('../../img/arrowTop.png')} resizeMode='contain'></Image>
<View style={{backgroundColor:'#efefef',width:'100%',padding:7}}>
<Text style={{color:'#104caa',fontSize:17}}>处理意见:<Text style={{color:'#3b3b3b',fontSize:17}}>{item.handleSuggestion || '处置中'}</Text></Text>
</View>
</View>
</View>
)
};
// 放大图片
enlargeImg(index,arr) {
this.setState({
imageList: arr,
currentIndex: index,
}, () => {
this.setState({
modalShow: true,
});
});
}
// 关闭模态框
closeModal() {
this.setState({
modalShow: false,
});
}
/*渲染图片*/
renderImg(item,index,arr){
return (
<TouchableOpacity activeOpacity={0.8} onPress={() => this.enlargeImg(index,arr)} key={index}>
{index == 0 && <Image source={{uri:item+'?x-oss-process=image/resize,w_1000'}} style={arr.length === 1 ? styles.coverImg : styles.moreImg} resizeMode="cover" />}
{index == 1 && <Image source={{uri:item+'?x-oss-process=image/resize,w_1000'}} style={[styles.moreImg,{marginLeft:(7/zoomW)}]} resizeMode="cover" />}
{index == 2 && <Image source={{uri:item+'?x-oss-process=image/resize,w_1000'}} style={[styles.moreImg,{marginLeft:(7/zoomW)}]} resizeMode="cover" />}
</TouchableOpacity>
)
};
render(){
return(
<ScrollView style={styles.background} bounces={false} scrollEventThrottle={200}>
<StatusBar barStyle={'default'}/>
<Modal
animationType={'none'}
visible={this.state.modalShow}
transparent
onRequestClose={() => {}}
>
<View style={styles.viewBg}>
<View
style={{
width,
height: getHeaderHeight(),
paddingTop: getHeaderPadding(),
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}
>
<TouchableOpacity
activeOpacity={0.8} style={{
height: '100%',
display: 'flex',
justifyContent: 'center',
paddingLeft: 15 / zoomW,
paddingRight: 15 / zoomW,
position: 'absolute',
left: 0,
top: getHeaderPadding(),
}} onPress={() => NoDoublePress.onPress(() => {
this.closeModal();
})}
>
<Image source={require('../../img/closeImgModal.png')} style={{ width: 12 / zoomW, height: 12 / zoomW }} resizeMode="contain" />
</TouchableOpacity>
<Text style={{ fontSize: 16, color: '#fff' }}>{this.state.currentIndex + 1}/{this.state.imageList.length}</Text>
</View>
<Carousel
style={{ height: height - getHeaderHeight(), width, paddingBottom: getHeaderHeight() }}
bullets={false}
isLooped={false}
autoplay={false}
currentPage={this.state.currentIndex}
onAnimateNextPage={index => this.setState({ currentIndex: index })}
>
{this.state.imageList.map((item, index) =>
<TouchableOpacity
activeOpacity={1} key={index} style={{
width,
height: height - 2 * getHeaderHeight(),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Image source={{ uri: `${item}?x-oss-process=image/resize,w_640` }} style={{ width, height: '100%' }} resizeMode="contain" />
</TouchableOpacity>,
)}
</Carousel>
</View>
</Modal>
<Image style={{width:'100%',height:195/zoomH}} source={global.user.politicalStatus == 1?require('../../img/myEventsBanner.png'):require('../../img/myEventsBanner_unparty.png')} resizeMode='cover'></Image>
<View style={{position:'absolute',right:14/zoomW,top:136/zoomH,backgroundColor:'#f1f1f1',width:80/zoomW,height:80/zoomW,borderRadius:4,alignItems:'center',justifyContent:'center'}}>
{global.user.avatar&&global.user.avatar!=''?
<Image style={{width:74/zoomW,height:74/zoomW}} defaultSource={global.user.politicalStatus == 1?require('../../img/defultPartyIcon.png'):require('../../img/defultIcon.png')} source={{uri:global.user.avatar}} resizeMode='cover'/>:
<Image style={{width:74/zoomW,height:74/zoomW}} source={global.user.politicalStatus == 1?require('../../img/defultPartyIcon.png'):require('../../img/defultIcon.png')} resizeMode='cover'/>}
{/*<Image style={{width:74/zoomW,height:74/zoomW}} defaultSource={global.user.politicalStatus == 1?require('../../img/defultPartyIcon.png'):require('../../img/defultIcon.png')} source={{uri:global.user.avatar}} resizeMode='cover'/>*/}
</View>
<Text style={{backgroundColor:'transparent',color:'white',position:'absolute',right:109/zoomW,top:162/zoomH,fontFamily:'PingFangSC-Medium',fontSize:18}}>{global.user.nickName}</Text>
{this.state.itemList.length==0&&<View style={{flexDirection:'row',width:'100%',height:20,justifyContent:'center',alignItems:'flex-start',marginTop:65/zoomH,paddingLeft:15/zoomW,paddingRight:15/zoomW}}>
<View style={{flex:1,height:2/zoomW,backgroundColor:'#d8d8d8',marginRight:14/zoomW}}></View>
<View style={{width:4/zoomW,height:4/zoomW,backgroundColor:'#d8d8d8'}}></View>
<View style={{flex:1,height:2/zoomW,backgroundColor:'#d8d8d8',marginLeft:14/zoomW}}></View>
</View>}
{this.state.itemList.length != 0 && this.state.itemList.map((v, i) => this.renderItem(v, i))}
</ScrollView>
);
}
}
const styles = StyleSheet.create({
backWrap: {
justifyContent: 'center',
paddingLeft: 18.5/zoomW,
paddingRight: 18.5/zoomW,
height: 44/zoomH,
},
background:{
flex:1,
backgroundColor:'#fff',
},
viewBg: {
width,
height,
backgroundColor: '#000',
display: 'flex',
justifyContent: 'flex-end',
},
itemContent:{
display:'flex',
flexDirection:'row',
marginBottom:(5/zoomH)
},
coverImg:{
width:(345/zoomW),
height:(193/zoomH),
backgroundColor:'#eee'
},
moreImg:{
width:(110/zoomW),
height:(110/zoomW),
backgroundColor:'#eee'
},
});