|
|
@@ -8,6 +8,7 @@ import apiWallet from '../../api/apiWallet';
|
|
|
import TextView from '../../components/TextView';
|
|
|
import { PageList } from '../Router';
|
|
|
import app from '../../../app.json';
|
|
|
+import VbeSkeleton from '../../components/VbeSkeleton';
|
|
|
|
|
|
const IconCharge = require('../../images/wallet/ic-type-charge.png');
|
|
|
const IconPayment = require('../../images/wallet/ic-type-payment.png');
|
|
|
@@ -16,17 +17,19 @@ export default class History extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- historyList: []
|
|
|
+ loading: true,
|
|
|
+ historyList: [],
|
|
|
+ loadingList: ["", "", "", "", ""]
|
|
|
};
|
|
|
this.refreshing = false;
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- this.getHistory();
|
|
|
+ //this.getHistory();
|
|
|
}
|
|
|
|
|
|
componentDidUpdate() {
|
|
|
- if (this.props.refresh && !this.refreshing && this.props.shown) {
|
|
|
+ if ((this.state.loading || this.props.refresh) && !this.refreshing && this.props.shown) {
|
|
|
this.refreshing = true;
|
|
|
this.getHistory();
|
|
|
}
|
|
|
@@ -45,7 +48,6 @@ export default class History extends Component {
|
|
|
return;
|
|
|
}
|
|
|
apiWallet.getTransactionList({latestPk: ''}).then(res => {
|
|
|
- this.stopRefresh();
|
|
|
if (res.data) {
|
|
|
this.setState({
|
|
|
historyList: res.data
|
|
|
@@ -55,13 +57,16 @@ export default class History extends Component {
|
|
|
this.setState({
|
|
|
historyList: []
|
|
|
});
|
|
|
+ }).finally(() => {
|
|
|
+ this.setState({
|
|
|
+ loading: false,
|
|
|
+ });
|
|
|
this.stopRefresh();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getHistoryV2() {
|
|
|
apiWallet.getTransactionListV2({latestPk: ''}).then(res => {
|
|
|
- this.stopRefresh();
|
|
|
if (res.data && res.data.length) {
|
|
|
this.setState({
|
|
|
historyList: res.data.slice(0, 10)
|
|
|
@@ -75,6 +80,10 @@ export default class History extends Component {
|
|
|
this.setState({
|
|
|
historyList: []
|
|
|
});
|
|
|
+ }).finally(() => {
|
|
|
+ this.setState({
|
|
|
+ loading: false,
|
|
|
+ });
|
|
|
this.stopRefresh();
|
|
|
});
|
|
|
}
|
|
|
@@ -112,58 +121,67 @@ export default class History extends Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<View style={this.props.shown ? ui.flex1 : styles.hide}>
|
|
|
- {/* <View style={ui.flexcc}>
|
|
|
- <Text style={styles.rangeText}>9th Aug to 12th Aug</Text>
|
|
|
- <MaterialIcons
|
|
|
- name='arrow-drop-down'
|
|
|
- color={colorDark}
|
|
|
- size={28}/>
|
|
|
- </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>
|
|
|
- </View>
|
|
|
- { item.amountSymbol == 'M'
|
|
|
- ? <TextView style={styles.amountDuct}>- {item.amount}</TextView>
|
|
|
- : <TextView style={styles.amountText}>+ {item.amount}</TextView>
|
|
|
- }
|
|
|
- </View>
|
|
|
- </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>
|
|
|
+ { this.state.loading
|
|
|
+ ? <View style={styles.listView}>
|
|
|
+ { this.state.loadingList.map((item, index) =>
|
|
|
+ <View style={styles.itemView} key={index}>
|
|
|
+ <VbeSkeleton
|
|
|
+ style={styles.iconType}
|
|
|
+ layout={[
|
|
|
+ {width: 32, height: 32, borderRadius: 30, marginRight: 16}
|
|
|
+ ]}/>
|
|
|
+ <View style={styles.itemContent}>
|
|
|
+ <VbeSkeleton
|
|
|
+ style={ui.flex1}
|
|
|
+ layout={[
|
|
|
+ {width: '100%', height: 15, marginTop: 4},
|
|
|
+ {width: '60%', height: 15, marginTop: 4}
|
|
|
+ ]}/>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ : <><View style={styles.listView}>
|
|
|
+ { this.state.historyList.length > 0
|
|
|
+ ? this.state.historyList.map((item, index) => (
|
|
|
+ <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>
|
|
|
+ </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>
|
|
|
);
|
|
|
@@ -179,7 +197,7 @@ const styles = StyleSheet.create({
|
|
|
fontSize: 14
|
|
|
},
|
|
|
listView: {
|
|
|
- marginTop: 16,
|
|
|
+ marginTop: 0,
|
|
|
minHeight: $vh(30),
|
|
|
backgroundColor: colorLight
|
|
|
},
|