Authored by 于良

品牌搜索无数据页面 review by 草莓

... ... @@ -13,6 +13,7 @@ import {
} from 'react-native';
import AllBrandListCell from '../AllBrandListCell';
import NoData from './NoData';
export default class Brand extends Component {
constructor(props) {
... ... @@ -61,6 +62,7 @@ export default class Brand extends Component {
render() {
let {
filtedBrands,
noData,
} = this.props;
let data = {
... ... @@ -72,13 +74,13 @@ export default class Brand extends Component {
return (
<View style={styles.container}>
<ListView
{noData ? <NoData /> : <ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRowsAndSections(data)}
renderRow={this.renderRow}
renderSectionHeader={this.renderSectionHeader}
/>
/>}
</View>
);
}
... ...
... ... @@ -31,7 +31,7 @@ export default class BrandSearch extends Component {
render() {
let {history, hot, filtedBrands, keyword, style} = this.props.data;
let {history, hot, filtedBrands, keyword, noData, style} = this.props.data;
let showBrandList = filtedBrands && filtedBrands.size > 0;
return (
<View style={[styles.container, style]}>
... ... @@ -47,6 +47,7 @@ export default class BrandSearch extends Component {
{showBrandList ?
<BrandList
filtedBrands={filtedBrands}
noData={noData}
onPressBrandSearchItem={this.props.onPressBrandSearchItem}
/> : <SearchKeyword
history={history}
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
Text,
Dimensions,
StyleSheet,
} = ReactNative;
export default class NoData extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Text style={styles.container}>{'无结果'}</Text>
);
}
}
let styles = StyleSheet.create({
container: {
width: Dimensions.get('window').width,
height: 40,
fontSize: 20,
fontWeight: 'bold',
color: '#999999',
textAlign: 'center',
marginTop: 100,
backgroundColor: 'transparent',
},
});
... ...
... ... @@ -157,8 +157,8 @@ class BrandContainer extends Component {
this.props.actions.filteBrandForKeyword(text);
}
_setBrandData(data,brandChannelFliter) {
this.props.actions.setBrandData(data,brandChannelFliter);
_setBrandData(data, selectedChannelId) {
this.props.actions.setBrandData(data, selectedChannelId);
}
_onPressKeyword(keyword) {
... ...
... ... @@ -550,9 +550,12 @@ export function filteBrandForKeyword(text) {
}
let result = {
list: {},
noData: false,
};
if (!text) {
dispatch(filtedBrandList(result));
return;
... ... @@ -561,7 +564,7 @@ export function filteBrandForKeyword(text) {
text = text.toLowerCase();
let pinyin = new Pinyin(false, 'lower');
let noData = true;
brandList && brandList.map((value, key) => {
let matchs = value.filter((v, k) => {
let name = v.get('brand_name', '').toLowerCase();
... ... @@ -582,10 +585,13 @@ export function filteBrandForKeyword(text) {
return false;
});
result[key] = matchs;
if (matchs.size > 0) {
noData = false;
}
result.list[key] = matchs;
});
result.noData = noData;
dispatch(filtedBrandList(result));
};
... ...
... ... @@ -67,6 +67,7 @@ let InitialState = Record({
hot: List(),
filtedBrands: Map(),
keyword: '',
noData: false,
})),
});
... ...
... ... @@ -288,7 +288,9 @@ export default function brandReducer(state=initialState, action) {
}
case FILTE_BRAND_LIST: {
return state.setIn(['search', 'filtedBrands'], Immutable.fromJS(action.payload));
let {list, noData} = action.payload;
return state.setIn(['search', 'filtedBrands'], Immutable.fromJS(list))
.setIn(['search', 'noData'], noData);
}
case SET_BRAND_KEYWORD: {
... ...