|
|
/* eslint-disable react/no-unused-state */
|
|
|
import Taro, { Component, navigateBack } from '@tarojs/taro';
|
|
|
import { View, Text, Navigator, Button } from '@tarojs/components';
|
|
|
import { FilterGroup, PageTitle } from '../../components';
|
...
|
...
|
@@ -21,7 +22,7 @@ export default class Search extends Component { |
|
|
super(...arguments);
|
|
|
this.state = {
|
|
|
filter: [],
|
|
|
selectFilter: {}
|
|
|
selectList: {}
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -39,47 +40,45 @@ export default class Search extends Component { |
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
let {selectList} = this.state;
|
|
|
selectList = this.props.filterData;
|
|
|
if (selectList) {
|
|
|
this.setState({
|
|
|
selectList
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onChangeFilter(item) {
|
|
|
// let {setFilter, filterData} = this.props;
|
|
|
|
|
|
// if (filterData[this.state.filterId] && item.itemId === filterData[this.state.filterId]) {
|
|
|
// setFilter({[this.state.filterId]: ''});
|
|
|
// } else {
|
|
|
// setFilter({[this.state.filterId]: item.itemId});
|
|
|
// }
|
|
|
|
|
|
// console.log('================1111====================');
|
|
|
// console.log(item);
|
|
|
// console.log('=================11111================');
|
|
|
|
|
|
// let {selectFilter} = this.props;
|
|
|
|
|
|
// this.setState({
|
|
|
// selectFilter: item
|
|
|
// });
|
|
|
let {selectList} = this.state;
|
|
|
for (var key in item) {
|
|
|
selectList[key] = item[key]
|
|
|
}
|
|
|
|
|
|
// console.log('==================2222==================');
|
|
|
// console.log(selectFilter);
|
|
|
// console.log('==================2222==================');
|
|
|
this.setState({
|
|
|
selectList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
onResetFilter() {
|
|
|
let {setFilter} = this.props;
|
|
|
let filter = {};
|
|
|
let {selectList} = this.state;
|
|
|
|
|
|
this.state.filter.map(item => {
|
|
|
filter[item.filterId] = {};
|
|
|
});
|
|
|
for (var key in selectList) {
|
|
|
selectList[key] = '';
|
|
|
}
|
|
|
setFilter(selectList);
|
|
|
|
|
|
setFilter(filter);
|
|
|
this.setState({
|
|
|
selectList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
onConfirmSearch() {
|
|
|
console.log('====================================');
|
|
|
console.log(this.props.filterData);
|
|
|
console.log('====================================');
|
|
|
let {setFilter} = this.props;
|
|
|
let {selectList} = this.state;
|
|
|
setFilter(selectList);
|
|
|
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
...
|
...
|
@@ -87,7 +86,7 @@ export default class Search extends Component { |
|
|
}
|
|
|
|
|
|
render () {
|
|
|
let {filter} = this.state;
|
|
|
let {filter, selectList} = this.state;
|
|
|
|
|
|
return (
|
|
|
<View className="filter-page">
|
...
|
...
|
@@ -96,7 +95,7 @@ export default class Search extends Component { |
|
|
{
|
|
|
filter.map((item, index) => {
|
|
|
return (
|
|
|
<FilterGroup list={item} onChangeFilter={this.onChangeFilter.bind(this)} key={index}></FilterGroup>
|
|
|
<FilterGroup list={item} selectList={selectList} onChangeFilter={this.onChangeFilter.bind(this)} key={index}></FilterGroup>
|
|
|
)
|
|
|
})
|
|
|
}
|
...
|
...
|
|