Authored by 盖剑秋

Add loading indicator.

... ... @@ -9,6 +9,9 @@ import {
Text,
ListView,
Dimensions,
ActivityIndicatorIOS,
Platform,
ProgressBarAndroid,
} from 'react-native';
... ... @@ -78,14 +81,32 @@ export default class AccountSettlement extends Component {
return (<Text>Error data source</Text>);
}
render() {
let isFetching = this.props.isFetching;
let loadText = isFetching?'加载中':'上拉加载更多';
return (
<View style={styles.container}>
<View>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRowsAndSections(this.props.dataBlob.toJS())}
renderRow={this.renderRow}
onEndReachedThreshold={-50}
onEndReached={this.props.fetchNextPage}
enableEmptySections={true}
renderFooter={()=>{
if (Platform.OS === 'android') {
return <View style={styles.footerContainer}>
<ProgressBarAndroid style={styles.footerIndicator}/>
<Text style = {styles.footerText}>{loadText}</Text>
</View>
} else {
return <View style={styles.footerContainer}>
<ActivityIndicatorIOS style={styles.footerIndicator} size='small' animating={isFetching}/>
<Text style = {styles.footerText}>{loadText}</Text>
</View>
}
}}
/>
</View>
);
... ... @@ -113,6 +134,21 @@ const styles = StyleSheet.create({
textAlign: 'center',
},
footerContainer: {
flexDirection: 'row',
},
footerIndicator: {
marginTop: 15,
marginLeft: Dimensions.get('window').width/2-50,
marginRight: 10,
},
footerText: {
marginTop: 17,
textAlign: 'center',
color:'#b1b1b1',
},
container: {
top: 64,
flex:1,
... ...
... ... @@ -70,6 +70,7 @@ export default class AccountSettlementContainer extends Component {
<AccountSettlement
dataBlob={mapBlob}
fetchNextPage={this.fetchNextPage}
isFetching={this.props.actStmt.isFetching}
/>
);
... ...
'use strict';
import Request from './Request';
import moment from 'moment';
export default class UserService {
... ... @@ -10,30 +9,12 @@ export default class UserService {
this.api = new Request();
}
async overview(brandId) {
let dateId = moment().format('YYYYMMDD'); //20160524
return await this.api.get({
url: '/operations/api/v6/category/getCategory',
body: {
brandId,
dateId
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async overview(shopId) {
async brandRank(brandId) {
let dateId = moment().format('YYYYMMDD'); //20160524
return await this.api.get({
url: '/operations/api/v6/category/getCategory',
body: {
brandId,
dateId
shopId,
}
})
.then((json) => {
... ...