|
|
@@ -3,10 +3,11 @@
|
|
|
* @邠心vbe on 2021/05/08
|
|
|
*/
|
|
|
import React, { Component } from 'react';
|
|
|
-import { View, Text, StyleSheet, Image, Pressable } from 'react-native';
|
|
|
+import { View, Text, StyleSheet, Image, Pressable, TouchableOpacity } from 'react-native';
|
|
|
import apiWallet from '../../api/apiWallet';
|
|
|
import TextView from '../../components/TextView';
|
|
|
import { PageList } from '../Router';
|
|
|
+import app from '../../../app.json';
|
|
|
|
|
|
const IconCharge = require('../../images/wallet/ic-type-charge.png');
|
|
|
const IconPayment = require('../../images/wallet/ic-type-payment.png');
|
|
|
@@ -21,13 +22,13 @@ export default class History extends Component {
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- this.getHistory(true);
|
|
|
+ this.getHistory();
|
|
|
}
|
|
|
|
|
|
componentDidUpdate() {
|
|
|
if (this.props.refresh && !this.refreshing && this.props.shown) {
|
|
|
this.refreshing = true;
|
|
|
- this.getHistory(true);
|
|
|
+ this.getHistory();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -38,22 +39,42 @@ export default class History extends Component {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- getHistory(refresh) {
|
|
|
- apiWallet.getTransactionList({latestPk: refresh ? '' : this.getLastPk()}).then(res => {
|
|
|
+ getHistory() {
|
|
|
+ if (app.v3.overview) {
|
|
|
+ this.getHistoryV2();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ apiWallet.getTransactionList({latestPk: ''}).then(res => {
|
|
|
this.stopRefresh();
|
|
|
if (res.data) {
|
|
|
- if (refresh) {
|
|
|
- this.setState({
|
|
|
- historyList: res.data
|
|
|
- });
|
|
|
- } else {
|
|
|
- const list = this.state.historyList;
|
|
|
- this.setState({
|
|
|
- historyList: list.concat(res.data)
|
|
|
- });
|
|
|
- }
|
|
|
+ this.setState({
|
|
|
+ historyList: res.data
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.setState({
|
|
|
+ historyList: []
|
|
|
+ });
|
|
|
+ this.stopRefresh();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ getHistoryV2() {
|
|
|
+ apiWallet.getTransactionListV2({latestPk: ''}).then(res => {
|
|
|
+ this.stopRefresh();
|
|
|
+ if (res.data && res.data.length) {
|
|
|
+ this.setState({
|
|
|
+ historyList: res.data.slice(10)
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ historyList: []
|
|
|
+ });
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
+ this.setState({
|
|
|
+ historyList: []
|
|
|
+ });
|
|
|
this.stopRefresh();
|
|
|
});
|
|
|
}
|
|
|
@@ -84,6 +105,10 @@ export default class History extends Component {
|
|
|
return title;
|
|
|
}
|
|
|
|
|
|
+ toHistoryList() {
|
|
|
+ startPage(PageList.history);
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
return (
|
|
|
<View style={this.props.shown ? ui.flex1 : styles.hide}>
|
|
|
@@ -96,35 +121,50 @@ export default class History extends Component {
|
|
|
</View> */}
|
|
|
<View style={styles.listView}>
|
|
|
{ this.state.historyList.length > 0
|
|
|
- ? this.state.historyList.map((item, index) => {
|
|
|
- return (
|
|
|
- <Pressable
|
|
|
- key={index}
|
|
|
- android_ripple={ripple}
|
|
|
- style={styles.itemView}
|
|
|
- onPress={() => {
|
|
|
- this.toSummary(index)
|
|
|
- }}>
|
|
|
- <Image
|
|
|
- style={styles.iconType}
|
|
|
- resizeMode="contain"
|
|
|
- source={(item.amountSymbol == 'P' || item.remarks) ? IconPayment : IconCharge}/>
|
|
|
- <View style={[styles.itemContent, index > 0 && styles.divide]}>
|
|
|
- <View style={ui.flex1}>
|
|
|
- <TextView style={styles.issueName}>{this.getTransTitle(item)}</TextView>
|
|
|
- <TextView style={styles.issueDesc}>{$t('wallet.labelTransactionId') + item.creditRecordPk}</TextView>
|
|
|
+ ? <>
|
|
|
+ {
|
|
|
+ this.state.historyList.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <Pressable
|
|
|
+ key={index}
|
|
|
+ android_ripple={ripple}
|
|
|
+ style={styles.itemView}
|
|
|
+ onPress={() => {
|
|
|
+ this.toSummary(index)
|
|
|
+ }}>
|
|
|
+ <Image
|
|
|
+ style={styles.iconType}
|
|
|
+ resizeMode="contain"
|
|
|
+ source={(item.amountSymbol == 'P' || item.remarks) ? IconPayment : IconCharge}/>
|
|
|
+ <View style={[styles.itemContent, index > 0 && styles.divide]}>
|
|
|
+ <View style={ui.flex1}>
|
|
|
+ <TextView style={styles.issueName}>{this.getTransTitle(item)}</TextView>
|
|
|
+ <TextView style={styles.issueDesc}>{$t('wallet.labelTransactionId') + item.creditRecordPk}</TextView>
|
|
|
+ </View>
|
|
|
+ { item.amountSymbol == 'M'
|
|
|
+ ? <TextView style={styles.amountDuct}>- {item.amount}</TextView>
|
|
|
+ : <TextView style={styles.amountText}>+ {item.amount}</TextView>
|
|
|
+ }
|
|
|
</View>
|
|
|
- { item.amountSymbol == 'M'
|
|
|
- ? <TextView style={styles.amountDuct}>- {item.amount}</TextView>
|
|
|
- : <TextView style={styles.amountText}>+ {item.amount}</TextView>
|
|
|
- }
|
|
|
- </View>
|
|
|
- </Pressable>
|
|
|
- );
|
|
|
- })
|
|
|
+ </Pressable>
|
|
|
+ );
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </>
|
|
|
: <Text style={styles.noResult}>{$t('wallet.noHistoryData')}</Text>
|
|
|
}
|
|
|
</View>
|
|
|
+ { (app.v3.overview && this.state.historyList.length > 0) &&
|
|
|
+ <TouchableOpacity
|
|
|
+ style={styles.moreButton}
|
|
|
+ activeOpacity={0.4}
|
|
|
+ onPress={() => this.toHistoryList()}>
|
|
|
+ <Text
|
|
|
+ style={ui.link}>
|
|
|
+ {$t("wallet.viewMore")}
|
|
|
+ </Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+ }
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
@@ -187,5 +227,10 @@ const styles = StyleSheet.create({
|
|
|
amountText: {
|
|
|
color: textPrimary,
|
|
|
fontSize: 14
|
|
|
+ },
|
|
|
+ moreButton: {
|
|
|
+ padding: 16,
|
|
|
+ alignItems: 'center',
|
|
|
+ marginBottom: 8
|
|
|
}
|
|
|
})
|