Data.js
12.9 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
'use strict';
import React, {Component} from 'react';
import {DeviceEventEmitter, Dimensions, Image, StyleSheet, Text, TouchableOpacity, View, ScrollView} from 'react-native';
import HelpTipsModal from "./HelpTipsModal";
import SureModal from "./SureModal";
import WithdrawModal from "./WithdrawModal";
import CheckSettleModal from "./CheckSettleModal";
import UploadCardModal from "./UploadCardModal";
import ScrollableTabView from 'react-native-scrollable-tab-view';
import TabStatistics from '../components/TabStatistics';
import Statistics from "./Statistics";
import ReactNative from "react-native";
import { TipsAlertItem, TipsAlert } from '../../common/components/YH_TipsAlert';
import Prompt from '../../common/components/Prompt';
const tabTitles = ['昨日', '本月', '上月'];
export default class Data extends Component {
constructor(props) {
super(props);
this._jumpBindCardUrl = this._jumpBindCardUrl.bind(this);
this._jumpBindIdentityCardUrl = this._jumpBindIdentityCardUrl.bind(this);
}
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();
}
_jumpBindCardUrl() {
let bindStatus = this.props.settlementInfo.settlementInfoData.hasBankCard;
let bindType = bindStatus ? '2' : '1';
this.props.jumpWithUrl && this.props.jumpWithUrl('我的银行卡', 'bankCard', bindType);
this.props.hiddenTipsAlertDialog && this.props.hiddenTipsAlertDialog();
}
_jumpBindIdentityCardUrl() {
this.props.jumpWithUrl && this.props.jumpWithUrl('我的身份证', 'nameAuthen');
this.props.hiddenBindAlertDialog && this.props.hiddenBindAlertDialog();
}
render() {
let {
isShowTipsAlert,
isShowHelp,
isShowSure,
isShowWithdrawal,
statisticsInfo,
isShowWithCheck,
checkSettlementInfo,
identityCardInfo,
tipMessage,
isShowCheckSettleDialog
} = this.props;
let bindStatus = this.props.settlementInfo.settlementInfoData.hasBankCard;
let scrollEnabled = height < 667;
let isIDBind = this.props.identityCardInfo.data;
// 处理了空值判断
let settlementAmount = this.props.settlementInfo.settlementInfoData.settlementAmount;
settlementAmount = settlementAmount ? settlementAmount : '0';
return (
<ScrollView style={styles.container} scrollEnabled = {scrollEnabled}>
<TipsAlert
tips={this.props.tips}
isShow={isShowTipsAlert}
>
<TipsAlertItem showStatus='sure' handleAction={this._jumpBindCardUrl}>去绑定</TipsAlertItem>
<TipsAlertItem showStatus='cancel' handleAction={this.props.hiddenTipsAlertDialog}>取消</TipsAlertItem>
</TipsAlert>
<HelpTipsModal
tips={this.props.tips}
isShowHelp={isShowHelp}
hiddenHelpDialog={this.props.hiddenHelpDialog}/>
<SureModal
isShow={isShowSure}
hiddenSureDialog={this.props.hiddenSureDialog}
showWithdrawalDialog={this.props.showWithdrawalDialog}/>
<WithdrawModal
isShowWithdrawal={isShowWithdrawal}
hiddenWithDrawDialog={this.props.hiddenWithDrawDialog}/>
<CheckSettleModal
data={checkSettlementInfo}
isShowWithCheck={isShowCheckSettleDialog}
jumpWithActivityUrl={this.props.jumpWithActivityUrl}
showWithdrawalDialog={this.props.showWithdrawalDialog}
hiddenCheckSettleDialog={this.props.hiddenCheckSettleDialog}/>
<UploadCardModal
isShow={this.props.isShowBindAlert}
jumpBindIdentityCardUrl={this._jumpBindIdentityCardUrl}
hiddenBindAlertDialog={this.props.hiddenBindAlertDialog}/>
<View style={styles.headerBackground}>
<Text style={styles.canWithDrawText}>可提现金额</Text>
<View style={styles.amountView}>
<View style={[styles.textView, {flex: 3}]}>
<Text
style={styles.amountText}><Text style={{fontSize:30}}>¥</Text>{settlementAmount}</Text>
</View>
<View style={[styles.textView, {flex: 1, alignItems: 'flex-end'}]}>
<TouchableOpacity activeOpacity={1} onPress={() => {
if (!bindStatus) {
this.props.showTipsAlertDialog && this.props.showTipsAlertDialog('请先完成银行卡绑定');
return
}
if (!this.props.settlementInfo.settlementInfoData.settlementAmount || this.props.settlementInfo.settlementInfoData.settlementAmount === 0) {
this.props.onShowTipMessage && this.props.onShowTipMessage('暂⽆可提现金额');
return
}
if (this.props.settlementInfo.settlementInfoData.canSettlement) {
if (this.props.settlementInfo.settlementInfoData.settlementAmount <= 500) {
!this.props.addSettlement.isFetching && this.props.showSureDialog && this.props.showSureDialog();
} else {
if (!isIDBind) {
this.props.showBindAlertDialog && this.props.showBindAlertDialog();
return
} else {
this.props.showCheckSettleDialog && this.props.showCheckSettleDialog();
}
}
} else {
this.props.showHelpDialog && this.props.showHelpDialog('您有正在处理中的提现,请耐心等待完成后再做新的提现操作');
}
}}>
<Text style={styles.amountButton}>提现</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.reminderView}>
<Image style={styles.reminderImage} source={require('../images/reminder.png')}/>
<Text style={styles.reminderText} numberOfLines={2}>每月20日结算上个月预估佣金,当月预估佣金在下个月20日结算</Text>
</View>
</View>
<View style={styles.lineView}/>
<TouchableOpacity activeOpacity={1} style={styles.withdrawView} onPress={() => {
this.props.jumpWithUrl && this.props.jumpWithUrl('提现记录', 'withdrawalRecord');
}}>
<Text style={styles.hasWithDrawText}>已提现金额</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15, marginTop: 5}]}>
<Text
style={[styles.hasWithDrawText,{marginTop: -2}]}>¥{this.props.settlementInfo.settlementInfoData.historySettlementAmount}</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('全部佣金', 'orderIncome');
}}>
<Text style={styles.hasWithDrawText}>全部佣金数据</Text>
<View style={[styles.textView, {flexDirection: 'row', paddingRight: 15}]}>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</View>
</TouchableOpacity>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
<ScrollableTabView
style={{backgroundColor: 'white'}}
locked={true}
contentProps={{style: {minHeight: 181}}}
scrollWithoutAnimation={true}
renderTabBar={() => <TabStatistics tabNames={tabTitles}/>}
onChangeTab={(obj) => {this.props.changeTab && this.props.changeTab(obj.i + 1);}}
>
<Statistics statisticsInfo={statisticsInfo} currentTab = {1} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} currentTab = {2} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} currentTab = {3} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
</ScrollableTabView>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
{tipMessage != '' ?
<Prompt
text={tipMessage}
duration={1500}
onPromptHidden={this.props.onHiddenTipMessage}
/>
: null
}
</ScrollView>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 375;
const DEVICE_HEIGHT_RATIO = height / 667;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0'
},
textStyle: {
flex: 1,
fontSize: 20,
marginTop: 20,
textAlign: 'center',
},
textView: {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'flex-start',
},
reminderImage: {
marginTop: 2,
width: 11,
height: 11,
},
reminderView: {
marginTop: 2,
flexDirection: 'row',
alignItems: 'flex-start',
},
reminderText: {
fontFamily: 'PingFang-SC-Regular',
color: '#B0B0B0',
fontSize: 10,
paddingLeft: 2,
paddingRight: 5,
},
headerBackground: {
width: width,
height: 138,
backgroundColor: '#FFFFFF',
paddingTop: 23,
paddingLeft: 15 * DEVICE_WIDTH_RATIO,
paddingBottom: 25,
position: 'relative',
},
canWithDrawText: {
height: 20,
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#B0B0B0',
marginBottom:5,
},
amountView: {
width: width - 15 * 2 * DEVICE_WIDTH_RATIO,
height: 58,
marginTop: 1,
flexDirection: 'row',
justifyContent: 'flex-start',
},
amountText: {
lineHeight: 48,
fontSize: 48,
color: '#444444',
fontWeight: 'bold',
marginLeft: -5,
},
amountButton: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
fontWeight: 'bold',
backgroundColor: '#D0021B',
color: '#FFFFFF',
borderWidth: 1,
borderColor: '#D0021B',
borderRadius: 4,
overflow: 'hidden',
paddingTop: 5,
paddingLeft: 18 * DEVICE_WIDTH_RATIO,
paddingRight: 18 * DEVICE_WIDTH_RATIO,
paddingBottom: 5,
textAlign: 'center',
},
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',
},
arrowImage: {
width: 16,
height: 16,
marginLeft: 2,
},
lineView: {
width: width,
height: 0.5,
backgroundColor: '#e0e0e0'
}
})
;