index.js
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import Taro, { Component, navigateBack } from '@tarojs/taro';
import { View, Text, Navigator, Button } from '@tarojs/components';
import { FilterGroup, PageTitle } from '../../components';
import {search as searchModel} from '../../models';
import { connect } from '@tarojs/redux';
import { bindActionCreators } from 'redux';
import { setFilter } from '../../actions/filterData';
import './index.scss';
import wx from '../../libs/wx';
@connect(({ filterData }) => ({
filterData
}), (dispatch) => {
return bindActionCreators({
setFilter
}, dispatch);
})
export default class Search extends Component {
constructor() {
super(...arguments);
this.state = {
filter: []
};
}
config = {
navigationBarTitleText: '筛选'
}
componentDidMount () {
console.log(this.$router);
let { params } = this.$router;
searchModel.getFilterData(params).then(ret => {
if (ret && ret.code === 200) {
this.setState({
filter: ret.data && ret.data.filter || []
});
}
});
}
onResetFilter() {
let {setFilter} = this.props;
let filter = {};
this.state.filter.map(item => {
filter[item.filterId] = {};
});
setFilter(filter);
}
onConfirmSearch() {
console.log('====================================');
console.log(this.props.filterData);
console.log('====================================');
wx.navigateBack({
delta: 1
})
}
render () {
let {filter} = this.state;
return (
<View className="filter-page">
<PageTitle pageTitle="筛选"></PageTitle>
{
filter.map((item, index) => {
return (
<FilterGroup list={item} key={index}></FilterGroup>
)
})
}
<View className="filter-btn">
<View className="reset-btn" onClick={this.onResetFilter}>清空</View>
<Button className="confirm-btn" onClick={this.onConfirmSearch}>确认</Button>
</View>
</View>
)
}
}