Authored by yoho-js001

去掉默认和最新筛选,保留最新。

Showing 32 changed files with 443 additions and 5 deletions
... ... @@ -35,7 +35,7 @@ export default class ProductListCell extends Component {
browse = browse/10000.0;
browse = Math.round(browse*10)/10;
}
src = src.replace('{width}', rowWidth).replace('{height}',Math.ceil(214*width/750)).replace('{mode}',2);
src = src.replace('{width}', rowWidth*2).replace('{height}',Math.ceil(214*width/750)*2).replace('{mode}',2);
return (
<TouchableOpacity
... ...
... ... @@ -20,6 +20,8 @@ import BrandProductMoreFilter from '../../../brandStore/components/brandStore/br
import ProductCategoryList from '../../../brandStore/components/brandStore/brandStoreSubView/Cells/ProductCategoryList';
import BrandProductFilter from '../../../brandStore/components/brandStore/brandStoreSubView/Cells/BrandProductFilter';
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
import NewArrivalFilter from './NewArrivalFilter'
import NewArrivalCategoryList from './NewArrivalCategoryList'
import TagsCell from './TagsCell'
import ShopCell from './ShopCell'
import ArticleCell from './ArticleCell'
... ... @@ -209,7 +211,7 @@ export default class NewArrival extends Component {
yPosition = evt.nativeEvent.layout.y;
}}
>
<BrandProductFilter
<NewArrivalFilter
onPressFilter={this._onPressProductFilter}
lastSelected={this.props.productList.isFilter}
moreFilter={this.props.productList.isMoreFilter}
... ... @@ -283,7 +285,7 @@ export default class NewArrival extends Component {
}}
/>
{productList.isFilter ?
<ProductCategoryList
<NewArrivalCategoryList
productList={productList}
onPressFilter={this._onPressProductFilter}
lastSelected={this.props.productList.isFilter}
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
AppRegistry,
StyleSheet,
Text,
View,
Image,
ListView,
Dimensions,
TouchableOpacity,
} = ReactNative;
import NewArrivalFilter from './NewArrivalFilter';
import immutable from 'immutable';
export default class ProductCategoryList extends React.Component {
constructor(props) {
super(props);
this.leftRenderRow = this.leftRenderRow.bind(this);
this.rightRenderRow = this.rightRenderRow.bind(this);
this._pressLeftRow = this._pressLeftRow.bind(this);
this._pressRightRow = this._pressRightRow.bind(this);
this.dataSourceL = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
this.dataSourceR = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
}
_pressLeftRow(rowData) {
this.refs.subCategoryList && this.refs.subCategoryList.scrollTo({x: 0, y: 0, animated: false});
this.props.onPressProductFilterLeftItem(rowData);
}
_pressRightRow(rowData) {
let items = this.props.categoryFilterList.toJS().filter((item) => {
return item.isSelect;
});
if (items.length > 0) {
this.props.onPressProductFilterRightItem(items[0], rowData);
}
}
leftRenderRow(rowData, sectionID, rowID, highlightRow) {
let selectText = this.props.filterNameFactors.get(rowData.get('key'));
let arrow = rowData.get('isSelect') ? <Image style={styles.arrow} source={require('../../image/filter_category_select_icon.png')}/> : null;
return (
<TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS())}>
<View style={[styles.leftRow]} >
<View style={styles.leftRowText} >
<Text style={styles.title} numberOfLines={1}>
{rowData.get('name')}:{" " + selectText}
</Text>
{arrow}
</View>
<View style={[styles.underline]}></View>
</View>
</TouchableOpacity>
);
}
rightRenderRow(rowData, sectionID, rowID, highlightRow) {
let colorStyle = rowData.get('isSelect') ? {backgroundColor: '#DBDBDB'} : {backgroundColor: '#f4f4f4'};
return (
<TouchableOpacity onPress={() => this._pressRightRow(rowData.toJS())}>
<View style={[styles.rightRow, colorStyle]}>
<Text style={styles.subtitle} numberOfLines={1}>
{rowData.get('name')}
</Text>
<View style={[styles.underline]}></View>
</View>
</TouchableOpacity>
);
}
render() {
let {categoryFilterList, filterCategoryDetailFilterList, filterNameFactors} = this.props;
let subList = [];
let items = categoryFilterList.toJS().filter((item) => {
return item.isSelect;
});
if (items.length > 0) {
subList = filterCategoryDetailFilterList.get(items[0].key);
}
return (
<View style={styles.allcontainer}>
<NewArrivalFilter
onPressFilter={this.props.onPressFilter}
lastSelected={this.props.productList.isFilter}
moreFilter={this.props.productList.isMoreFilter}
selectOrder={this.props.productList.order}/>
<View style={styles.container}>
<ListView
style={styles.leftContentContainer}
dataSource={this.dataSourceL.cloneWithRows(categoryFilterList.toArray())}
renderRow={this.leftRenderRow}
scrollsToTop={false}
/>
<ListView
ref='subCategoryList'
style={styles.rightContentContainer}
dataSource={this.dataSourceR.cloneWithRows(subList.toArray())}
renderRow={this.rightRenderRow}
scrollsToTop={false}
/>
</View>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let rowHeight = Math.ceil(height - 37);
let rowWidth = Math.ceil(width / 2);
let styles = StyleSheet.create({
allcontainer:{
flex: 1,
flexDirection: 'column',
left: 0,
width: width,
height: height ,
backgroundColor: '#ffffff',
borderTopColor: '#e0e0e0',
borderTopWidth: 0.5,
borderLeftColor: '#ffffff',
borderLeftWidth: 0,
borderRightWidth: 0,
borderBottomWidth: 0,
},
container:{
flex: 1,
flexDirection: 'row',
position: 'absolute',
left: 0,
width: width,
height: height - 40 - 44 - 64,
backgroundColor: '#ffffff',
borderTopWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
borderBottomWidth: 0,
},
leftContentContainer: {
backgroundColor: '#ffffff',
},
leftRow: {
justifyContent: 'center',
height: 44,
width: rowWidth,
paddingLeft: 15,
backgroundColor: '#ffffff',
},
leftRowText: {
flexDirection: 'row',
alignItems: 'center',
height: 43.5,
width: rowWidth,
},
rightContentContainer: {
backgroundColor: '#f4f4f4',
},
rightRow: {
flexDirection: 'column',
justifyContent: 'center',
height: 44,
width: rowWidth,
paddingLeft: 15,
},
underline:{
width: rowWidth,
height: 0.5,
backgroundColor:'#e0e0e0',
position: 'absolute',
bottom: 0,
},
title: {
fontSize: 14,
color: '#444444',
width: rowWidth - 15 - 6,
},
subtitle: {
fontSize: 14,
color: '#b0b0b0',
},
arrow: {
justifyContent: 'flex-end',
alignItems: 'center',
width: 6,
height: 12,
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
Image,
Text,
ListView,
TouchableOpacity,
Dimensions,
StyleSheet,
} = ReactNative;
export default class BrandProductFilter extends React.Component {
constructor(props) {
super (props);
this._renderRow = this._renderRow.bind(this);
this._renderSeparator = this._renderSeparator.bind(this);
this._renderImage = this._renderImage.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.key != r2.key,
});
this.state = {
filters: [
{
key: 'new',
name: '最新',
value: {
asc: 's_t_desc',
desc: 's_t_desc',
},
isAsc: false,
radio: true,
},
{
key: 'price',
name: '价格',
value: {
asc: 's_p_asc',
desc: 's_p_desc',
},
isAsc: false,
radio: false,
},
{
key: 'discount',
name: '折扣',
value: {
asc: 'p_d_asc',
desc: 'p_d_desc',
},
isAsc: false,
radio: false,
},
{
key: 'filter',
name: '筛选',
value: {
asc: 'filter',
desc: 'filter',
},
isAsc: false,
radio: false,
},
],
selectedIndex: 0,
};
this.images = {
normal: require('../../image/filter/shared_segmentedcontrol_other_normal.png'),
asc: require('../../image/filter/shared_segmentedcontrol_other_up.png'),
desc: require('../../image/filter/shared_segmentedcontrol_other_down.png'),
down:require('../../image/filter/brandstore_filter_arrow_down.png'),
down_normal:require('../../image/filter/brandstore_filter_arrow_down_normal.png'),
up:require('../../image/filter/brandstore_filter_arrow_up.png'),
up_normal:require('../../image/filter/brandstore_filter_arrow_up_normal.png'),
};
}
componentWillReceiveProps(nextProps){
if(nextProps.selectOrder==''){
this.setState({
selectedIndex: 0,
});
}
}
_renderImage(rowData, rowID) {
let img;
if(rowID==0){
// if (rowID == this.state.selectedIndex) {
// img = this.props.moreFilter ? this.images.up : this.images.down;
// }else{
// img = this.props.moreFilter ? this.images.up_normal : this.images.down_normal;
// }
img = null;
}else if(rowID==3){
img = this.props.lastSelected ? this.images.up : this.images.down_normal;
}else{
if (rowID == this.state.selectedIndex){
img = rowData.isAsc ? this.images.asc : this.images.desc;
}else{
img = this.images.normal;
}
}
return <Image style={styles.image} source={img}/>;
}
_renderRow(rowData, sectionID, rowID) {
let colorStyle = rowID == this.state.selectedIndex ? {color: '#444444'} : {color: '#b0b0b0'};
if (rowID == 3) {
colorStyle = this.props.lastSelected ? {color: '#444444'} : {color: '#b0b0b0'};
}
if(rowID==0){
// if(this.props.selectOrder=='s_t_desc'){
// rowData.name='最新';
// }else{
// rowData.name='默认';
// }
}
return (
<View style={{backgroundColor: 'white'}}>
<TouchableOpacity style={{backgroundColor: 'white', flex: 1}} onPress={() => {
let filters = this.state.filters;
let filter = this.state.filters[rowID];
// if (filter.radio) {
// this.props.onPressFilter && this.props.onPressFilter(filters[0].key);
// return;
// }
if (rowID == 3) {
let value = 'filter';
this.props.onPressFilter && this.props.onPressFilter(value);
return;
}
filter.isAsc = !filter.isAsc;
filters[rowID] = filter;
this.setState({
selectedIndex: rowID,
filters,
});
let value = filter.isAsc ? filter.value['asc'] : filter.value['desc'];
this.props.onPressFilter && this.props.onPressFilter(value);
}}>
<View key={'row' + rowID} style={styles.rowContainer}>
<Text style={[styles.name, colorStyle]}>{rowData.name}</Text>
{this._renderImage(rowData, rowID)}
</View>
</TouchableOpacity>
</View>
);
}
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
</View>
);
}
render() {
let {style} = this.props;
return (
<View style={[styles.container, style]}>
<ListView
contentContainerStyle={[styles.contentContainer, style]}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(this.state.filters)}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
scrollEnabled={false}
scrollsToTop={false}
/>
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
</View>
);
}
}
let selCol = '444444'
let norCol = 'b0b0b0'
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
marginLeft: -1,
width: width + 2,
height: 40,
backgroundColor:'white',
},
contentContainer: {
flexDirection: 'row',
backgroundColor:'white',
},
rowContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
width: Math.ceil(width / 4),
height: 40,
backgroundColor: 'white',
},
name: {
color: '#b0b0b0',
},
image: {
marginTop: 2,
marginLeft: 2,
},
separator: {
width: 0.5,
top: 12.5,
height: 15,
backgroundColor: '#e5e5e5',
},
});
... ...
... ... @@ -43,7 +43,7 @@ export default class ProductListCell extends Component {
>
<View style={{flex:1}}>
<View style={styles.imageContainer}>
<Image style={styles.image} source={{uri: shop_logo.replace('{width}', 120).replace('{height}', 50)}}/>
<Image style={styles.image} source={{uri: shop_logo.replace('{width}', 240).replace('{height}', 100)}}/>
<Text style={styles.name}>{shop_name}</Text>
<Text style={styles.text}>
上新
... ...
... ... @@ -20,7 +20,7 @@ let InitialState = Record({
isMoreFilter:false,
error: null,
list: List(),
order: 's_n_desc',
order: 's_t_desc',
currentPage: 0,
pageCount: 0,
pageSize: 60,//60,
... ...