Authored by 孙凯

add 下啦刷新 review by hongmo

... ... @@ -37,6 +37,9 @@ export default class TransferShipment extends Component {
render() {
let {resource} = this.props;
let dataList = resource?resource.get('records'):null;
let isLoadingMore = resource.get('isFetching') && resource.get('currentPage') > 0;
let endReached = resource.get('endReached');
return (
<View style={styles.container}>
<ListView
... ... @@ -44,12 +47,25 @@ export default class TransferShipment extends Component {
dataSource={this.dataSource.cloneWithRows(dataList?dataList.toArray():[])}
renderRow={this._renderRow}
enableEmptySections={true}
renderFooter={()=>{
if (endReached) {
return <View style={styles.placeholder} />;
} else {
return <LoadMoreIndicator isVisible={isLoadingMore} animating={true}/>;
}
}}
onEndReached={() => {
if (dataList && dataList.size > 0) {
this.props.onEndReached && this.props.onEndReached();
}
}}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const styles = StyleSheet.create({
container: {
flex: 1,
... ... @@ -58,5 +74,9 @@ const styles = StyleSheet.create({
listContainer: {
flex: 1,
backgroundColor: 'white',
}
},
placeholder: {
width,
height: 15,
},
});
... ...
... ... @@ -53,10 +53,12 @@ class TransferShipmentContainer extends Component {
this._checkUp = this._checkUp.bind(this);
this._setPurchaseNum = this._setPurchaseNum.bind(this);
this._resetData = this._resetData.bind(this);
this._onEndReached = this._onEndReached.bind(this);
}
componentDidMount() {
this.props.actions.resetData();
this.props.actions.getPurchaseList();
}
... ... @@ -64,6 +66,10 @@ class TransferShipmentContainer extends Component {
}
_onEndReached() {
this.props.actions.getPurchaseList();
}
_resetData(){
this.props.actions.resetData();
this.props.actions.getPurchaseList();
... ... @@ -87,7 +93,13 @@ class TransferShipmentContainer extends Component {
return (
<View style={styles.container}>
<TransferShipment resource={purchaseList} setPurchaseNum={this._setPurchaseNum} checkUp={this._checkUp} goToStatsPage={this._goToStatsPage}/>
<TransferShipment
resource={purchaseList}
setPurchaseNum={this._setPurchaseNum}
checkUp={this._checkUp}
goToStatsPage={this._goToStatsPage}
onEndReached={this._onEndReached}
/>
</View>
);
}
... ...
... ... @@ -117,8 +117,8 @@ export function getPurchaseList() {
let {purchaseList} = transferShipment;
if (purchaseList.isFetching || purchaseList.endReached) {
return;
}
return;
}
let shopId = home.shopId;
let pageSize = purchaseList.pageSize;
... ...
... ... @@ -69,6 +69,7 @@ export default function userReducer(state = initialState, action) {
case GET_PURCHASE_LIST_FAILURE:{
return state.setIn(['purchaseList', 'isFetching'], false)
.setIn(['purchaseList', 'error'], action.payload)
.setIn(['purchaseList', 'endReached'], true);
}
case CHECKUP_REQUEST:{
return state.setIn(['purchaseList', 'records'], Immutable.fromJS(action.payload));
... ...