Authored by 孙凯

add header 切换逻辑 review by 红魔

... ... @@ -59,15 +59,18 @@ export default class BrandStore extends Component {
case 'brandReource': {
return (
<BrandStoreFilter
onPressFilter={this.props.onPressFilter}
selectID = {this.props.storeFilter}
onPressStoreFilter={this.props.onPressStoreFilter}
/>
);
}
break;
// 底部商品列表筛选工具栏
case 'hotProducts_APP': {
case 'storeFilter': {
return (
<Text>最新、价格、折扣、筛选</Text>
<BrandStoreFilter
selectID = {this.props.storeFilter}
onPressStoreFilter={this.props.onPressStoreFilter}
/>
);
}
break;
... ... @@ -108,12 +111,13 @@ export default class BrandStore extends Component {
break;
case '1':
{
return (
<BrandListCell
resource={rowData}
onPressBrandItem={this.props.onPressBrandItem}
/>
);
return null;
// return (
// <BrandListCell
// resource={rowData}
// onPressBrandItem={this.props.onPressBrandItem}
// />
// );
}
break;
case '2':
... ... @@ -161,6 +165,18 @@ export default class BrandStore extends Component {
break;
}
}else if (sectionID == 'storeFilter') {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft, marginTop: 0} : {paddingLeft};
return (
<BrandProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
/>
);
return null;
}else if (sectionID == 'productList') {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft, marginTop: 0} : {paddingLeft};
... ... @@ -176,7 +192,7 @@ export default class BrandStore extends Component {
}
}
render() {
let {info, resource, coupon, productList} = this.props;
let {info, resource, coupon,productList,storeFilter} = this.props;
let {
shopTopBanner_APP,
oneRowTwoColImages_APP,
... ... @@ -186,17 +202,24 @@ export default class BrandStore extends Component {
hotProducts_APP,
} = resource;
let dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
brandReource:[coupon,brandBrowse,largeSlideImg_APP,oneRowTwoColImages_APP,recommend_APP,hotProducts_APP.list ? hotProducts_APP.list.toArray() : []],
productList: productList.list.toArray(),
};
// console.log(coupon.toJS())
// console.log(brandBrowse.toJS())
// console.log(largeSlideImg_APP.toJS())
// console.log(oneRowTwoColImages_APP.toJS())
let dataSource = null;
if (storeFilter == 0) {
dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
brandReource:[coupon,brandBrowse,largeSlideImg_APP,oneRowTwoColImages_APP,recommend_APP,hotProducts_APP.list ? hotProducts_APP.list.toArray() : []],
productList: productList.list.toArray(),
};
}else if (storeFilter == 1){
dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
storeFilter:productList.list.toArray(),
};
}else if (storeFilter == 2){
dataSource = {
shopTopBanner_APP: [shopTopBanner_APP],
storeFilter:productList.list.toArray(),
};
}
return (
<ListView
contentContainerStyle={styles.contentContainer}
... ...
... ... @@ -48,7 +48,7 @@ export default class BrandStoreFilter extends React.Component {
isSelect: false,
},
],
selectedIndex: 0,
selectedIndex: this.props.selectID,
};
}
... ... @@ -66,13 +66,13 @@ export default class BrandStoreFilter extends React.Component {
filter.isSelect = !filter.isSelect;
filters[rowID] = filter;
this.setState({
selectedIndex: rowID,
filters,
});
let value = filter.isSelect;
this.props.onPressFilter(value);
if (rowID != 3) {
this.setState({
selectedIndex: rowID,
filters,
});
}
this.props.onPressStoreFilter(rowID);
}}>
<View key={'row' + rowID} style={styles.rowContainer}>
<Text style={[styles.name, colorStyle]}>{rowData.name}</Text>
... ...
... ... @@ -2,11 +2,12 @@ import keyMirror from 'key-mirror';
export default keyMirror({
SET_COLLECTION: null,
SET_STOREFILTER:null,
SEL_BRANDITEM:null,
SEL_COUPONITEM:null,
SET_PLATFORM: null,
SET_SHOP_ID: null,
SHOP_INFO_SUCCESS: null,
SHOP_INFO_REQUEST: null,
SHOP_INFO_FAILURE: null,
... ...
... ... @@ -46,7 +46,7 @@ class BrandStoreContainer extends Component {
this._onPressBrandItem= this._onPressBrandItem.bind(this);
this._onPressOneRowTwoColImages= this._onPressOneRowTwoColImages.bind(this);
this._onPressRecommendItem= this._onPressRecommendItem.bind(this);
this._onPressFilter= this._onPressFilter.bind(this);
this._onPressStoreFilter= this._onPressStoreFilter.bind(this);
this._onPressProduct= this._onPressProduct.bind(this);
}
... ... @@ -90,25 +90,29 @@ class BrandStoreContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressFilter(){
alert("_onPressFilter");
_onPressStoreFilter(value){
if (value == 3) {
alert("打开全部商品");
}else {
this.props.actions.setStoreFilter(value);
}
}
render() {
let {info, resource, coupon,productList} = this.props.brandStore;
let {info, resource, coupon,productList,storeFilter} = this.props.brandStore;
return (
<BrandStore
info={info}
resource={resource}
coupon={coupon}
productList={productList}
storeFilter={storeFilter}
onPressCollection={this._onPressCollection}
onPressCoupon={this._onPressCoupon}
onPressBrandItem={this._onPressBrandItem}
onPressOneRowTwoColImages={this._onPressOneRowTwoColImages}
onPressRecommendItem={this._onPressRecommendItem}
onPressFilter={this._onPressFilter}
onPressStoreFilter={this._onPressStoreFilter}
onPressProduct={this._onPressProduct}
/>
);
... ...
... ... @@ -7,6 +7,7 @@ import {parseShopResources} from '../../utils/ResourceParser';
const {
SET_COLLECTION,
SET_STOREFILTER,
JUMP_WITH_URL,
SET_SCANTYPE,
JUMP_WITH_OBJECT_NEWFLAG,
... ... @@ -49,6 +50,13 @@ export function onPressCollection() {
};
}
export function setStoreFilter(filter) {
return {
type: SET_STOREFILTER,
payload: filter
};
}
export function setShopId(shopId) {
return {
type: SET_SHOP_ID,
... ...
... ... @@ -21,13 +21,13 @@ let InitialState = Record({
isFetching: false,
error: null,
shopTopBanner_APP: '', // 店铺banner
oneRowTwoColImages_APP: List(), // url src // 资源位小图
oneRowTwoColImages_APP: List(), // url src // 资源位小图
brandBrowse: new (Record({ // 店铺品牌一览
single: false,
brandId: 0,
brands: List(), // url src name
moreUrl: '',
})),
})),
largeSlideImg_APP: List(), // url src // 资源位大图幻灯
recommend_APP: new (Record({ // 热门品类
title: '热门品类',
... ... @@ -60,12 +60,12 @@ let InitialState = Record({
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
storeFilter: 0,
isCollection: false,
hasBuy : false,
touchBrandItem : false,
shopsBrands:List(),
});
export default InitialState;
... ...
... ... @@ -5,6 +5,7 @@ import Immutable, {Map} from 'immutable';
const {
ONEROWTWOCOLIMAGE,
SET_STOREFILTER,
SET_COLLECTION,
JUMP_WITH_URL,
SET_SCANTYPE,
... ... @@ -55,7 +56,9 @@ export default function brandStoreReducer(state=initialState, action) {
return state.setIn(['info', 'isFetching'], true)
.setIn(['info', 'error'], null);
}
case SET_STOREFILTER: {
return state.set('storeFilter', action.payload);
}
case SHOP_INFO_SUCCESS: {
let {
is_favorite,
... ...