Authored by huangyCode

修改查询列表参数和筛选参数

<template>
<div class="container" v-show="showType">
<div class="header">
<div class="back" @click="hide()"></div>
<div class="back" @click="back()"></div>
</div>
<div class="title">筛选</div>
<div class="content">
<div class="item" v-for="(filter,row) in filterData">
<div class="content-search">
<div class="item" v-if="filterData && filterData.length" v-for="(filter,row) in filterData">
<div class="item-title">{{filter.filterName}}</div>
<div v-if="filter.itemList && filter.itemList.length" class="item-list">
<div class="item-img-content" v-if="filter.filterId === 'brand'"
... ... @@ -17,10 +17,15 @@
</div>
<div class="item-text item-size" v-if="filter.filterId === 'size'" :style="i===0 && 'margin-left:1rem'"
:class="filterParams.size.includes(item.itemId) && 'item-text-selected'"
v-for="(item,i) in filter.itemList" @click="select({filterId:filter.filterId, itemId:item.itemId, row})">{{item.itemName}}</div>
<div class="item-text" v-if="filter.filterId === 'sort' || filter.filterId === 'gender'" :style="i===0 && 'margin-left:1rem'"
v-for="(item,i) in filter.itemList" @click="select({filterId:filter.filterId, itemId:item.itemId, row})">
{{item.itemName}}
</div>
<div class="item-text" v-if="filter.filterId === 'sort' || filter.filterId === 'gender'"
:style="i===0 && 'margin-left:1rem'"
:class="(filterParams.sort.includes(item.itemId) || filterParams.gender.includes(item.itemId)) && 'item-text-selected'"
v-for="(item,i) in filter.itemList" @click="select({filterId:filter.filterId, itemId:item.itemId, row})">{{item.itemName}}</div>
v-for="(item,i) in filter.itemList" @click="select({filterId:filter.filterId, itemId:item.itemId, row})">
{{item.itemName}}
</div>
</div>
</div>
</div>
... ... @@ -52,6 +57,12 @@ export default {
},
filterData: [],
filterVisible: false,
copyFilterParams: {
sort: [], // 品类id
brand: [], // 品牌id
gender: [], // 性别
size: [], // 尺码id
}
};
},
activated() {
... ... @@ -72,12 +83,19 @@ export default {
methods: {
...mapActions(['fetchFilterData']),
clear() {
this.setFilterParam({
let filterParams = {
sort: [], // 品类id
brand: [], // 品牌id
gender: [], // 性别
size: [], // 尺码id
});
};
for (let item of this.filterData) {
if (item.itemList && item.itemList.length === 1) {
filterParams[item.filterId].push(item.itemList[0].itemId);
}
}
this.setFilterParam(filterParams);
},
fetchData: async function(params) {
... ... @@ -93,7 +111,13 @@ export default {
this.filterParams = filterParams;
},
back() {
this.filterParams = {...this.copyFilterParams};
this.hide();
},
submit() {
this.copyFilterParams = {...this.filterParams};
let params = {
sort: this.filterParams.sort.join(','),
brand: this.filterParams.brand.join(','), // 品牌id
... ... @@ -137,7 +161,7 @@ export default {
this.setFilterParam(optParams);
},
setFilterParam({filter}) {
setFilterParam(filter) {
let filterParams = this.filterParams;
if (typeof filter === 'object' && Object.keys(filter).length) {
... ... @@ -158,7 +182,7 @@ export default {
}
};
</script>
<style scoped>
<style lang="scss" scoped>
.header {
width: 100%;
height: 45PX;
... ... @@ -190,45 +214,7 @@ export default {
margin-left: 40px;
}
.content {
}
.bottom {
height: 120px;
position: fixed;
bottom: 0;
z-index: 9;
width: 100%;
background: #fff;
display: flex;
border-top: 1px solid rgba(0, 0, 0, 0.12);
justify-content: space-between;
align-items: center;
}
.clear {
margin-left: 32px;
line-height: 80px;
text-align: center;
width: 330px;
height: 80px;
color: #000;
font-size: 32px;
border: 1px solid rgba(0, 0, 0, 0.12);
border-radius: 40px;
}
.submit {
line-height: 80px;
background-color: #08304B;
width: 330px;
height: 80px;
text-align: center;
color: #fff;
font-size: 32px;
border-radius: 40px;
margin-right: 32px;
}
.content-search {
.item {
margin-bottom: 60px;
... ... @@ -305,6 +291,44 @@ export default {
width: 140px;
height: 64px;
}
}
.bottom {
height: 120px;
position: fixed;
bottom: 0;
z-index: 9;
width: 100%;
background: #fff;
display: flex;
border-top: 1px solid rgba(0, 0, 0, 0.12);
justify-content: space-between;
align-items: center;
}
.clear {
margin-left: 32px;
line-height: 80px;
text-align: center;
width: 330px;
height: 80px;
color: #000;
font-size: 32px;
border: 1px solid rgba(0, 0, 0, 0.12);
border-radius: 40px;
}
.submit {
line-height: 80px;
background-color: #08304B;
width: 330px;
height: 80px;
text-align: center;
color: #fff;
font-size: 32px;
border-radius: 40px;
margin-right: 32px;
}
.back {
margin-top: 24px;
... ...
... ... @@ -98,8 +98,6 @@ export default {
}
if (Object.keys(params).length && params.type) {
this.type = params.type;
} else {
params.type = 6;
}
!params.order && (params.order = 'sale_desc');
this.fetchList({...params, isReset: true});
... ...
... ... @@ -9,18 +9,18 @@
</div>
</form>
<Scroll v-show="!query.length" :options="scrollOptions">
<div class="recent title middle" v-if="searchWord.length">热门推荐</div>
<div class="recent title middle" v-if="searchWord && searchWord.length">热门推荐</div>
<div class="content middle">
<div class="item" v-if="searchWord.length" v-for="item of searchWord" @click="goSearch({query : item.search_word})">
<div class="item" v-if="searchWord && searchWord.length" v-for="item of searchWord" @click="goSearch({query : item.search_word})">
{{item.search_word}}
</div>
</div>
<div class="recent middle" v-if="localHistory.length">
<div class="recent middle" v-if="localHistory && localHistory.length">
<div class="title">最近搜索</div>
<div class="search-clear search-clear-img" @click="clearLocalHistory()"></div>
</div>
<div class="content middle">
<div class="item" v-if="localHistory.length" v-for="item of localHistory" @click="goSearch({query : item})">{{item}}
<div class="item" v-if="localHistory && localHistory.length" v-for="item of localHistory" @click="goSearch({query : item})">{{item}}
</div>
</div>
</Scroll>
... ... @@ -72,7 +72,8 @@ export default {
this.$router.push({
name: 'List',
query: {
query: this.query
query: this.query,
type: 6
}
});
},
... ... @@ -85,7 +86,8 @@ export default {
this.$router.push({
name: 'List',
query: {
query
query,
type: 6
}
});
},
... ...