diff --git a/pages/index/index.js b/pages/index/index.js index 15b2d23..8088e9b 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -925,34 +925,34 @@ Page({ selectRegion: function(e) { const region = e.currentTarget.dataset.region + // 立即关闭弹窗 + this.setData({ + selectedRegion: region, + showRegionPicker: false + }) + // 重新显示tabBar const app = getApp(); if (app && app.globalData) { app.globalData.showTabBar = true; } - // 应用筛选条件 - this.setData({ - selectedRegion: region, - showRegionPicker: false - }, () => { - // 如果从局部地区切换到全国地区,重新加载所有商品 - if (region === '全国' && this.data.selectedCategory === '全部' && !this.data.searchKeyword) { - // 重新加载商品数据 - this.refreshGoodsList(); - } else { - // 否则仅对本地商品进行筛选 - const filteredGoods = this.applyFilters(this.data.goods, false) - const groupedGoods = this.groupGoodsForStaggeredLayout(filteredGoods) - const { leftColumnGoods, rightColumnGoods } = this.distributeToColumns(filteredGoods) - this.setData({ - filteredGoods: filteredGoods, - groupedGoods: groupedGoods, - leftColumnGoods: leftColumnGoods, - rightColumnGoods: rightColumnGoods - }) - } - }) + // 如果从局部地区切换到全国地区,重新加载所有商品 + if (region === '全国' && this.data.selectedCategory === '全部' && !this.data.searchKeyword) { + // 重新加载商品数据 + this.refreshGoodsList(); + } else { + // 否则仅对本地商品进行筛选 + const filteredGoods = this.applyFilters(this.data.goods, false) + const groupedGoods = this.groupGoodsForStaggeredLayout(filteredGoods) + const { leftColumnGoods, rightColumnGoods } = this.distributeToColumns(filteredGoods) + this.setData({ + filteredGoods: filteredGoods, + groupedGoods: groupedGoods, + leftColumnGoods: leftColumnGoods, + rightColumnGoods: rightColumnGoods + }) + } }, // 阻止事件冒泡 diff --git a/pages/index/index.wxml b/pages/index/index.wxml index b7219fd..49fbb00 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -10,8 +10,7 @@ - {{selectedRegion || '全国'}} - + {{selectedRegion || '全国'}} ▼ 🔍 @@ -29,14 +28,14 @@ - + 选择地区 {{item}} @@ -134,7 +133,7 @@ - +