...
|
...
|
@@ -25,164 +25,110 @@ import BrandStoreHeaderView from '../brandStore/brandStoreSubView/SessionHeader/ |
|
|
import CouponCell from '../brandStore/brandStoreSubView/Cells/CouponCell';
|
|
|
import BrandListCell from '../brandStore/brandStoreSubView/Cells/BrandListCell';
|
|
|
import BrandSwiper from '../brandStore/brandStoreSubView/Cells/BrandSwiper';
|
|
|
import OneRowTwoColImages from '../brandStore/brandStoreSubView/Cells/OneRowTwoColImages';
|
|
|
|
|
|
export default class BrandStore extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
let getSectionData = (dataBlob, sectionID) => {
|
|
|
return dataBlob[sectionID];
|
|
|
};
|
|
|
|
|
|
let getRowData = (dataBlob, sectionID, rowID) => {
|
|
|
return dataBlob[sectionID + ':' + rowID];
|
|
|
};
|
|
|
|
|
|
this.state = {
|
|
|
dataSource: new ListView.DataSource({
|
|
|
getSectionData: getSectionData, // 获取组中数据
|
|
|
getRowData: getRowData, // 获取行中的数据
|
|
|
rowHasChanged: (r1, r2) => r1 != r2,
|
|
|
sectionHeaderHasChanged: (s1, s2) => s1 !== s2
|
|
|
})
|
|
|
};
|
|
|
|
|
|
this.loadDataFromJason();
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
});
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
// this.props.actions.getShopsIntro();
|
|
|
|
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
|
}
|
|
|
|
|
|
loadDataFromJason() {
|
|
|
let jsonData = require('../../image/Car.json');
|
|
|
let dataBlob = {},
|
|
|
sectionIDs = [],
|
|
|
rowIDs = [],
|
|
|
cars = [];
|
|
|
let datas = jsonData.data;
|
|
|
for (let i in datas) {
|
|
|
//step 1、把组数据放入sectionIDs数组中
|
|
|
sectionIDs.push(i);
|
|
|
//step 2、把组中内容放dataBlob对象中
|
|
|
dataBlob[i] = datas[i].title;
|
|
|
//step 3、取出该组中所有的车
|
|
|
cars = datas[i].cars;
|
|
|
//step 4记录每一行中的数据
|
|
|
rowIDs[i] = [];
|
|
|
//step 5、获取行中每一组数据
|
|
|
for (let j in cars) {
|
|
|
//把行号放入rowIDs中
|
|
|
rowIDs[i].push(j);
|
|
|
//把每一行中的内容放dataBlob对象中
|
|
|
dataBlob[i + ':' + j] = cars[j];
|
|
|
}
|
|
|
}
|
|
|
this.state = {
|
|
|
dataSource: this.state.dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs)
|
|
|
};
|
|
|
}
|
|
|
render() {
|
|
|
|
|
|
|
|
|
let src = this.props.src.toArray();
|
|
|
return (
|
|
|
<ListView
|
|
|
dataSource={this.state.dataSource}
|
|
|
dataSource={this.dataSource.cloneWithRows(src)}
|
|
|
renderRow={this.renderRow.bind(this)}
|
|
|
renderSectionHeader={this.renderSectionHeader.bind(this)}
|
|
|
renderHeader = {this.renderHeader.bind(this)}
|
|
|
// renderSectionHeader={this.renderSectionHeader.bind(this)}
|
|
|
// renderHeader = {this.renderHeader.bind(this)}
|
|
|
contentContainerStyle={styles.listViewStyle}//设置cell的样式
|
|
|
enableEmptySections = {true}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
// 每一行的数据
|
|
|
renderRow(rowData,sectionID,rowID,highlightRow) {
|
|
|
|
|
|
if (sectionID === '0') {
|
|
|
switch (rowID) {
|
|
|
case '0':
|
|
|
{
|
|
|
return (
|
|
|
<CouponCell
|
|
|
src={'aa'}
|
|
|
onPressCoupon={this._onPressCoupon}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
case '1':
|
|
|
{
|
|
|
return (
|
|
|
<BrandListCell
|
|
|
src={'aa'}
|
|
|
onPressBrandItem={this._onPressBrandItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
return (
|
|
|
<BrandSwiper
|
|
|
src={'aa'}
|
|
|
onPressBrandItem={this._onPressBrandItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}else {
|
|
|
return (
|
|
|
<TouchableOpacity activeOpacity={0.5}>
|
|
|
<View style={styles.row}>
|
|
|
<Text style={styles.text}>
|
|
|
{rowData.name}
|
|
|
</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 每一组中的数据
|
|
|
renderSectionHeader(sectionData, sectionID) {
|
|
|
|
|
|
//根据数据显示不同的header
|
|
|
switch (sectionData) {
|
|
|
case 'A':
|
|
|
{
|
|
|
return (
|
|
|
<View style={styles.headerViewStyle}>
|
|
|
<Text style={{marginLeft: 5, color: 'white'}}>{sectionData}</Text>
|
|
|
</View>
|
|
|
if (rowData.get('resource_name') == 'shopTopBanner_APP') {
|
|
|
return(
|
|
|
<BrandStoreHeaderView
|
|
|
src={rowData.get('resource_data')}
|
|
|
onPressCollection={this._onPressCollection}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
return (
|
|
|
<View style={styles.headerViewStyle}>
|
|
|
<Text style={{marginLeft: 5, color: 'white'}}>{sectionData}</Text>
|
|
|
</View>
|
|
|
}else if (rowData.get('resource_name') == 'largeSlideImg_APP') {
|
|
|
return <BrandSwiper
|
|
|
src={rowData.get('resource_data')}
|
|
|
onPressBrandItem={this._onPressBrandItem}
|
|
|
/>;
|
|
|
}else if (rowData.get('resource_name') == 'oneRowTwoColImages_APP') {
|
|
|
return(
|
|
|
<OneRowTwoColImages
|
|
|
src={rowData.get('resource_data')}
|
|
|
onPressOneRowTwoColImages={this._onPressOneRowTwoColImages}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
|
|
|
|
|
|
renderHeader(){
|
|
|
return(
|
|
|
<BrandStoreHeaderView
|
|
|
src={'aa'}
|
|
|
onPressCollection={this._onPressCollection}
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
// <CouponCell
|
|
|
// src={'aa'}
|
|
|
// onPressCoupon={this._onPressCoupon}
|
|
|
// />
|
|
|
|
|
|
// <BrandListCell
|
|
|
// src={'aa'}
|
|
|
// onPressBrandItem={this._onPressBrandItem}
|
|
|
// />
|
|
|
}
|
|
|
|
|
|
// 每一组中的数据
|
|
|
// renderSectionHeader(sectionData, sectionID) {
|
|
|
//
|
|
|
// //根据数据显示不同的header
|
|
|
// switch (sectionData) {
|
|
|
// case 'A':
|
|
|
// {
|
|
|
// return (
|
|
|
// <View style={styles.headerViewStyle}>
|
|
|
// <Text style={{marginLeft: 5, color: 'white'}}>{sectionData}</Text>
|
|
|
// </View>
|
|
|
// );
|
|
|
// }
|
|
|
// break;
|
|
|
// default:
|
|
|
// {
|
|
|
// return (
|
|
|
// <View style={styles.headerViewStyle}>
|
|
|
// <Text style={{marginLeft: 5, color: 'white'}}>{sectionData}</Text>
|
|
|
// </View>
|
|
|
// );
|
|
|
// }
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// renderHeader(){
|
|
|
// return(
|
|
|
// <BrandStoreHeaderView
|
|
|
// src={'aa'}
|
|
|
// onPressCollection={this._onPressCollection}
|
|
|
// />
|
|
|
// );
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
let styles = StyleSheet.create({
|
...
|
...
|
|