fix search and filtering for /busqueda

This commit is contained in:
2025-10-10 15:00:36 +02:00
parent 987c388bff
commit 894546a901
2 changed files with 77 additions and 180 deletions

View File

@@ -38,9 +38,9 @@
<ClientOnly>
<v-range-slider
v-model="priceRange"
:min="0"
:max="500"
step="10"
:min="minPrice"
:max="maxPrice"
step="5"
thumb-label="always"
color="#143E8C"
track-color="#d6d5d5"
@@ -120,15 +120,17 @@
</template>
<script>
export default {
props: {
filters: {
type: Object,
default: () => ({}),
maxPrice: {
type: Number,
default: 500,
},
prices: {
type: Object,
default: () => ({}),
minPrice: {
type: Number,
default: 0,
},
currentFilters: {
type: Object,
@@ -144,16 +146,12 @@ export default {
data() {
return {
// filterForm: {
// shipping_cost: false,
// discount: false,
// },
screenSize: null,
visible: true,
checkedCategories: [],
categories: [
"Alimentación",
"Agricultura ",
"Agricultura",
"Energía",
"Hogar y jardín",
"Moda y Textil",
@@ -167,7 +165,7 @@ export default {
"Finanzas Éticas y Seguros",
"Servicios Profesionales",
],
priceRange: [0, 500],
priceRange: [this.minPrice, this.maxPrice],
priceRangeFilter: {},
place: null,
coordinates: null,
@@ -188,24 +186,25 @@ export default {
} else {
this.checkedCategories = [];
}
// if (Object.keys(newCurrentFilters).includes("shipping_cost")) {
// this.filterForm.shipping_cost = true;
// } else {
// this.filterForm.shipping_cost = false;
// }
}
//this.filterForm.discount = this.$route.query.hasOwnProperty("discount");
},
prices(newPrices) {
if (newPrices.min && newPrices.max) {
this.priceRange = [newPrices.min, newPrices.max];
if (newCurrentFilters["price_min"] && newCurrentFilters["price_max"]) {
this.priceRange = [newCurrentFilters["price_min"], newCurrentFilters["price_max"]];
}
else if (newCurrentFilters["price_min"] && !newCurrentFilters["price_max"]) {
this.priceRange = [newCurrentFilters["price_min"], this.maxPrice];
}
else if (!newCurrentFilters["price_min"] && newCurrentFilters["price_max"]) {
this.priceRange = [this.minPrice, newCurrentFilters["price_max"]];
}
else {
this.priceRange = [this.minPrice, this.maxPrice];
}
}
},
},
mounted() {
if (this.prices.min && this.prices.max) {
this.priceRange = [this.prices.min, this.prices.max];
if (this.currentFilters?.price_min && this.currentFilters?.price_max) {
this.priceRange = [this.currentFilters.price_min, this.currentFilters.prices_max];
}
this.screenSize = window.innerWidth;
window.addEventListener("resize", () => {
@@ -224,17 +223,7 @@ export default {
},
applyFilters() {
const filters = {};
filters.price_min = this.priceRange[0];
filters.price_max = this.priceRange[1];
//if (this.filterForm.shipping_cost) filters.shipping_cost = false;
//if (this.filterForm.discount) filters.discount = true;
filters.category = this.checkedCategories;
if (this.place) {
filters.latitude = this.place.geo.latitude;
filters.longitude = this.place.geo.longitude;
}
this.$emit("applyFilters", filters);
this.$emit("applyFilters", { category: [...this.checkedCategories], price_min: this.priceRange[0], price_max: this.priceRange[1] });
},
},
};
@@ -361,7 +350,6 @@ export default {
gap: 1rem;
}
.form-check-input {
&:checked {
background-color: $color-button;
}