...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
import React, {Component} from 'react';
|
|
|
import PlainTextSection from './PlainTextSection';
|
|
|
import Placeholder from './Placeholder';
|
|
|
import LoadMoreIndicator from './indicator/LoadMoreIndicator';
|
|
|
|
|
|
import {
|
|
|
StyleSheet,
|
...
|
...
|
@@ -20,45 +21,82 @@ export default class StockStats extends Component { |
|
|
super (props);
|
|
|
|
|
|
this.ds = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => r1 !== r2,
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
|
|
});
|
|
|
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
return (
|
|
|
<TouchableHighlight underlayColor={'white'} onPress={() => {}}>
|
|
|
<View style={styles.row}>
|
|
|
<Image source={{uri: rowData.thumb}} style={styles.thumb}/>
|
|
|
<View style={styles.detail}>
|
|
|
<Text style={styles.brand}>{rowData.brand}</Text>
|
|
|
<Text style={styles.product}>{rowData.product}</Text>
|
|
|
<Text style={styles.brand}>{'厂家编号:' + rowData.vendor + ' sku:' + rowData.sku}</Text>
|
|
|
<Text style={styles.product}>{'进货价:' + rowData.importPrice + ' 库存:' + rowData.stockNum}</Text>
|
|
|
switch (sectionID) {
|
|
|
case 'SECTION_HEADER':
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<PlainTextSection content={rowData.section2} />
|
|
|
<Placeholder />
|
|
|
</View>
|
|
|
</View>
|
|
|
</TouchableHighlight>
|
|
|
);
|
|
|
);
|
|
|
|
|
|
|
|
|
case 'SECTION_TIME':
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<View style={styles.dateContainer}>
|
|
|
<Image source={require('../images/date.png')}/>
|
|
|
<Text style={styles.date}>{rowData.section1}</Text>
|
|
|
</View>
|
|
|
<Placeholder />
|
|
|
</View>
|
|
|
);
|
|
|
|
|
|
case 'SECTION_CONTENT':
|
|
|
return (
|
|
|
<TouchableHighlight underlayColor={'white'} onPress={() => {}}>
|
|
|
<View style={styles.row}>
|
|
|
<Image source={{uri: rowData.thumb}} style={styles.thumb}/>
|
|
|
<View style={styles.detail}>
|
|
|
<Text style={styles.brand}>{rowData.brand}</Text>
|
|
|
<Text style={styles.product}>{rowData.product}</Text>
|
|
|
<Text style={styles.brand}>{'厂家编号:' + rowData.vendor + ' sku:' + rowData.sku}</Text>
|
|
|
<Text style={styles.product}>{'进货价:' + rowData.importPrice + ' 库存:' + rowData.stockNum}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</TouchableHighlight>
|
|
|
);
|
|
|
default:
|
|
|
return (
|
|
|
<Text>Error data source</Text>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let isFetching = this.props.isFetching;
|
|
|
|
|
|
let loadText = '暂无更多数据';
|
|
|
if (!this.props.reachEnd) {
|
|
|
loadText = isFetching ? '正在加载...' : '上拉加载更多';
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<View style={styles.dateContainer}>
|
|
|
<Image source={require('../images/date.png')}/>
|
|
|
<Text style={styles.date}>{this.props.section1}</Text>
|
|
|
</View>
|
|
|
<Placeholder />
|
|
|
<PlainTextSection content={this.props.section2} />
|
|
|
<Placeholder />
|
|
|
<ListView
|
|
|
dataSource={this.ds.cloneWithRows(this.props.section3)}
|
|
|
dataSource={this.ds.cloneWithRowsAndSections(this.props.section.toJS())}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator}/>}
|
|
|
onEndReachedThreshold={-10}
|
|
|
onEndReachedThreshold={-50}
|
|
|
onEndReached={this.props.requestData}
|
|
|
enableEmptySections={true} />
|
|
|
enableEmptySections={true}
|
|
|
renderFooter={()=>{
|
|
|
return <LoadMoreIndicator
|
|
|
hidden={this.props.hideLoadingFooter}
|
|
|
loadingText={loadText}
|
|
|
animating={isFetching}
|
|
|
/>
|
|
|
}}
|
|
|
/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
...
|
...
|
|