diff --git a/pages/index/index.js b/pages/index/index.js index cf048d1..40600b6 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1670,8 +1670,8 @@ Page({ filtered = filtered.filter(item => item.isAd || (item.region && item.region.includes(selectedRegion))) } - // 应用高级筛选中的蛋壳颜色筛选 - if (this.data.advancedFilters.shellColor !== 'all') { + // 应用高级筛选中的蛋壳颜色筛选(仅当selectedCategory为"全部"时) + if (this.data.advancedFilters.shellColor !== 'all' && this.data.selectedCategory === '全部') { const selectedShellColor = this.data.advancedFilters.shellColor filtered = filtered.filter(item => item.isAd || (item.shellColor && item.shellColor.includes(selectedShellColor))) } @@ -1959,8 +1959,14 @@ Page({ searchKeyword: '', // 清除搜索关键词,筛选框优先级更高 }); + // 如果选择的不是"全部"分类,则同步更新高级筛选中的蛋壳颜色 + if (category !== '全部') { + this.setData({ + 'advancedFilters.shellColor': category + }); + } // 如果选择的是"全部"分类,则重置高级筛选条件 - if (category === '全部') { + else { this.resetAdvancedFilter(); } @@ -2022,10 +2028,22 @@ Page({ // 选择蛋壳颜色并关闭下拉菜单 selectShellColor: function (e) { const shellColor = e.currentTarget.dataset.color; - this.setData({ - 'advancedFilters.shellColor': shellColor, - showShellColorPicker: false - }); + + // 如果选择的不是"全部颜色",则同步更新品种筛选区域的选择 + if (shellColor !== 'all') { + this.setData({ + selectedCategory: shellColor, + 'advancedFilters.shellColor': shellColor, + showShellColorPicker: false + }); + } + // 如果选择的是"全部颜色",则只更新高级筛选中的蛋壳颜色 + else { + this.setData({ + 'advancedFilters.shellColor': shellColor, + showShellColorPicker: false + }); + } }, // 选择蛋黄类型并关闭下拉菜单