Authored by QC-L

完成筛选功能 review by 黄敬囿

... ... @@ -8,6 +8,7 @@ import sort from '../../static/images/sort.png';
import sortUp from '../../static/images/sort-up.png';
import sortDown from '../../static/images/sort-down.png';
import './index.scss';
import router from '../../router/index';
@connect(({ filterMenu }) => {
return {filterMenu}
... ... @@ -74,6 +75,13 @@ export default class filterMenu extends Component {
});
}
goToFilter() {
let { screen } = this.props;
router.go('filter', {
...screen
});
}
render() {
let {tabs, hasFilter, tabClass, filterMenu, fromPage} = this.props;
let {curOrder} = this.state;
... ... @@ -114,10 +122,10 @@ export default class filterMenu extends Component {
</View>
{
hasFilter &&
<Navigator className="filter-btn" url="/pages/filter/index" hover-class="none">
<View className="filter-btn" onClick={this.goToFilter} hover-class="none">
<Image src={filterIcon} className="filter-icon"></Image>
<Text className="text">筛选</Text>
</Navigator>
</View>
}
</View>
)
... ...
... ... @@ -29,7 +29,9 @@ export default class Search extends Component {
}
componentDidMount () {
searchModel.getFilterData().then(ret => {
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 || []
... ...
... ... @@ -3,13 +3,18 @@ import { View, Button } from '@tarojs/components';
import { SearchBar, FilterMenu, ProductList, PageTitle } from '../../components';
import { common as commonModel } from '../../models';
import { connect } from '@tarojs/redux';
import { bindActionCreators } from 'redux';
import { clearFilter } from '../../actions/filterData';
import './index.scss';
@connect(({ filterMenu, filterData }) => ({
filterMenu,
filterData
}))
}), (dispatch) => {
return bindActionCreators({
clearFilter
}, dispatch);
})
export default class SearchList extends Component {
constructor(props) {
... ... @@ -67,7 +72,6 @@ export default class SearchList extends Component {
}
}
params.gender = ''
// 初始化数据
tabs.map(item => {
... ... @@ -101,6 +105,11 @@ export default class SearchList extends Component {
this.getProductData(nextProps.filterMenu);
}
componentWillUnmount() {
let { clearFilter } = this.props;
clearFilter();
}
onScroll(e) {
if (e.detail.scrollTop > 72 && !this.state.isFixed) {
this.setState({
... ... @@ -193,8 +202,6 @@ export default class SearchList extends Component {
if (order) {
params.order = order;
} else {
// params.type = order ? '' : type;
}
// 系列,品牌,品类
... ... @@ -307,7 +314,7 @@ export default class SearchList extends Component {
<PageTitle pageTitle={pageTitle} selfClass="pd"></PageTitle>
}
<View className={ this.state.fixed ? 'fixed' : '' }>
<FilterMenu filterMenu={filterMenu} tabs={ this.state.tabs } fromPage="search" hasFilter = { this.state.hasFilter } > </FilterMenu>
<FilterMenu filterMenu={ filterMenu } tabs = { this.state.tabs } fromPage = "search" hasFilter = { this.state.hasFilter } screen={this.$router.params} > </FilterMenu>
< /View>
<ProductList list={productList[type]}></ProductList>
</ScrollView>
... ...
... ... @@ -33,5 +33,8 @@ export default {
},
search: {
path: '/pages/search/index'
}
},
filter: {
path: '/pages/filter/index'
},
}
\ No newline at end of file
... ...