Mine.js
9.35 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
'use strict';
import React, {Component} from 'react';
import {DeviceEventEmitter, Dimensions, Image, ListView, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {Immutable} from "immutable";
import SingleImage from './floor/SingleImage';
import MineCell from './cell/MineCell';
import YH_Image from '../../common/components/YH_Image';
import Prompt from "../../common/components/Prompt";
export default class Mine extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
});
}
componentDidMount() {
this.subscription = DeviceEventEmitter.addListener('BankCardBindSuccessEvent', () => {
this.props.refreshSettlementInfo && this.props.refreshSettlementInfo();
});
this.subscription = DeviceEventEmitter.addListener('IdentityCardBindSuccessEvent', () => {
this.props.refreshIdentityCardInfo && this.props.refreshIdentityCardInfo();
});
}
componentWillUnmount() {
this.subscription.remove();
}
_renderHeader() {
let bindStatus = this.props.settlementInfo.settlementInfoData.hasBankCard;
let bindStyle = bindStatus ? {color: '#444444'} : {color: '#D0021B'};
let isBind = bindStatus ? '已绑定' : '未绑定';
let bindType = bindStatus ? '2' : '1'; // 2绑定,1未绑定
let ico = this.props.profile.head_ico;
let imageUrl = YH_Image.getSlicedUrl(ico, 50, 50, 2);
let nickname = this.props.profile.nickname;
let uploadStatus = this.props.identityCardInfo.data;
let uploadStyle = uploadStatus ? {color: '#444444'} : {color: '#D0021B'};
let isUpload = uploadStatus ? '已上传' : '未上传';
//当前粉丝数空值判断
let fansAmount = this.props.shareTotalInfo.shareTotalInfoData.fans;
fansAmount = fansAmount ? fansAmount : '0';
let fansShow = this.props.shareTotalInfo.shareTotalInfoData.showFans;
let fansShowStyle = fansShow ? {width: width, height: 50, backgroundColor: '#FFFFFF', flexDirection: 'row',
paddingLeft: 15, alignItems: 'center', justifyContent: 'space-between'} : {height: 0, width: 0};
let lineShowStyle = fansShow ? {height: 1.0, backgroundColor: '#f0f0f0'} : {height: 0};
//邀请好友数空值判断
let invitesAmount = this.props.shareTotalInfo.shareTotalInfoData.inviteNum;
invitesAmount = invitesAmount ? invitesAmount : '0';
return (
<View>
<View style={styles.headerBackground}>
<YH_Image style={styles.headIcon} url={imageUrl} circle={true}/>
<View style={styles.textView}>
<Text style={styles.nicknameText}>{nickname}</Text>
</View>
</View>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
<TouchableOpacity activeOpacity={1} style={styles.withdrawView} onPress={() => {
this.props.jumpWithUrl && this.props.jumpWithUrl('我的银行卡', 'bankCard', bindType);
}}>
<Text style={styles.hasWithDrawText}>我的银行卡</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15}]}>
<Text style={[styles.hasWithDrawText, bindStyle]}>{isBind}</Text>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</View>
</TouchableOpacity>
<View style={{height: 1, backgroundColor: '#f0f0f0'}}/>
<TouchableOpacity activeOpacity={1} style={styles.withdrawView} onPress={() => {
if (uploadStatus) {
this.props.showToastMessage && this.props.showToastMessage('身份证已上传,如需修改请联系有货客服');
} else {
this.props.jumpWithUrl && this.props.jumpWithUrl('我的身份证', 'nameAuthen');
}
}}>
<Text style={styles.hasWithDrawText}>我的身份证</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15}]}>
<Text style={[styles.hasWithDrawText, uploadStyle]}>{isUpload}</Text>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</View>
</TouchableOpacity>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
<TouchableOpacity activeOpacity={1} style={styles.withdrawView} onPress={() => {
this.props.jumpWithUrl && this.props.jumpWithUrl('邀请好友', 'invitedFriends');
}}>
<Text style={styles.hasWithDrawText}>邀请好友数</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15}]}>
<Text style={[styles.hasWithDrawText]}>{invitesAmount}</Text>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</View>
</TouchableOpacity>
<View style={lineShowStyle}/>
<TouchableOpacity activeOpacity={1} style={fansShowStyle} onPress={() => {
}}>
<Text style={styles.hasWithDrawText}>当前粉丝数</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15}]}>
<Text style={[styles.hasWithDrawText]}>{fansAmount}</Text>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</View>
</TouchableOpacity>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
</View>
);
}
_renderRow(rowData, sectionID, rowID) {
if(!rowData || !rowData.get('data')){
return null;
}
let templatename = rowData.get('template_name');
if (templatename === 'textNav' && rowData) {
return (
<MineCell
resource={rowData.get('data')}
resourceJumpWithUrl={this.props.resourceJumpWithUrl}
styles={styles} />
);
} else if (templatename === 'newSingleImage' && rowData) {
console.log(rowData.toJS());
return (
<SingleImage
data={rowData}
resourceJumpWithUrl={this.props.resourceJumpWithUrl} />
)
} else {
return null
}
}
render() {
let {mineResourceInfo, isShowToast, toastMessage} = this.props;
let resourceList = mineResourceInfo.resourceList ? mineResourceInfo.resourceList.toArray() : [];
return (
<View style={styles.container}>
<ListView
ref={(c) => {
this.listView = c;
}}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(resourceList)}
renderHeader={this._renderHeader}
renderRow={this._renderRow}
/>
{isShowToast ? <Prompt
text={toastMessage}
duration={1500}
onPromptHidden={this.props.hideToastMessage}
/> : null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0'
},
headerBackground: {
width: width,
height: 80,
backgroundColor: '#FFFFFF',
padding: 15,
flexDirection: 'row',
},
headIcon: {
width: 50,
height: 50,
marginRight:10,
overflow: 'hidden',
borderRadius: 25,
},
textView: {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
},
nicknameText: {
fontSize: 14,
color: '#444444',
fontWeight: 'bold'
},
withdrawView: {
width: width,
height: 50,
backgroundColor: '#FFFFFF',
flexDirection: 'row',
paddingLeft: 15,
alignItems: 'center',
justifyContent: 'space-between'
},
hasWithDrawText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#444444',
},
hasNumText: {
fontFamily: 'SanFranciscoText-Medium',
fontSize: 14,
color: '#444444',
},
arrowImage: {
width: 11,
height: 11,
marginLeft: 2,
},
contentContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
backgroundColor: 'white'
}
})
;